Skip to main content

Polynomial2D example 8

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)=1+1x1y1f(x,y)=-1+1x^1 y^1

!!! note "integer-monomial"

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

!!! example "result"

f(x,y)=+11x1y1f(x,y)=+1-1x^1 y^1

!!! note "monomial - real"

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

!!! example "result"

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

!!! note "real - monomial"

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

!!! example "result"

f(x,y)=+11x1y1f(x,y)=+1-1x^1 y^1

!!! note "monomial- monomial"

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

!!! example "result"

f(x,y)=f(x,y)=

!!! note "polynomial - monomial"

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

!!! example "result"

f(x,y)=+1x1y11x2f(x,y)=+1x^1 y^1-1x^2

!!! note "monomial - polynomial"

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

!!! example "result"

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

!!! note "polynomial - polynomial"

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

!!! example "result"

f(x,y)=f(x,y)=

!!! note "polynomial - integer"

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

!!! example "result"

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

!!! note "integer - polynomial"

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

!!! example "result"

f(x,y)=1y2+1+1x1y11x2f(x,y)=-1 y^2+1+1x^1 y^1-1x^2
END PROGRAM main