# Math equation reference

## Supported operators

Addition(+), Sustraction(-), Multiplication(*), Division(/), Modulo(%).

## Constants

You may enter constants or static equations as you would in a calculator. For instance: `

    3 / 4

`

## Sensor data

Values from physical sensors can be called using the following syntax: `[SERIAL:ID]`, where `SERIAL` is the sensor's serial number and `ID` is the channel Id as displayed in the Source ID column.
For instance, to add an offset of `+0.5` to the first channel of sensor `A01234`, one would write: `

    [A01234:00] + 0.5

` Note that values from multiple sensors can be supported: `

    [A01234:00] + 1.3 * [B01234:02]

`

## Calibrated and uncalibrated data

For Dracal products supporting 3-point calibration, the data generated by the syntax [SERIAL:ID] are calibrated if calibration is activated, and uncalibrated if it is not.
In these devices, even when calibration is activated, it is always possible to access the uncalibrated data of calibratable real channels by adding the suffix "_nc" as followed: `[SERIAL:ID_nc]`. For instance, the following formula returns the difference between the calibrated and uncalibrated value of the second channel of sensor `A01234`:
`[A01234:01]-[A01234:01_nc]`

## Advanced use

Equations are parsed using the QTScript javascript engine. Comparison operators (>, < >=, <=) can be used in conjunction with the ternary operator (?), to select between two values: `

    [A01234:01] > 10 ? 1 : 0

` The Javascript Math object is available to provide mathematical functions and constants. For instance:

- Math.max(x, ...) : Returns the highest value in a list of arguments
- Math.min(x, ...) : Returns the lowest value in a list of arguments
- Math.pow(x,y) : Returns the value of x to the power of y
- Math.sqrt(x) : Returns the square root of x
- Math.sin(x) : Returns the sine (a value between -1 and 1) of the angle x (given in radians)
- Math.PI : Returns 3.141592653589793

For instance, to return the highest value in a list of 3 measurements: `

    Math.max([A01234:00], [A01234:01], [B01234:02])

`

## Units management

Set the unit (°C, K, %, ppm, ...) of a MATH channel by clicking on the Edit box (pencil icon) next to its equation.
Note: The MATH channel units are not affected by the sensor unit changes done in the Configuration tab.
Tip: When changing the units of the sensors direct output, keep in mind that this change will affect the value of every MATH channel using a sensor impacted channel.