3.6.1. Mathematical Functions

Mathematical functions supported from the C/C++ Math library are as shown in the table below.

Figure 3.108: Supported mathematical functions

FunctionsDescription
ABS(E1)DefinitionUse to compute the absolute value of E1.
Input (E1)Real
Return ValueReal ≥ 0
ExampleABS(-1.5) = 1.5
ACOS(E1)DefinitionUse to compute the arc-cosine of E1.
Input (E1)-1 ≤ Real ≤ 1. If the input value is greater than 1 or less than -1, it will be limited 1 or -1, respectively.
Return Value0 ≤ Real < PI in Radians
ExampleACOS(0.5) = PI/3
AINT(E1)DefinitionUse to truncate E1 to the whole number.
Input (E1)Real
Return ValueInteger. If the magnitude of E1 is less than 1, then AINT(E1) returns 0. If the magnitude is equal to or greater than 1, then it returns the largest whole number that does not exceed its magnitude. The sign is the same as the sign of E1.
ExampleAINT(-1.5678) = -1, AINT(0.17) = 0
ANINT(E1)DefinitionUse to round E1 to the nearest whole number.
Input (E1)Real
Return ValueInteger. If E1 is greater than 0, then ANINT(X) returns AINT(E1+0.5). If E1 is less than or equal to 0, then return AINT(E1-0.5).
ExampleANINT(0.4) = 0, ANINT(-1.9) = -2
ASIN(E1)DefinitionUse to compute the arcsine of E1.
Input (E1)-1 ≤ Real ≤ 1. If the input value is greater than 1 or less than -1, it will be limited 1 or -1, respectively.
Return Value-PI/2 ≤ Real ≤ PI/2 in Radians.
ExampleASIN(0.5) = PI/6
ATAN(E1)DefinitionUse to compute the arctangent of E1.
Input (E1)Real
Return Value-PI/2 ≤ Real ≤ PI/2 in Radians.
ExampleATAN(1.0) = PI/4
ATAN2(E1,E2)DefinitionUse to compute the arctangent of E2/E1.
Input (E1,E2)Real
Return Value

-PI < Real ≤ PI in Radians. The return value can be computed under several conditions as follows.

1) E1 > 0 → ATAN(E2/E1)

2) E1 < 0 & E2 ≥ 0 → ATAN(E2/E1) + PI

3) E1 < 0 & E2 ≤ 0 → ATAN(E2/E1) - PI

4) E1 = 0 & E2 > 0 → PI/2

5) E1 = 0 & E2 < 0 → -PI/2

6) E1 = 0 & E2 = 0 → 0

ExampleATAN2(1.0,-1.0) = 3*PI/4, ATAN2(-1.0,1.0) = -PI/4
CEIL(E1)DefinitionUse to return the least integer greater than or equal to E1.
Input (E1)Real
Return ValueInteger
ExampleCEIL(0.4) = 1, CEIL(-0.9) = 0
COS(E1)DefinitionUse to compute the cosine of E1.
Input (E1)Real (Radians)
Return ValueReal
ExampleCOS(PI/3) = 0.5
COSH(E1)DefinitionUse to compute the hyperbolic cosine of E1.
Input (E1)Real (Radians)
Return ValueReal
ExampleCOSH(PI/18) = 1.01526957
DIM(E1,E2)DefinitionUse to compute the difference E1-E2 if the result is positive. Otherwise returns zero.
Input (E1,E2)Real
Return ValueReal ≥ 0
ExampleDIM(2,1) = 1, DIM(1,2) = 0
EXP(E1)DefinitionUse to compute the base e exponential of E1.
Input (E1)Real
Return ValueReal
ExampleEXP(1.0) = e (Euler's number)
FLOOR(E1)DefinitionUse to return the greatest integer less than or equal to E1.
Input (E1)Real
Return ValueInteger
ExampleFLOOR(0.4) = 0, FLOOR(-0.9) = -1
INT(E1)DefinitionUse to truncate x to the whole number.
Input (E1)Real
Return ValueInteger. If the magnitude of x is less than 1, then INT(E1) returns 0. If the magnitude is equal to or greater than 1, then it returns the largest whole number that does not exceed its magnitude. The sign is the same as the sign of x.
Example 
LOG(E1)DefinitionUse to compute the natural (base e) logarithm of E1.
Input (E1)Real > 0
Return ValueReal
ExampleLOG(2.7182818) = 1.0
LOG10(E1)DefinitionUse to compute the base 10 logarithm of E1.
Input (E1)Real > 0
Return ValueReal
ExampleLOG(100.0) = 2.0
MAX(E1,E2)DefinitionUse to return the maximum value of E1 and E2.
Input (E1,E2)Real
Return ValueReal
ExampleMAX(1,2) = 2
MIN(E1,E2)DefinitionUse to return the minimum value of E1 and E2.
Input (E1,E2)Real
Return ValueReal
ExampleMIN(1,2) = 1
MOD(E1,E2)DefinitionUse to computes the remainder of the division of E1 by E2.
Input (E1,E2)Real. E2 must be not equal to zero.
Return Value

Real. The return value can be calculated as follows.

E1 - INT(E1/E2) * E2.

ExampleMOD(9,4) = 1
POW(E1,E2)DefinitionUse to computes E1 raised to the power of E2.
Input (E1,E2)Real. E1 must be not equal to zero.
Return Value

Real. The return value can be computed under several conditions as follows.

1) E1 > 0 → E1^E2

2) E1 = 0 & E2 > 0 → 0

3) E1 = 0 & E2 = 0 → 1

4) E1 = 0 & E2 < 0 → 0

5) E1 < 0 & E2 is an integer number. → E1^E2

6) E1 < 0 & E2 has a finite decimal. → 0

For 4) case and 6) cases, the return value is not calculated but actually Motion solver returns zero value.

ExamplePOW(2,4) = 16
RAND(E1,E2)DefinitionUse to returns a pseudo-random number from a uniform distribution between E1 and E2.
Input (E1,E2)Real. E2 must be greater than E1.
Return ValueReal
ExampleRAND(6,9) = 6, 7, 8 or 9
SIGN(E1,E2)DefinitionUse to return the value of E1 with the sign of E2.
Input (E1,E2)Real
Return ValueReal
ExampleSIGN(7,-1) = -7, SIGN(-7,-1) = -7, SIGN(-7,1) = 7
SIN(E1)DefinitionUse to compute the sine of E1.
Input (E1)Real (Radians)
Return ValueReal
ExampleSIN(PI/6) = 0.5
SINH(E1)DefinitionUse to compute the hyperbolic sine of E1.
Input (E1)Real (Radians)
Return ValueReal
ExampleSINH(PI/18) = 0.17542037
SQRT(E1)DefinitionUse to compute the square root of E1.
Input (E1)Real ≥ 0
Return ValueReal ≥ 0
ExampleSQRT(4) = 2
TAN(E1)DefinitionUse to compute the tangent of E1.
Input (E1)Real in Radians. E1 must be not equal to (2N-1)*PI/2.
Return ValueReal
ExampleTAN(PI/4) = 1.0
TANH(E1)DefinitionUse to compute the hyperbolic tangent of E1.
Input (E1)Real (Radians)
Return ValueReal
ExampleTANH(PI/18) = 0.172782