Syntax to define a mathematical function

Syntax to define a mathematical function#

In a mathematical function, used for example in field definition, it’s possible to use the predifined function (an object parser is used to evaluate the functions) :

ABS

absolute value function

COS

cosine function

SIN

sine function

TAN

tangent function

ATAN

arctangent function

EXP

exponential function

LN

natural logarithm function

SQRT

square root function

INT

integer function

ERF

error function

RND(x)

random function (values between 0 and x)

COSH

hyperbolic cosine function

SINH

hyperbolic sine function

TANH

hyperbolic tangent function

ACOS

inverse cosine function

ASIN

inverse sine function

ATANH

inverse hyperbolic tangent function

NOT(x)

NOT x (returns 1 if x is false, 0 otherwise)

SGN(x)

SGN x (returns 1 if x is positive, -1 if negative, 0 if zero)

x_AND_y

boolean logical operation AND (returns 1 if both x and y are true, else 0)

x_OR_y

boolean logical operation OR (returns 1 if x or y is true, else 0)

x_GT_y

greater than (returns 1 if \(x>y\), else 0)

x_GE_y

greater than or equal to

x_LT_y

less than (returns 1 if x<y, else 0)

x_LE_y

less than or equal to

x_MIN_y

returns the smallest of x and y

x_MAX_y

returns the largest of x and y

x_MOD_y

modular division of x per y

x_EQ_y

equal to (returns 1 if x==y, else 0)

x_NEQ_y

not equal to (returns 1 if x!=y, else 0)

You can also use the following operations:

+

addition

-

subtraction

/

division

*

multiplication

%

modulo

$

max

^

power

<

less than

>

greater than

[

less than or equal to

]

greater than or equal to

You can also use the following constants:

Pi

pi value (3,1415…)

The variables which can be used are:

x,y,z

coordinates

t

time

Examples:#

Champ_front_fonc_txyz 2 cos(y+x^2) t+ln(y)

Champ_fonc_xyz dom 2 tanh(4*y)*(0.95+0.1*rnd(1)) 0.

Possible errors:#

Error 1:#

Champ_fonc_txyz 1 cos(10*t)*(1<x<2)*(1<y<2)

Previous line is wrong. It should be written as:

Champ_fonc_txyz 1 cos(10*t)*(1<x)*(x<2)*(1<y)*(y<2)

Error 2:#

Champ_front_fonc_xyz 1 20*(x<-2)+10*(y]-5)+3*(z>0)

Previous line is wrong because negative values are not written between parentheses. It should be written as:

Champ_front_fonc_xyz 1 20*(x<(-2))+10*(y](-5))+3*(z>0)