Skip to main content

Polynomial2D example 9

This example shows the usage of [[Polynomial2D_]] class. In this example we get polynomials by adding monomials.

  • poly = mono * integer
  • poly = mono * real
  • poly = integer * mono
  • poly = real * mono
  • poly = mono * mono
  • poly = mono * poly
  • poly = poly * mono
  • poly = poly * poly
  • poly = poly * integer
  • poly = poly * real
  • poly = integer * poly
  • poly = real * poly

Modules and classes

  • [[Polynomial2D_]]

Usage

PROGRAM main
use easifemBase
use easifemClasses
implicit none
type(Polynomial2D_) :: f1, f2
type(Monomial2D_) :: m1, m2

!!! note "Monomial * integer" Initiate the [[Monomial2D_]] object.

m=xym=xy
  m1 = Monomial2D( 1,1,"x","y" )
m2 = Monomial2D( 2, 0, "x", "y" )
f1 = m1 * 2
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+2x1y1f(x,y)=+2x^1 y^1

!!! note "integer * monomial"

  f1 = 2*m1
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+2x1y1f(x,y)=+2x^1 y^1

!!! note "monomial * real"

  f1 = m1 * 2.0
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+2x1y1f(x,y)=+2x^1 y^1

!!! note "real * monomial"

  f1 = 2.0 * m1
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+2x1y1f(x,y)=+2x^1 y^1

!!! note "monomial * monomial"

  f1 = m1 * m1
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+1x2y2f(x,y)=+1x^2 y^2

!!! note "polynomial * monomial"

  f1 = m1 + m2
f2 = f1 * m2
call f2%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+1x3y1+1x4f(x,y)=+1x^3 y^1+1x^4

!!! note "monomial * polynomial"

  f2 = m2 * f1
call f2%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+1x3y1+1x4f(x,y)=+1x^3 y^1+1x^4

!!! note "polynomial * polynomial"

  f2 = f1 * f1
call f2%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+1x2y2+2x3y1+1x4f(x,y)=+1x^2 y^2+2x^3 y^1+1x^4

!!! note "polynomial * integer"

  f2 = f1 * 2
call f2%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+2x1y1+2x2f(x,y)=+2x^1 y^1+2x^2

!!! note "integer * polynomial"

  f2 = 2*f1
call f2%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+2x1y1+2x2f(x,y)=+2x^1 y^1+2x^2
END PROGRAM main