[comment]: # attributes: notoc

[comment]: # translation:outdated

[comment]: # ({new-ef4bef6c})
# 5 Mathematical functions

All functions listed here are supported in:

-   [Trigger expressions](/manual/config/triggers/expression)
-   [Calculated items](/manual/config/items/itemtypes/calculated)

Mathematical functions are supported with float and integer value types,
unless stated otherwise.

Some general notes on function parameters:

-   Function parameters are separated by a comma
-   Expressions are accepted as parameters
-   Optional function parameters (or parameter parts) are indicated by
    `<` `>`

|FUNCTION|<|<|<|
|--------|-|-|-|
|<|**Description**|**Function-specific parameters**|**Comments**|
|**abs** (value)|<|<|<|
|<|The absolute value of a value.<br><br>This function references **change()** to obtain the absolute value of the change (see example).|**value** - value to check|Supported value types: float, int, str, text, log<br><br>For strings returns:<br>0 - values are equal<br>1 - values differ<br><br>Example:<br>=> **abs**(change(/host/key))>10<br><br>Absolute numeric difference will be calculated, as seen with these incoming example values ('previous' and 'latest' value = absolute difference):<br>'1' and '5' = `4`<br>'3' and '1' = `2`<br>'0' and '-2.5' = `2.5`|
|**acos** (value)|<|<|<|
|<|The arccosine of a value as an angle, expressed in radians.|**value** - value to check|The value must be between -1 and 1.<br><br>For example, the arccosine of a value '0.5' will be '2.0943951'.<br><br>Example:<br>=> **acos**(last(/host/key))|
|**asin** (value)|<|<|<|
|<|The arcsine of a value as an angle, expressed in radians.|**value** - value to check|The value must be between -1 and 1.<br><br>For example, the arcsine of a value '0.5' will be '-0.523598776'.<br><br>Example:<br>=> **asin**(last(/host/key))|
|**atan** (value)|<|<|<|
|<|The arctangent of a value as an angle, expressed in radians.|**value** - value to check|For example, the arctangent of a value '1' will be '0.785398163'.<br><br>Example:<br>=> **atan**(last(/host/key))|
|**atan2** (value,abscissa)|<|<|<|
|<|The arctangent of the ordinate (exprue) and abscissa coordinates specified as an angle, expressed in radians.|**value** - value to check<br>**abscissa** - abscissa value|For example, the arctangent of the ordinate and abscissa coordinates of a value '1' will be '2.21429744'.<br><br>Example:<br>=> **atan2**(last(/host/key),2)|
|**avg** (<value1>,<value2>,...)|<|<|<|
|<|Average value of the referenced item values.|**valueX** - value returned by one of history functions|Example:<br>=> **avg**(avg(/host/key),avg(/host2/key2))|
|**cbrt** (value)|<|<|<|
|<|Cube root of a value.|**value** - value to check|For example, the cube root of '64' will be '4', of '63' will be '3.97905721'.<br><br>Example:<br>=> **cbrt**(last(/host/key))|
|**ceil (value)**|<|<|<|
|<|Round the value up to the nearest greater integer.|**value** - value to check|For example, '2.4' will be rounded up to '3'.<br><br>Example:<br>=> **ceil**(last(/host/key))<br><br>See also floor().|
|**cos (value)**|<|<|<|
|<|The cosine of a value, where the value is an angle expressed in radians.|**value** - value to check|For example, the cosine of a value '1' will be '0.54030230586'.<br><br>Example:<br>=> **cos**(last(/host/key))|
|**cosh (value)**|<|<|<|
|<|The hyperbolic cosine of a value.|**value** - value to check|For example, the hyperbolic cosine of a value '1' will be '1.54308063482'.<br><br>Returns value as a real number, not as scientific notation.<br><br>Example:<br>=> **cosh**(last(/host/key))|
|**cot (value)**|<|<|<|
|<|The cotangent of a value, where the value is an angle, expressed in radians.|**value** - value to check|For example, the cotangent of a value '1' will be '0.54030230586'.<br><br>Example:<br>=> **cot**(last(/host/key))|
|**degrees (value)**|<|<|<|
|<|Converts a value from radians to degrees.|**value** - value to check|For example, a value '1' converted to degrees will be '57.2957795'.<br><br>Example:<br>=> **degrees**(last(/host/key))|
|**e**|<|<|<|
|<|Euler's number (2.718281828459045).|<|Example:<br>=> **e**()|
|**exp** (value)|<|<|<|
|<|Euler's number at a power of a value.|**value** - value to check|For example, Euler's number at a power of a value '2' will be '7.38905609893065'.<br><br>Example:<br>=> **exp**(last(/host/key))|
|**expm1 (value)**|<|<|<|
|<|Euler's number at a power of a value minus 1.|**value** - value to check|For example, Euler's number at a power of a value '2' minus 1 will be '6.38905609893065'.<br><br>Example:<br>=> **expm1**(last(/host/key))|
|**floor** (value)|<|<|<|
|<|Round the value down to the nearest smaller integer.|**value** - value to check|For example, '2.6' will be rounded down to '2'.<br><br>Example:<br>=> **floor**(last(/host/key))<br><br>See also ceil().|
|**log** (value)|<|<|<|
|<|Natural logarithm.|**value** - value to check|For example, the natural logarithm of a value '2' will be '0.69314718055994529'.<br><br>Example:<br>=> **log**(last(/host/key))|
|**log10** (value)|<|<|<|
|<|Decimal logarithm.|**value** - value to check|For example, the decimal logarithm of a value '5' will be '0.69897000433'.<br><br>Example:<br>=> **log10**(last(/host/key))|
|**max** (<value1>,<value2>,...)|<|<|<|
|<|Highest value of the referenced item values.|**valueX** - value returned by one of history functions|Example:<br>=> **max**(avg(/host/key),avg(/host2/key2))|
|**min** (<value1>,<value2>,...)|<|<|<|
|<|Lowest value of the referenced item values.|**valueX** - value returned by one of history functions|Example:<br>=> **min**(avg(/host/key),avg(/host2/key2))|
|**mod** (value,denominator)|<|<|<|
|<|Division remainder.|**value** - value to check<br>**denominator** - division denominator|For example, division remainder of a value '5' with division denominator '2' will be '1'.<br><br>Example:<br>=> **mod**(last(/host/key),2)|
|**pi**|<|<|<|
|<|Pi constant (3.14159265358979).|<|Example:<br>=> **pi**()|
|**power** (value,power value)|<|<|<|
|<|The power of a value.|**value** - value to check<br>**power value** - the Nth power to use|For example, the 3rd power of a value '2' will be '8'.<br><br>Example:<br>=> **power**(last(/host/key),3)|
|**radians** (value)|<|<|<|
|<|Convert a value from degrees to radians.|**value** - value to check|For example, a value '1' converted to radians will be '0.0174532925'.<br><br>Example:<br>=> **radians**(last(/host/key))|
|**rand**|<|<|<|
|<|Return a random integer value.|<|A pseudo-random generated number using time as seed (enough for mathematical purposes, but not cryptography).<br><br>Example:<br>=> **rand**()|
|**round** (value,decimal places)|<|<|<|
|<|Round the value to decimal places.|**value** - value to check<br>**decimal places** - specify decimal places for rounding (0 is also possible)|For example, a value '2.5482' rounded to 2 decimal places will be '2.55'.<br><br>Example:<br>=> **round**(last(/host/key),2)|
|**signum** (value)|<|<|<|
|<|Returns '-1' if a value is negative, '0' if a value is zero, '1' if a value is positive.|**value** - value to check|Example:<br>=> **signum**(last(/host/key))|
|**sin** (value)|<|<|<|
|<|The sine of a value, where the value is an angle expressed in radians.|**value** - value to check|For example, the sine of a value '1' will be '0.8414709848'.<br><br>Example:<br>=> **sin**(last(/host/key))|
|**sinh** (value)|<|<|<|
|<|The hyperbolical sine of a value.|**value** - value to check|For example, the hyperbolical sine of a value '1' will be '1.17520119364'.<br><br>Example:<br>=> **sinh**(last(/host/key))|
|**sqrt** (value)|<|<|<|
|<|Square root of a value.|**value** - value to check|This function will fail with a negative value.<br><br>For example, the square root of a value '3.5' will be '1.87082869339'.<br><br>Example:<br>=> **sqrt**(last(/host/key))|
|**sum** (<value1>,<value2>,...)|<|<|<|
|<|Sum of the referenced item values.|**valueX** - value returned by one of history functions|Example:<br>=> **sum**(avg(/host/key),avg(/host2/key2))|
|**tan** (value)|<|<|<|
|<|The tangent of a value.|**value** - value to check|For example, the tangent of a value '1' will be '1.55740772465'.<br><br>Example:<br>=> **tan**(last(/host/key))|
|**truncate** (value,decimal places)|<|<|<|
|<|Truncate the value to decimal places.|**value** - value to check<br>**decimal places** - specify decimal places for truncating (0 is also possible)|Example:<br>=> **truncate**(last(/host/key),2)|

