Skip to main content

Monomial1D example 4

This example shows the usage of EvalGradient and Grad operator for [[Monomial1D_]] class.

Modules and classes

  • [[Monomial1D_]]

Usage

PROGRAM main
use easifemBase
use easifemClasses
implicit none
type(Monomial1D_) :: y0, y1, y2, y3, ans

Initiate the object.

y=1y=1

  y0=Monomial1D( degree=0_I4B, varname="x" )
CALL Display( y0%evalgradient( x=1.0_DFP ), "f(1)=" )
>result
f(1)=0.00000

y=xy=x

  y1=Monomial1D( degree=1_I4B, varname="x" )
CALL Display( y1%EvalGradient(1.0_DFP), "f(1)=" )
>result
f(1)=1.00000

y=x2y=x^{2}

  y2=Monomial1D( degree=2_I4B, varname="x" )
CALL Display( y2%EvalGradient(1.0_DFP), "f(1)=" )
>result
f(1)=2.00000

We can also get the gradient of the monomial

  ans = y2%Grad()
CALL ans%display("grad of y2 f(x) = ")
>result
grad of y2 f(x) =x^1
END PROGRAM main