Mathematical functions

[Edit this page](https://github.com/ClickHouse/ClickHouse/tree/master/docs/en/sql-reference/functions/math-functions.md)

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

Introduced in: v1.1.0

Returns the arc cosine of the argument.

**Syntax**

```
acos(x)
```

**Arguments**

- `x` — The value for which to find arc cosine 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 arc cosine of x [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT acos(0.5);
```

```
1.0471975511965979
```

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

Introduced in: v20.12.0

Returns the inverse hyperbolic cosine.

**Syntax**

```
acosh(x)
```

**Arguments**

- `x` — Hyperbolic cosine of angle. 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 the angle, in radians. Values from the interval: `0 ≤ acosh(x) < +∞`. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT acosh(1)
```

```
0
```

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

Introduced in: v1.1.0

Calculates the arcsine of the provided argument.
For arguments in the range `[-1, 1]` it returns the value in the range of `[-pi() / 2, pi() / 2]`.

**Syntax**

```
asin(x)
```

**Arguments**

- `x` — Argument for which to calculate arcsine 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 arcsine value of the provided argument `x` [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**inverse**

```
SELECT asin(1.0) = pi() / 2, sin(asin(1)), asin(sin(1))
```

```
1 1 1
```

**float32**

```
SELECT toTypeName(asin(1.0::Float32))
```

```
Float64
```

**nan**

```
SELECT asin(1.1), asin(-2), asin(inf), asin(nan)
```

```
nan nan nan nan
```

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

Introduced in: v20.12.0

Returns the inverse hyperbolic sine.

**Syntax**

```
asinh(x)
```

**Arguments**

- `x` — Hyperbolic sine of angle. 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 the angle, in radians. Values from the interval: `-∞ < asinh(x) < +∞`. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Basic usage**

```
SELECT asinh(0)
```

```
0
```

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

Introduced in: v1.1.0

Returns the arc tangent of the argument.

**Syntax**

```
atan(x)
```

**Arguments**

- `x` — The value for which to find arc tangent 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 arc tangent of `x`. [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT atan(1);
```

```
0.7853981633974483
```

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

Introduced in: v20.12.0

Returns the atan2 as the angle in the Euclidean plane, given in radians, between the positive x axis and the ray to the point `(x, y) ≠ (0, 0)`.

**Syntax**

```
atan2(y, x)
```

**Arguments**

- `y` — y-coordinate of the point through which the ray passes. [`(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)
- `x` — x-coordinate of the point through which the ray passes. [`(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 angle `θ` such that `-π < θ ≤ π`, in radians [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT atan2(1, 1)
```

```
0.7853981633974483
```

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

Introduced in: v20.12.0

Returns the inverse hyperbolic tangent.

**Syntax**

```
atanh(x)
```

**Arguments**

- `x` — Hyperbolic tangent of angle. Values from the interval: -1 < x < 1. `(U)Int*`, `Float*` or `Decimal*`. [`(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 angle, in radians. Values from the interval: -∞ < atanh(x) < +∞ [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT atanh(0)
```

```
0
```

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

Introduced in: v1.1.0

Returns the cubic root of the argument.

**Syntax**

```
cbrt(x)
```

**Arguments**

- `x` — The value for which to find the cubic 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 cubic root of `x`. [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT cbrt(8);
```

```
2
```

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

Introduced in: v1.1.0

Returns the cosine of the argument.

**Syntax**

```
cos(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 cosine of `x`. [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT cos(0);
```

```
1
```

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

Introduced in: v20.12.0

Returns the hyperbolic cosine of the argument.

**Syntax**

```
cosh(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: `1 ≤ cosh(x) < +∞` [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Basic usage**

```
SELECT cosh(0)
```

```
1
```

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

Introduced in: v22.2.0

Converts radians to degrees.

**Syntax**

```
degrees(x)
```

**Arguments**

- `x` — Input 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 value of `x` in degrees. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Basic usage**

```
SELECT degrees(3.141592653589793)
```

```
180
```

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

Introduced in: v1.1.0

Returns Euler's constant (e).

**Syntax**

```
e()
```

**Arguments**

- None.

**Returned value**

Returns Euler's constant [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT e();
```

```
2.718281828459045
```

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

Introduced in: v1.1.0

If `x` is non-negative, then `erf(x/(σ√2))` is the probability that a random variable having a normal distribution with standard deviation `σ` takes the value that is separated from the expected value by more than `x`.

**Syntax**

```
erf(x)
```

**Arguments**

- `x` — The value for which to compute the error function value. [`(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 error function value [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Three sigma rule**

```
SELECT erf(3 / sqrt(2))
```

```
┌─erf(divide(3, sqrt(2)))─┐
│      0.9973002039367398 │
└─────────────────────────┘
```