[comment]: # ({/new-ef4bef6c})

[comment]: # ({new-b94e027b})
### Function details

Some general notes on function parameters:

-   Function parameters are separated by a comma
-   Expressions are accepted as parameters
-   Optional function parameters (or parameter parts) are indicated by
    `<` `>`

[comment]: # ({/new-b94e027b})

[comment]: # ({new-ef1976cf})

##### abs(value) {#abs}

The absolute value of a value.<br>
Supported value types: *Float*, *Integer*, *String*, *Text*, *Log*.<br>
For strings returns: 0 - the values are equal; 1 - the values differ.

Parameter: 

-   **value** - the value to check

The absolute numeric difference will be calculated, as seen with these incoming example values ('previous' and 'latest' value = absolute difference): '1' and '5' = `4`; '3' and '1' = `2`; '0' and '-2.5' = `2.5`

Example:

    abs(last(/host/key))>10

[comment]: # ({/new-ef1976cf})

[comment]: # ({new-799c1d3c})

##### acos(value) {#acos}

The arccosine of a value as an angle, expressed in radians.

Parameter: 

-   **value** - the value to check

The value must be between -1 and 1. For example, the arccosine of a value '0.5' will be '2.0943951'.

Example:

    acos(last(/host/key))

[comment]: # ({/new-799c1d3c})

