Mathematical functions

**Examples**

**Usage example**

```
SELECT log10(100);
```

```
2
```

## log1p[​](#log1p "Direct link to log1p")

Introduced in: v20.12.0

Calculates log(1+x).
The calculation log1p(x) is more accurate than log(1+x) for small values of `x`.

**Syntax**

```
log1p(x)
```

**Arguments**

- `x` — Values from the interval: `-1 < x < +∞`. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns values from the interval: -∞ < log1p(x) < +∞ [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT log1p(0)
```

```
0
```

## log2[​](#log2 "Direct link to log2")

Introduced in: v1.1.0

Returns the binary logarithm of the argument.

**Syntax**

```
log2(x)
```

**Arguments**

- `x` — The number for which to compute the binary logarithm of. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns the binary logarithm of `x`. [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT log2(8);
```

```
3
```

## pi[​](#pi "Direct link to pi")

Introduced in: v1.1.0

Returns pi (π).

**Syntax**

```
pi()
```

**Arguments**

- None.

**Returned value**

Returns pi [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT pi();
```

```
3.141592653589793
```

## pow[​](#pow "Direct link to pow")

Introduced in: v1.1.0

Returns x raised to the power of y.

**Syntax**

```
pow(x, y)
```

**Aliases**: `power`

**Arguments**

- `x` — The base. [`(U)Int8/16/32/64`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)
- `y` — The exponent. [`(U)Int8/16/32/64`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns x^y [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT pow(2, 3);
```

```
8
```

## proportionsZTest[​](#proportionsZTest "Direct link to proportionsZTest")

Introduced in: v22.3.0

Returns test statistics for the two proportion Z-test - a statistical test for comparing the proportions from two populations x and y.
The function supports both pooled and unpooled estimation methods for the standard error.
In the pooled version, the two proportions are averaged and only one proportion is used to estimate the standard error.
In the unpooled version, the two proportions are used separately.

**Syntax**

```
proportionsZTest(successes_x, successes_y, trials_x, trials_y, conf_level, pool_type)
```

**Arguments**

- `successes_x` — Number of successes in population x. [`UInt64`](/docs/sql-reference/data-types/int-uint)
- `successes_y` — Number of successes in population y. [`UInt64`](/docs/sql-reference/data-types/int-uint)
- `trials_x` — Number of trials in population x. [`UInt64`](/docs/sql-reference/data-types/int-uint)
- `trials_y` — Number of trials in population y. [`UInt64`](/docs/sql-reference/data-types/int-uint)
- `conf_level` — Confidence level for the test. [`Float64`](/docs/sql-reference/data-types/float)
- `pool_type` — Selection of pooling method for standard error estimation. Can be either 'unpooled' or 'pooled'. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns a tuple containing: `z_stat` (Z statistic), `p_val` (P value), `ci_low` (lower confidence interval), `ci_high` (upper confidence interval). [`Tuple(Float64, Float64, Float64, Float64)`](/docs/sql-reference/data-types/tuple)

**Examples**

**Usage example**

```
SELECT proportionsZTest(10, 11, 100, 101, 0.95, 'unpooled');
```

```
┌─proportionsZTest(10, 11, 100, 101, 0.95, 'unpooled')───────────────────────────────┐
│ (-0.20656724435948853,0.8363478437079654,-0.09345975390115283,0.07563797172293502) │
└────────────────────────────────────────────────────────────────────────────────────┘
```

## radians[​](#radians "Direct link to radians")

Introduced in: v22.2.0

Converts degrees to radians.

**Syntax**

```
radians(x)
```

**Arguments**

- `x` — Input in degrees. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns value in radians [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT radians(180)
```

```
3.141592653589793
```

## sigmoid[​](#sigmoid "Direct link to sigmoid")

Introduced in: v20.1.0

Calculates the sigmoid function: `1 / (1 + exp(-x))`. The sigmoid function maps any real number to the range (0, 1) and is commonly used in machine learning.

**Syntax**

```
sigmoid(x)
```

**Arguments**

- `x` — The input value. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float)

**Returned value**

Returns the sigmoid of the input value, in the range (0, 1). [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Basic usage**

```
SELECT sigmoid(0)
```

```
0.5
```

## sign[​](#sign "Direct link to sign")

Introduced in: v21.2.0

Returns the sign of a real number.

**Syntax**

```
sign(x)
```

**Arguments**

- `x` — Values from -∞ to +∞. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Decimal*`](/docs/sql-reference/data-types/decimal) or [`Float*`](/docs/sql-reference/data-types/float)

**Returned value**

Returns `-1` for `x < 0`, `0` for `x = 0`, `1` for `x > 0`. [`Int8`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Sign for zero**

```
SELECT sign(0)
```

```
0
```

**Sign for positive**

```
SELECT sign(1)
```

```
1
```

**Sign for negative**

```
SELECT sign(-1)
```

```
-1
```

## sin[​](#sin "Direct link to sin")

Introduced in: v1.1.0

Returns the sine of the argument.

**Syntax**

```
sin(x)
```

**Arguments**

- `x` — The number whose sine will be returned. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns the sine of x.

**Examples**

**simple**

```
SELECT sin(1.23)
```

```
0.9424888019316975
```

## sinh[​](#sinh "Direct link to sinh")

Introduced in: v20.12.0

Returns the hyperbolic sine.

**Syntax**

```
sinh(x)
```

**Arguments**

- `x` — The angle, in radians. Values from the interval: -∞ < x < +∞. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns values from the interval: -∞ < sinh(x) < +∞ [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT sinh(0)
```

```
0
```

## sqrt[​](#sqrt "Direct link to sqrt")

Introduced in: v1.1.0

Returns the square root of the argument.

**Syntax**

```
sqrt(x)
```

**Arguments**

- `x` — The number for which to find the square root of. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns the square root of x [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT sqrt(16);
```

```
4
```

## tan[​](#tan "Direct link to tan")

Introduced in: v1.1.0

Returns the tangent of the argument.

**Syntax**

```
tan(x)
```

**Arguments**

- `x` — The angle in radians. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Decimal*`](/docs/sql-reference/data-types/decimal)

**Returned value**

Returns the tangent of `x`. [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT tan(0);
```

```
0
```

## tanh[​](#tanh "Direct link to tanh")

Introduced in: v20.1.0

Returns the hyperbolic tangent.

**Syntax**

```
tanh(x)
```

**Arguments**