Math channels allow you to calculate values based on measured data. For example you can calculate travelled distance from speed channel by using integral function.

## Operators

OperatorTypeDescription
+ArithmeticPlus
-ArithmeticSubtract
*ArithmeticMultiply
/ArithmeticDivide
%ArithmeticRemainder
^ArithmeticExponent
<ComparisonLess than
<=ComparisonLess than or equal
>ComparisonGreater than
>=ComparisonGreater than or equal
==ComparisonEqual
!=ComparisonNot equal
&&LogicalAnd
||LogicalOr
!LogicalNot

## Functions

### If condition

Function evaluates given condition if the result is true or false. Depending on the calculation results, function outputs the defined result.

``if({condition}, {value-if-true}, {value-if-false})``
JS
ParameterDescriptionExamples
conditionExpression to evaluate if given condition is true or false. Expression can include aritmethic calculations or various operators to evaluate values against  In the expression any operators.([RPM] + 1000) > 10000
[RPM] > 10000 && [RPM] < 20000

value-if-trueValue or function to execute in case result from condition is true. It's possible to use channel as output, calculate new value or use static values
value-if-falseIt's possible to use channel as output, calculate new value or use static values

This example shows a simple example how to make condition and use manipulate the output with multiplication. If function is used to separate throttle values from throttle/brake channel.

``if([throttle-and-brake] > 0,[throttle-and-brake] * 10, 0)``
JS

Condition is evaluating if channel value is above 0 and everytime this condition is true, then Throttle and brake channel value multiplied with 10 is used. If condition is false, then value is always 0.

Coming soon

### Integral

Function calculates the cumulative sum of channel/statement values. Function also give the possibility to reset calculation after lap changes.

``integral( {data}, {lap-reset})``
JS
ParameterDescriptionExample
data

lap-resetBoolean (true/false) option to enable integral value reset when lap changes. Use value 1 to enable lap reset and 0 to disable lap reset.

Example shows how to calculate distance over one data file from speed channels by using integrate function.

``integral( [speed-all], 0)``
JS

Example shows how to calculate cumulative sum of steering input over one lap. Difference here is that second parameter is set to 1, so calculation is reset after each lap. This calculation can be used to indicate possible balance change over one run.

``integral( [steering], 1)``
JS