[comment]: # ({new-96ac62bc})

##### asin(value) {#asin}

The arcsine of a value as an angle, expressed in radians.

Parameter: 

-   **value** - the value to check

The value must be between -1 and 1. For example, the arcsine of a value '0.5' will be '-0.523598776'.

Example:

    asin(last(/host/key)) 

[comment]: # ({/new-96ac62bc})

[comment]: # ({new-1fc197d5})

##### atan(value) {#atan}

The arctangent of a value as an angle, expressed in radians.

Parameter: 

-   **value** - the value to check

The value must be between -1 and 1. For example, the arctangent of a value '1' will be '0.785398163'.

Example:

    atan(last(/host/key))

[comment]: # ({/new-1fc197d5})

[comment]: # ({new-a0956f60})

##### atan2(value,abscissa) {#atan2}

The arctangent of the ordinate (exprue) and abscissa coordinates specified as an angle, expressed in radians.

Parameter: 

-   **value** - the value to check;
-   **abscissa** - the abscissa value.

For example, the arctangent of the ordinate and abscissa coordinates of a value '1' will be '2.21429744'.

Example:

    atan(last(/host/key),2)

[comment]: # ({/new-a0956f60})

[comment]: # ({new-d3ee3e17})

##### avg(<value1>,<value2>,...) {#avg}

The average value of the referenced item values.

Parameter: 

-   **valueX** - the value returned by one of the history functions.

Example:

    avg(avg(/host/key),avg(/host2/key2))

[comment]: # ({/new-d3ee3e17})

[comment]: # ({new-bd8056a7})

##### cbrt(value) {#cbrt}

The cube root of a value.

Parameter: 

-   **value** - the value to check

For example, the cube root of '64' will be '4', of '63' will be '3.97905721'.

Example:

    cbrt(last(/host/key))

[comment]: # ({/new-bd8056a7})

[comment]: # ({new-476b353b})

##### ceil(value) {#ceil}

Round the value up to the nearest greater or equal integer.

Parameter: 

-   **value** - the value to check

