Standard Mathematical Functions
Mathematical functions consist of the function name and one or two arguments. An argument can be any number or variable name. A mathematical function applies the function, which it represents, to the argument(s).
In the example above:
If the argument(s) are complex numbers (for example in an AC simulation), the functions RAD, DEG, DEGEL, INT, REM, and LOOKUP consider only the real part.
When entering these functions, do not leave spaces between the function arguments and the open parenthesis mark. For example: SIN(x) not SIN (x).
For backward compatibility, the functions ARCSIN, ARCCOS, ARCTAN, SQU, LOOKUP, INTEG, ROOT(x), RAD, DEG, and MOD(x) are still recognized in pure SML text.
The following tables list the standard mathematical functions included in Twin Builder:
When defining arguments for trigonometric functions, you must consider poles to avoid potential errors during a simulation.
|
Notation |
Description |
Example |
|
SIN(x) |
Sine, x[rad] |
SIN(PI/6)=0.5 |
|
COS(x) |
Cosine, x[rad] |
COS(2•PI/3)=-0.5 |
|
TAN(x) |
Tangent, x[rad] |
TAN(PI/4)=1 |
|
ASIN(x) |
Arc sine [rad] |
ASIN(0.5)=0.524=PI/6 |
|
ACOS(x) |
Arc cosine [rad] |
ACOS(0.5)=1.0471=PI/3 |
|
ATAN(x) |
Arc tangent [rad] |
ATAN(1)=0.785=PI/4 |
|
ATAN2(x,y) ATAN2=ATAN(y/x) |
Arc tangent2 [rad] r=0 if x=0 and y=0; -p £ r £ p |
ATAN2(.25,1)= |
|
SINH(x) |
Hyperbolic sine |
SINH(1)=1.175201 |
|
COSH(x) |
Hyperbolic cosine |
COSH(1)=1.54308 |
|
TANH(x) |
Hyperbolic tangent |
TANH(1)=0.761594 |
|
ASINH |
Hyperbolic Arcsine |
ASINH(1.175201)=1 |
|
ACOSH |
Hyperbolic Arccosine |
ACOSH(1.54308)=1 |
|
ATANH |
Hyperbolic Arctangent |
ATANH(0.761594)=1 |
|
Notation |
Description |
Example |
|
SQR(x) |
Square. |
SQR(16)=16²=256 |
|
SQRT(x) |
Square root. |
SQRT(9)=²Ö9=3 |
|
ROOT(x,y) |
n-th Root. |
ROOT(27,3)=³Ö27=3 |
|
SDT(x,y) |
Integration of a variable from the function call until to the simulation end. y=integration method NOTE: Usable in property values (during simulation) but not in postprocessing. |
SDT(var1)=òvar1 dt Integration methods: |
|
DDT(x) |
Derivative of a variable in time NOTE: Usable in property values (during simulation) but not in postprocessing. |
DDT(var1)=dvar1/dt |
|
MAX(x1,x2) |
Returns the greater of two values |
MAX(1,5)=5 |
|
MIN(x1,x2) |
Returns the lesser of two values |
MIN(1,5)=1 |
|
MOD(x,y) |
Modulus. |
MOD(370,60)=10 |
|
LOOKUP(x,y) x=Characteristic name y=X value |
Access function to a characteristic. |
LOOKUP(XY1.VAL,5)= |
|
NOZ(x,y) |
Not zero. Ensures that the minimum absolute value of x is restricted to the absolute value specified by y. Default for y if not specified is 1e-12. This function is useful in avoiding divide-by-zero conditions introduced either by normal expressions or the partial derivative of these expressions. For example: 1/(VM1.V) would better be written as 1/(noz(VM1.V)) to avoid division by zero when VM1.V is zero. sqrt(x.V) would
be better written as sqrt(noz(x.V))
if a partial derivative of the expression is to be considered because
the partial derivative of sqrt(x.V)
with respect to x.V is NOTE: Usable in property values (during simulation) but not in postprocessing. |
noz(x, 1e-13) = x if abs(x) > 1e-13 = 1e-13 if abs(x) < 1e-13 = -1e-13 if abs(x) < 1e-13 If y is negative, then the absolute value of y is used. noz(x, -1e-13) = x = 1e-13 if abs(x) < 1e-13 and x is >=0 = -1e-13 if abs(x) < 1e-13 and x is <0 |
|
Notation |
Description |
Example |
|
EXP(x) |
Exponential function. |
EXP(5)=e5=148.41 |
|
LN(x) |
LN(3)=loge3=1.099 |
|
|
LOG(x,y) |
Common logarithm. |
LOG(7,4)=log47=1.403 |
Complex Functions
|
Notation |
Description |
Example |
|
ABS(x) |
Absolute value. |
ABS(-8.5)=|-8.5|=8.5 |
|
RE(z) |
Real part |
RE(z)=5 |
|
IM(z) |
Imaginary part |
IM(z)=3 |
|
ARG(z) |
Returns a phase value (argument) from AC analysis results, which are complex values, in degrees. For example, given: z=a+bi=r(cosj+i•sinj)=r•eij z=5+3i=5.83(cos30.96°+i•sin30.96°) |
ARG(z)=30.96° |
|
MAG(z) |
Magnitude of a complex number. |
MAG(Z)=5 |
|
Notation |
Description |
Example |
|
ANG_RAD(z) |
Returns a phase value from AC analysis results in radians. |
ANG_RAD(5+3i)=0.5404 |
|
ANG_DEG(z) |
Returns a phase value from AC analysis results, which are complex values, in degrees. |
ANG_DEG(5+3i)=30.96° |
|
DEGEL(x[,y]); y=1 |
Conversion from electrical angle (in radians) to seconds with respect to Hz. |
DEGEL(PI,50)=0.010 |
The special conversion functions gel50, gel16, gel, mod360, mod60 have been replaced in Simplorer7 and later by generic functions degel(x,y) and mod(x,y).
|
Notation |
Description |
Example |
|
SGN(x) |
Sign dependent value (-1, 0, 1). r=0 if z=0, 1 if Re(z)>0 or (Re(z)=0 and Im(z)>0), -1 otherwise. |
SGN(3)=1; SIGN(0)=0; |
|
INT(x) |
Integer part of a value. |
INT(2.5)=2 |
|
REM(x) |
Returns the fractional part of a decimal number such that rem(x) = x-int(x) Syntax: rem(x) |
REM(2.5)=0.5 |
Conditional Functions
|
Notation |
Description |
Example |
|
IF (condition1) [ ELSE IF (condition2) ELSE |
IF-ELSE returns equations (which are valid for FML and FML_INIT components). If-Else function to perform operations dependent on conditions. The ELSE IF and ELSE statements can be omitted. |
IF (t>=1) [ ELSE IF (t>=2) ELSE |
|
IF (condition, True-expression, False-expression)
|
The implicit IF statement is an expression and can only be used on the right side of an equation or in value expressions. |
|