# 18.3 Mathematical functions Signal value might require some recalculation or signal update prior to being sent. Understandably, existing columns in Excel configuration like `multiply`, `add`, `bit_select` might not be flexible enough. To overcome these limitations, symbolic mathematical expressions can be configured to do calculations automatically on every update of a signal.
It should be noted that filling mathematical expression disables other mathematical scalar operations for a single value such as `multiply`, `add` or `bit_select`. Other functions (primarily between several signals) are still available such as operation.
### Feature list: - Optimized for speed - High parsing performance - if-then-else operator with lazy evaluation - Default implementation with many features - 25 predefined functions - 18 predefined operators - Unit support - Use postfix operators as unit multipliers (3m -> 0.003) ### Mathematical functions Table. Supported mathematical functions:Name | Argument count | Explanation |
sin | 1 | sine function (rad) |
cos | 1 | cosine function (rad) |
tan | 1 | tangent function (rad) |
asin | 1 | arcus sine function (rad) |
acos | 1 | arcus cosine function (rad) |
atan | 1 | arcus tangens function (rad) |
sinh | 1 | hyperbolic sine function |
cosh | 1 | hyperbolic cosine |
tanh | 1 | hyperbolic tangens function |
asinh | 1 | hyperbolic arcus sine function |
acosh | 1 | hyperbolic arcus tangens function |
atanh | 1 | hyperbolic arcur tangens function |
log2 | 1 | logarithm to the base 2 |
log10 | 1 | logarithm to the base 10 |
log | 1 | logarithm to base e (2.71828...) |
ln | 1 | logarithm to base e (2.71828...) |
exp | 1 | e raised to the power of x |
sqrt | 1 | square root of a value |
sign | 1 | sign function -1 if x<0; 1 if x>0 |
rint | 1 | round to nearest integer |
abs | 1 | absolute value |
min | variable | min of all arguments |
max | variable | max of all arguments |
sum | variable | sum of all arguments |
avg | variable | mean value of all arguments |
floor | 1 | round down to the nearest integer |
It should be noted that trigonometric functions (excluding hiperbolic functions) only support arguments in radians. This means that arguments for this function have to be recalculated if angle is defined in degress.
Value recalculation is only triggered on signal change of the preconfigured signal. That means that using other signals (via TagValue() call) does not trigger value update.
Some mathematical expression cannot be mathematically evaluated in some conditions, for example, square root cannot be found for negative numbers. As complex numbers are not supported, result is then equal to Not a Number (NaN). These results are marked with an invalid (IV) flag.
### Binary operations Table. Supported binary operators:Operator | Description | Priority |
= | assignment | -1 |
» | right shift | 0 |
« | left shift | 0 |
& | bitwise and | 0 |
| | bitwise or | 0 |
&& | logical and | 1 |
|| | logical or | 2 |
<= | less or equal | 4 |
>= | greater or equal | 4 |
!= | not equal | 4 |
== | equal | 4 |
> | greater than | 4 |
< | less than | 4 |
+ | addition | 5 |
- | subtraction | 5 |
\* | multiplication | 6 |
% | modulo | 6 |
/ | division | 6 |
^ | raise x to the power of y | 7 |
Operator | Description | Remarks |
?: | if then else operator | C++ style syntax |
Expression | Description |
value \* 0.0001 | Multiply the tag by a constant. |
value + TagValue(”tag/dev\_alias/sig\_alias/out”) | Add value of tag/dev\_alias/sig\_alias/out to the current tag. |
sin(value) | Return a predefined sine function value of the tag. |
(value>5)? 1: 0 | If the value is greater than 5, the result should be equal to 1, otherwise - equal to 0 |