> For the complete documentation index, see [llms.txt](https://docs.e6data.com/ingestion-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.e6data.com/ingestion-engine/sql/functions/math.md).

# Math

*The e6 Ingestion Engine scalar functions are based on* [*Apache DataFusion*](https://arrow.apache.org/datafusion/) *and these docs are derived from the DataFusion function reference.*

| Function           | Description             | Example             | Result       |
| ------------------ | ----------------------- | ------------------- | ------------ |
| `abs(x)`           | Absolute value          | `abs(-5)`           | `5`          |
| `ceil(x)`          | Ceiling                 | `ceil(4.2)`         | `5`          |
| `floor(x)`         | Floor                   | `floor(4.8)`        | `4`          |
| `round(x [, d])`   | Round to d places       | `round(3.14159, 2)` | `3.14`       |
| `trunc(x [, d])`   | Truncate to d places    | `trunc(3.14159, 2)` | `3.14`       |
| `power(base, exp)` | Exponentiation          | `power(2, 3)`       | `8`          |
| `sqrt(x)`          | Square root             | `sqrt(16)`          | `4.0`        |
| `cbrt(x)`          | Cube root               | `cbrt(27)`          | `3.0`        |
| `exp(x)`           | e^x                     | `exp(1)`            | `2.718...`   |
| `ln(x)`            | Natural logarithm       | `ln(2.718...)`      | `1.0`        |
| `log(base, x)`     | Logarithm               | `log(10, 100)`      | `2.0`        |
| `log10(x)`         | Base-10 log             | `log10(100)`        | `2.0`        |
| `log2(x)`          | Base-2 log              | `log2(8)`           | `3.0`        |
| `pi()`             | Pi constant             | `pi()`              | `3.14159...` |
| `signum(x)`        | Sign of number          | `signum(-5)`        | `-1`         |
| `factorial(n)`     | Factorial               | `factorial(5)`      | `120`        |
| `gcd(a, b)`        | Greatest common divisor | `gcd(12, 8)`        | `4`          |
| `lcm(a, b)`        | Least common multiple   | `lcm(4, 6)`         | `12`         |
| `sin(x)`           | Sine                    | `sin(pi() / 2)`     | `1.0`        |
| `cos(x)`           | Cosine                  | `cos(0)`            | `1.0`        |
| `tan(x)`           | Tangent                 | `tan(pi() / 4)`     | `1.0`        |
| `asin(x)`          | Arc sine                | `asin(1)`           | `1.5707...`  |
| `acos(x)`          | Arc cosine              | `acos(1)`           | `0.0`        |
| `atan(x)`          | Arc tangent             | `atan(1)`           | `0.7853...`  |
| `degrees(x)`       | Radians to degrees      | `degrees(pi())`     | `180.0`      |
| `radians(x)`       | Degrees to radians      | `radians(180)`      | `3.14159...` |

## `abs`

Returns the absolute value of a number.

```
abs(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `acos`

Returns the arc cosine or inverse cosine of a number.

```
acos(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `acosh`

Returns the area hyperbolic cosine or inverse hyperbolic cosine of a number.

```
acosh(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `asin`

Returns the arc sine or inverse sine of a number.

```
asin(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `asinh`

Returns the area hyperbolic sine or inverse hyperbolic sine of a number.

```
asinh(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `atan`

Returns the arc tangent or inverse tangent of a number.

```
atan(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `atanh`

Returns the area hyperbolic tangent or inverse hyperbolic tangent of a number.

```
atanh(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `atan2`

Returns the arc tangent or inverse tangent of `expression_y / expression_x`.

```
atan2(expression_y, expression_x)
```

**Arguments**

* **expression\_y**: First numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
* **expression\_x**: Second numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `cbrt`

Returns the cube root of a number.

```
cbrt(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `ceil`

Returns the nearest integer greater than or equal to a number.

```
ceil(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `cos`

Returns the cosine of a number.

```
cos(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `cosh`

Returns the hyperbolic cosine of a number.

```
cosh(numeric_expression)
```

## `degrees`

Converts radians to degrees.

```
degrees(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `exp`

Returns the base-e exponential of a number.

```
exp(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to use as the exponent. Can be a constant, column, or function, and any combination of arithmetic operators.

## `factorial`

Factorial. Returns 1 if value is less than 2.

```
factorial(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `floor`

Returns the nearest integer less than or equal to a number.

```
floor(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `gcd`

Returns the greatest common divisor of `expression_x` and `expression_y`. Returns 0 if both inputs are zero.

```
gcd(expression_x, expression_y)
```

**Arguments**

* **expression\_x**: First numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
* **expression\_y**: Second numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `isnan`

Returns true if a given number is +NaN or -NaN otherwise returns false.

```
isnan(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `iszero`

Returns true if a given number is +0.0 or -0.0 otherwise returns false.

```
iszero(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `lcm`

Returns the least common multiple of `expression_x` and `expression_y`. Returns 0 if either input is zero.

```
lcm(expression_x, expression_y)
```

**Arguments**

* **expression\_x**: First numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
* **expression\_y**: Second numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `ln`

Returns the natural logarithm of a number.

```
ln(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `log`

Returns the base-x logarithm of a number. Can either provide a specified base, or if omitted then takes the base-10 of a number.

```
log(base, numeric_expression)
log(numeric_expression)
```

**Arguments**

* **base**: Base numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `log10`

Returns the base-10 logarithm of a number.

```
log10(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `log2`

Returns the base-2 logarithm of a number.

```
log2(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `nanvl`

Returns the first argument if it's not *NaN*. Returns the second argument otherwise.

```
nanvl(expression_x, expression_y)
```

**Arguments**

* **expression\_x**: Numeric expression to return if it's not *NaN*. Can be a constant, column, or function, and any combination of arithmetic operators.
* **expression\_y**: Numeric expression to return if the first expression is *NaN*. Can be a constant, column, or function, and any combination of arithmetic operators.

## `pi`

Returns an approximate value of pi.

```
pi()
```

## `power`

Returns a base expression raised to the power of an exponent.

```
power(base, exponent)
```

**Arguments**

* **base**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
* **exponent**: Exponent numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

**Aliases**

* pow

## `pow`

*Alias of* [*power*](#power)*.*

## `radians`

Converts degrees to radians.

```
radians(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `random`

Returns a random float value in the range \[0, 1). The random seed is unique to each row.

```
random()
```

## `round`

Rounds a number to the nearest integer.

```
round(numeric_expression[, decimal_places])
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
* **decimal\_places**: Optional. The number of decimal places to round to. Defaults to 0.

## `signum`

Returns the sign of a number. Negative numbers return `-1`. Zero and positive numbers return `1`.

```
signum(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `sin`

Returns the sine of a number.

```
sin(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `sinh`

Returns the hyperbolic sine of a number.

```
sinh(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `sqrt`

Returns the square root of a number.

```
sqrt(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `tan`

Returns the tangent of a number.

```
tan(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `tanh`

Returns the hyperbolic tangent of a number.

```
tanh(numeric_expression)
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.

## `trunc`

Truncates a number to a whole number or truncated to the specified decimal places.

```
trunc(numeric_expression[, decimal_places])
```

**Arguments**

* **numeric\_expression**: Numeric expression to operate on. Can be a constant, column, or function, and any combination of arithmetic operators.
* **decimal\_places**: Optional. The number of decimal places to truncate to. Defaults to 0 (truncate to a whole number). If `decimal_places` is a positive integer, truncates digits to the right of the decimal point. If `decimal_places` is a negative integer, replaces digits to the left of the decimal point with `0`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.e6data.com/ingestion-engine/sql/functions/math.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