For example, '2.4' will be rounded up to '3'. See also [floor()](#floor).

Example:

    ceil(last(/host/key))

[comment]: # ({/new-476b353b})

[comment]: # ({new-5dcd529a})

##### cos(value) {#cos}

The cosine of a value, where the value is an angle expressed in radians.

Parameter: 

-   **value** - the value to check

For example, the cosine of a value '1' will be '0.54030230586'.

Example:

    cos(last(/host/key))

[comment]: # ({/new-5dcd529a})

[comment]: # ({new-0bcb804d})

##### cosh(value) {#cosh}

The hyperbolic cosine of a value.
Returns the value as a real number, not as scientific notation.

Parameter: 

-   **value** - the value to check

For example, the hyperbolic cosine of a value '1' will be '1.54308063482'.

Example:

    cosh(last(/host/key))

[comment]: # ({/new-0bcb804d})

[comment]: # ({new-e77ec290})

##### cot(value) {#cot}

The cotangent of a value, where the value is an angle expressed in radians.

Parameter: 

-   **value** - the value to check

For example, the cotangent of a value '1' will be '0.54030230586'.

Example:

    cot(last(/host/key))

[comment]: # ({/new-e77ec290})

[comment]: # ({new-1d5ff49e})

##### degrees(value) {#degrees}

Converts a value from radians to degrees.

Parameter: 

-   **value** - the value to check

For example, a value '1' converted to degrees will be '57.2957795'.

Example:

    degrees(last(/host/key))

[comment]: # ({/new-1d5ff49e})

[comment]: # ({new-818dfba1})

##### e {#e}

The Euler's number (2.718281828459045).

Example:

    e()

[comment]: # ({/new-818dfba1})

[comment]: # ({new-46e0e80f})

##### exp(value) {#exp}

The Euler's number at a power of a value.

Parameter: 

-   **value** - the value to check

For example, Euler's number at a power of a value '2' will be '7.38905609893065'.

Example:

    exp(last(/host/key))

[comment]: # ({/new-46e0e80f})

[comment]: # ({new-7a699dd2})

##### expm1(value) {#expm1}

The Euler's number at a power of a value minus 1.

Parameter: 

-   **value** - the value to check

For example, Euler's number at a power of a value '2' minus 1 will be '6.38905609893065'.

Example:

    expm1(last(/host/key))

[comment]: # ({/new-7a699dd2})

[comment]: # ({new-0ec4e450})

##### floor(value) {#floor}

Round the value down to the nearest smaller or equal integer.

Parameter: 

-   **value** - the value to check

For example, '2.6' will be rounded down to '2'. See also [ceil()](#ceil).

Example:

    floor(last(/host/key))

[comment]: # ({/new-0ec4e450})

[comment]: # ({new-b0a6f934})

##### log(value) {#log}

The natural logarithm.

Parameter: 

-   **value** - the value to check

For example, the natural logarithm of a value '2' will be '0.69314718055994529'.

Example:

    log(last(/host/key))

[comment]: # ({/new-b0a6f934})

[comment]: # ({new-f5d65956})

##### log10(value) {#log10}

The decimal logarithm.

Parameter: 

-   **value** - the value to check

For example, the decimal logarithm of a value '5' will be '0.69897000433'.

Example:

    log10(last(/host/key))

[comment]: # ({/new-f5d65956})

[comment]: # ({new-05ca2759})

##### max(<value1>,<value2>,...) {#max}

The highest value of the referenced item values.

Parameter: 

-   **valueX** - the value returned by one of the history functions.

Example:

    max(avg(/host/key),avg(/host2/key2))

[comment]: # ({/new-05ca2759})

[comment]: # ({new-21fb2e91})

##### min(<value1>,<value2>,...) {#min}

The lowest value of the referenced item values.

Parameter: 

-   **valueX** - the value returned by one of the history functions.

Example:

    min(avg(/host/key),avg(/host2/key2))

[comment]: # ({/new-21fb2e91})

[comment]: # ({new-cbed4c8c})

##### mod(value,denominator) {#mod}

The division remainder.

Parameter: 

-   **value** - the value to check;
-   **denominator** - the division denominator.

For example, division remainder of a value '5' with division denominator '2' will be '1'.

Example:

    mod(last(/host/key),2)

[comment]: # ({/new-cbed4c8c})

[comment]: # ({new-8460a32c})

##### pi {#pi}

The Pi constant (3.14159265358979).

Example:

    pi()

[comment]: # ({/new-8460a32c})

[comment]: # ({new-d9b2cdad})

##### power(value,power value) {#power}

The power of a value.

Parameter: 

-   **value** - the value to check;
-   **power value** - the Nth power to use.

For example, the 3rd power of a value '2' will be '8'.

Example:

    power(last(/host/key),3)

[comment]: # ({/new-d9b2cdad})

[comment]: # ({new-fc32afde})

##### radians(value) {#radians}

Converts a value from degrees to radians.

Parameter: 

-   **value** - the value to check

For example, a value '1' converted to radians will be '0.0174532925'.

Example:

    radians(last(/host/key))

[comment]: # ({/new-fc32afde})

[comment]: # ({new-6eb2edcd})

##### rand {#rand}

Return a random integer value. A pseudo-random generated number using time as seed (enough for mathematical purposes, but not cryptography).

Example:

    rand()

[comment]: # ({/new-6eb2edcd})

[comment]: # ({new-f724e644})

##### round(value,decimal places) {#round}

Round the value to decimal places.

Parameter: 

-   **value** - the value to check;
-   **decimal places** - specify decimal places for rounding (0 is also possible).

For example, a value '2.5482' rounded to 2 decimal places will be '2.55'.

Example:

    round(last(/host/key),2)

[comment]: # ({/new-f724e644})

[comment]: # ({new-09e5becb})

##### signum(value) {#signum}

Returns '-1' if a value is negative, '0' if a value is zero, '1' if a value is positive.

Parameter: 

-   **value** - the value to check.

For example, a value '2.5482' rounded to 2 decimal places will be '2.55'.

Example:

    signum(last(/host/key))

[comment]: # ({/new-09e5becb})

[comment]: # ({new-79bdc912})

##### sin(value) {#sin}

The sine of a value, where the value is an angle expressed in radians.

Parameter: 

-   **value** - the value to check

For example, the sine of a value '1' will be '0.8414709848'.

Example:

    sin(last(/host/key))

[comment]: # ({/new-79bdc912})

[comment]: # ({new-b7b48127})

##### sinh(value) {#sinh}

The hyperbolical sine of a value, where the value is an angle expressed in radians.

Parameter: 

-   **value** - the value to check

For example, the hyperbolical sine of a value '1' will be '1.17520119364'.

Example:

    sinh(last(/host/key))

[comment]: # ({/new-b7b48127})

[comment]: # ({new-2848f7af})

##### sqrt(value) {#sqrt}

The square root of a value.<br>
This function will fail with a negative value.

Parameter: 

-   **value** - the value to check

For example, the square root of a value '3.5' will be '1.87082869339'.

Example:

    sqrt(last(/host/key))

[comment]: # ({/new-2848f7af})

[comment]: # ({new-8c82ac77})

##### sum(<value1>,<value2>,...) {#sum}

The sum of the referenced item values.

Parameter: 

-   **valueX** - the value returned by one of the history functions.

Example:

    sum(avg(/host/key),avg(/host2/key2))

[comment]: # ({/new-8c82ac77})

[comment]: # ({new-f1010957})

##### tan(value) {#tan}

The tangent of a value.

Parameter: 

-   **value** - the value to check

For example, the tangent of a value '1' will be '1.55740772465'.

Example:

    tan(last(/host/key))

[comment]: # ({/new-f1010957})

[comment]: # ({new-c483c31f})

##### truncate(value,decimal places) {#truncate}

Truncate the value to decimal places.

Parameter: 

-   **value** - the value to check;
-   **decimal places** - specify decimal places for truncating (0 is also possible).

For example, a value '2.5482' truncated to 2 decimal places will be '2.54'.

Example:

    truncate(last(/host/key),2)

[comment]: # ({/new-c483c31f})

[comment]: # ({544a48ff-dbea2171})

[サポートされているすべての関数](/manual/appendix/functions)を参照してください。

[comment]: # ({/544a48ff-dbea2171})
