# Math channels

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

Operator | Type | Description |
---|---|---|

+ | Arithmetic | Plus |

- | Arithmetic | Subtract |

* | Arithmetic | Multiply |

/ | Arithmetic | Divide |

% | Arithmetic | Remainder |

^ | Arithmetic | Exponent |

< | Comparison | Less than |

<= | Comparison | Less than or equal |

> | Comparison | Greater than |

>= | Comparison | Greater than or equal |

== | Comparison | Equal |

!= | Comparison | Not equal |

&& | Logical | And |

|| | Logical | Or |

! | Logical | Not |

## Functions

### Absolute value

### Derivative

### 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})`

Parameter | Description | Examples |
---|---|---|

condition | Expression 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-true | Value 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-false | It'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)`

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})`

Parameter | Description | Example |
---|---|---|

data | ||

lap-reset | Boolean (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)`

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)`