# Math reference

> All 13 math in AlgoBarsX, each with its parameters, defaults, ranges and an example: abs, min, max, round, floor, ceil, sqrt, log, exp, pow and 3 more.

Source: https://algobarsx.com/docs/ref-fn-math/

### `abs(value)` → like value

Absolute value.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |

```algobarsx
body_size = abs(close - open)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `min(a, b)` → like a

Smaller of two values.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `a` | number | required | First value. |
| `b` | number | required | Second value. |

```algobarsx
body_low = min(open, close)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `max(a, b)` → like a

Larger of two values.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `a` | number | required | First value. |
| `b` | number | required | Second value. |

```algobarsx
body_high = max(open, close)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `round(value, decimals = 0)` → like value

Round to a number of decimals.

#### Parameters

| Name | Type | Default | Range | What it is |
| --- | --- | --- | --- | --- |
| `value` | number | required |  | Value. |
| `decimals` | int | `0` | 0 to 12 | Decimal places. |

```algobarsx
shown = round(close, 2)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `floor(value)` → like value

Round down.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |

```algobarsx
whole = floor(close)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `ceil(value)` → like value

Round up.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |

```algobarsx
whole_up = ceil(close)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `sqrt(value)` → number

Square root, deterministic across devices.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |

```algobarsx
root = sqrt(252)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `log(value)` → number

Natural logarithm, deterministic across devices.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |

```algobarsx
log_price = log(close)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `exp(value)` → number

Exponential, deterministic across devices.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |

```algobarsx
growth = exp(0.05)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `pow(base, exponent)` → number

Power, deterministic across devices.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `base` | number | required | Base. |
| `exponent` | number | required | Exponent. |

```algobarsx
squared = pow(close, 2)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `clamp(value, low, high)` → like value

Limit a value to a range.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |
| `low` | number | required | Lowest allowed. |
| `high` | number | required | Highest allowed. |

```algobarsx
bounded = clamp(rsi(close, 14), 20, 80)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `sign(value)` → number

-1, 0 or 1.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `value` | number | required | Value. |

```algobarsx
side_sign = sign(close - open)
```

Works in: strategy, indicator, alert, library. Since 1.0.

### `lerp(a, b, t)` → like a

Linear interpolation between two values.

#### Parameters

| Name | Type | Default | What it is |
| --- | --- | --- | --- |
| `a` | number | required | Start. |
| `b` | number | required | End. |
| `t` | number | required | Fraction from 0 to 1. |

```algobarsx
halfway = lerp(low, high, 0.5)
```

Works in: strategy, indicator, alert, library. Since 1.0.
