Skip to main content

Polynomial2D example 7

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" )
f1 = m1 + 1
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+1x0y0+1x1y1f(x,y)=+1x^0*y^0+1x^1*y^1

!!! note "integer+monomial"

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

!!! example "result"

f(x,y)=+1x0y0+1x1y1f(x,y)=+1x^0*y^0+1x^1*y^1

!!! note "monomial + real"

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

!!! example "result"

f(x,y)=+1x0y0+1x1y1f(x,y)=+1x^0*y^0+1x^1*y^1

!!! note "real + monomial"

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

!!! example "result"

f(x,y)=+1x0y0+1x1y1f(x,y)=+1x^0*y^0+1x^1*y^1

!!! note "monomial+ monomial"

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

!!! example "result"

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

!!! note "polynomial + monomial"

  m2 = Monomial2D( 2, 0, "x", "y" )
f1 = f1 + m2
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+2x1y1+1x2y0f(x,y)=+2x^1*y^1+1x^2*y^0

!!! note "monomial + polynomial"

  m2 = Monomial2D( 0, 2, "x", "y" )
f1 = m2 + f1
call f1%display( 'f(x,y)=' )

!!! example "result"

f(x,y)=+1x0y2+2x1y1+1x2y0f(x,y)=+1x^0*y^2+2x^1*y^1+1x^2*y^0

!!! note "polynomial + polynomial"

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

!!! example "result"

f(x,y)=+2x0y2+4x1y1+2x2y0f(x,y)=+2x^0*y^2+4x^1*y^1+2x^2*y^0

!!! note "polynomial + integer"

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

!!! example "result"

f(x,y)=+1x0y2+1x0y0+2x1y1+1x2y0f(x,y)=+1x^0*y^2+1x^0*y^0+2x^1*y^1+1x^2*y^0

!!! note "integer + polynomial"

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

!!! example "result"

f(x,y)=+1x0y2+1x0y0+2x1y1+1x2y0f(x,y)=+1x^0*y^2+1x^0*y^0+2x^1*y^1+1x^2*y^0
END PROGRAM main