Breadcrumbs

Piecewise linear function / function expression

Symbol

image-20221202-084004.png

Usage & working

Both function expressions calculate a defined mathematical function.

  • In the piecewise function you can define a function based on points on the graph

  • the function expressions allow you to define a specific function to calculate

Syntax function expression

The function expression evaluates the input variable “x” using the single line function expression. The syntax is similar to the syntax of the programmeable controller , with the additional constraint that the expression must be one line.

The following syntax can be used:

  • operators :

    • increment operators (++ and --)

    • unary operators (- and !) 

    • binary operators : power (^), multiply (*), modulo (%), divide (/), sum (+), min (-)

    • ternary operator (a = x ? b : x)  see https://www.freecodecamp.org/news/c-ternary-operator/

      • Example: Switch command

        • If Switch = 1 : Output= a , else output = b

          Output = (Switch ==1) ? a: b;
          
    • conditional operators (|| and &&)

    • comparison (<=', >=, >, <, <=, ==, '!=)

    • mathematical functions : exp, ln, sin, cos, tan, sqrt, min(x1, x2), max(x1, x2), abs, floor, ceil, sgn (signum)