> ## Documentation Index
> Fetch the complete documentation index at: https://docs.truemath.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Arithmetic and powers

> Core arithmetic, percent change, modulo, powers and roots, and logarithmic and exponential functions.

These cover core arithmetic, percent change, modulo, powers, roots, logarithms, and exponential functions. Every operation works on a number or a [table](/math/types/tables), returning the same shape it was given. For operator precedence and the comparison and logical operators, see [Operators and precedence](/math/functions/operators-and-precedence).

## Core arithmetic

```
value1 + value2     # add
value1 - value2     # subtract
value1 * value2     # multiply
value1 / value2     # divide
```

Each operation accepts two numbers, a number and a table, or two tables — producing a new table when a table is involved. Two tables must be the **same length**, or an `Invalid dimensions` error is returned. Dividing by `0` returns a `Division by 0` error; `1 / value` returns the reciprocal of `value`.

```
3 + 4                   => 7
[3; 4; 5] + 3           => [6; 7; 8]
[6; 9; 12] + [3; 4; 5]  => [9; 13; 17]

3 - 4                   => -1
[6; 9; 12] - [3; 4; 5]  => [3; 5; 7]

3 * 4                   => 12
[3; 4; 5] * 3           => [9; 12; 15]

3 / 4                   => 0.75
[6; 9; 12] / [3; 4; 5]  => [2; 2.25; 2.4]
```

## Percent change \[ch]

```
ch(value; change)
ch(value; change; periods)
```

Returns `value` adjusted by a percentage `change` (entered as a decimal): a positive `change` adds, a negative `change` subtracts. This is the financial calculator equivalent of `value + change%` or `value - change%`, which a spreadsheet would write as `value ± (value * change%)`. With `periods`, it compounds the change over that many periods (compound annual growth rate). `value` can be a number or a table.

```
ch(100; 0.25)      => 125
ch(100; -0.25)     => 75
ch(100; 0.25; 3)   => 195.3125
```

## Modulo \[mod]

```
mod(value1; value2)
```

The remainder of `value1` divided by `value2`. A `value2` of `0` returns a `Division by 0` error. Either argument can be a number or a table; if both are tables they must be the same length, or `Invalid dimensions` is returned. If `value1` or `value2` is too large to calculate then returns 'Parameter out of range' error.

```
mod(3; 2)              => 1
mod(2; 3)              => 2
mod(3; 3)              => 0
mod([3;4;5]; 2)        => [1; 0; 1]
mod([3;7;9]; [2;4;5])  => [1; 3; 4]
```

## Powers and roots

### Power \[^]

```
value ^ x
```

Raises `value` to the `x` power. `value` can either be a number or table where the same is returned. Several forms are common:

* `value ^ 2`, `value ^ 3` — squared, cubed.
* `value ^ -1` — the reciprocal of `value` (see also division).
* `value ^ (1/2)` — the square root, the same as `sqrt(value)`.
* `value ^ (1/x)` — the `x`th root, the same as `root(value; x)`.

```
4^2          => 16
-2^2         => -4
9^(1/2)      => 3
4^-1         => 0.25
[3; 4; 5]^2  => [9; 16; 25]
```

### Square root \[sqrt]

```
sqrt(value)
```

The square root of `value`. `value` can either be a number or table where the same is returned.

```
sqrt(16)            => 4
sqrt([9; 16; 25])   => [3; 4; 5]
```

### Root \[root]

```
root(value; x)
```

The `x`th root of `value`. `root(value; 2)` is the same as `sqrt(value)`. `value` can either be a number or table where the same is returned.

```
root(16; 2)          => 4
root([9; 16; 25]; 2) => [3; 4; 5]
```

## Logarithms and exponentials

### Natural logarithm \[ln]

```
ln(value)
```

The natural logarithm (base *e*) of `value`. `value` can either be a number or table where the same is returned.

```
ln(10)            => 2.3026
ln([2; 3; 4])     => [0.6931; 1.099; 1.3863]
```

### Exponential \[exp]

```
exp(value)
```

The constant *e* (2.718281828459045) raised to `value`. `value` can either be a number or table where the same is returned. There is no `e` constant; write `exp(1)` when you need *e* itself.

```
exp(10)              => 22026.4658
exp([0.5; 0.75; 2])  => [1.6487; 2.117; 7.3891]
```

### Logarithm \[log]

```
log(value)
log(value; base)
```

The logarithm of `value` in base 10, or in `base`. `value` can either be a number or table where the same is returned. `base` must be a whole number ≥ 2; real numbers are truncated, and values outside the range return a `Parameter out of range` error.

```
log(15)              => 1.1761
log(15; 3)           => 2.4650
log([10; 12; 14]; 4) => [1.661; 1.7925; 1.9037]
```

### Antilogarithm \[alog]

```
alog(value)
```

The inverse (base 10) logarithm of `value`. `value` can either be a number or table where the same is returned.

```
alog(1.25)             => 17.7828
alog([0.8; 1.2; 1.4])  => [6.3096; 15.8489; 25.1189]
```
