# Math Functions

Defines mathematical operators to transform or combine time series.

- Math Functions
- :abs (Absolute Value)
- :add (Addition)
- :clamp-max (Clamp Maximum)
- :clamp-min (Clamp Minimum)
- :const (Constant)
- :derivative (Derivative/Rate)
- :div (Divide)
- :integral (Integral / Total Sum)
- :median (Median)
- :mul (Multiply)
- :neg (Negative)
- :per-step (Per Step)
- :sqrt (Square Root)
- :stddev (Standard Deviation)
- :sub (Subtract)

## :abs (Absolute Value)

Compute a new time series where each interval has the absolute value of the input time series.

## :add (Addition)

Compute a new time series where each interval has the value (a + b) where a and b are the corresponding intervals in the input time series.

## :clamp-max (Clamp Maximum)

Restricts the maximum value of the output time series to the specified value. Values from the input time series that are less than or equal to the maximum will not be changed.

A common use-case is to ensure huge spikes in the time series do not force the graph to rescale to the spike, making the rest of the data relatively flat in comparison.

## :clamp-min (Clamp Minimum)

Restricts the minimum value of the output time series to the specified value. Values from the input time series that are greater than or equal to the minimum will not be changed. A common use-case is to allow for auto-scaled axis up to a specified bound.

## :const (Constant)

Generates a line where each datapoint is a constant value.

```
42,:const
```

## :derivative (Derivative/Rate)

Computes the rate of change per step of the input time series. This is useful for metrics collected as gauges where you want to see the rate of change instead of the actual values of the time series.

```
name,sys.cpu_pct,:eq,:derivative
```

## :div (Divide)

Compute a new time series where each interval has the value (a / b) where a and b are the corresponding intervals in the input time series. If a and b are 0, then 0 will be returned for the interval. If only b is 0, then NaN will be returned as the value for the interval.

## :integral (Integral / Total Sum)

Cumulatively sums the values over the query time range. For example if a counter increases by 5.0 every step period, each step in the time series will increase by 5, i.e. 5, 10, 15, 20, 25…

```
name,requestsPerSecond,:eq,:sum,:per-step,:integral
```

## :median (Median)

Compute the median of the time series expression

## :mul (Multiply)

Compute a new time series where each interval has the value (a * b) where a and b are the corresponding intervals in the input time series.

## :neg (Negative)

Compute a new time series where each interval has the negated value of the input time series.

Essentially this function will convert all positive values into their negative equivalent.

## :per-step (Per Step)

Converts a line from a rate per second to a rate based on the step size of the graph. This is useful for getting an estimate of the raw number of events for a given interval.

By default Counters are normalised to rates per second in Outlyer, so this function is useful to see the actual number of events for each step period if needed.

## :sqrt (Square Root)

Compute a new time series where each interval has the square root of the value from the input time series.

## :stddev (Standard Deviation)

Compute the standard deviation for the results of a group by.

```
name,sys.cpu_pct,:eq,(,instance.hostname,),:by,:stddev
```

## :sub (Subtract)

Compute a new time series where each interval has the value (a - b) where a and b are the corresponding intervals in the input time series.