floor_ceiling

<< Click to Display Table of Contents >>

Navigation:  Sample Problems > Usage > Functions >

floor_ceiling

Previous pageReturn to chapter overviewNext page

{ FLOOR_CEILING.PDE

 This script demonstrates the FLOOR and CEILING functions.

 This are provided as alternatives to the MIN and MAX functions that have continuous derivatives.

}

 

TITLE "FLOOR and CEILING Functions"

 

{ No variables, no equations }

 

DEFINITIONS

    ! floor

    fmax = max(x, 0)

    floor1 = floor(x, 0, 0.1)

    floor2 = floor(x, 0, 0.2)

 

    ! ceiling

    cmin = min(x, 0)

    ceil1 = ceiling(x, 0, 0.1)

    ceil2 = ceiling(x, 0, 0.2)

 

{ We need a plot domain even if no system variables : }

 

BOUNDARIES

  region 1

    start(-1,-0.1) line to (1,-0.1) to (1,0.1) to (-1,0.1) to close

PLOTS

    elevation(fmax, floor1, floor2) from(-0.5, 0) to (0.5, 0) as "Floor compared to Max"

    elevation(dx(fmax), dx(floor1), dx(floor2)) from(-0.5, 0) to (0.5, 0) as "dx(Floor) compared to dx(Max)"

   

    elevation(cmin, ceil1, ceil2) from(-0.5, 0) to (0.5, 0) as "Ceiling compared to Min"

    elevation(dx(cmin), dx(ceil1), dx(ceil2)) from(-0.5, 0) to (0.5,0) as "dx(Ceiling) compared to dx(Min)"

   

 

END