Mathematical functions

**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**

- `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 < tanh(x) < 1 [`Float*`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT tanh(0)
```

```
0
```

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

Introduced in: v1.1.0

Returns the gamma function.

**Syntax**

```
tgamma(x)
```

**Arguments**

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

**Examples**

**Usage example**

```
SELECT tgamma(5);
```

```
24
```

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

Introduced in: v23.3.0

Returns the number of the bucket in which parameter `operand` falls in a histogram having count equal-width buckets spanning the range `low` to `high`. Returns 0 if `operand` is less than `low`, and returns `count`+1 if `operand` is greater than or equal to `high`.
There is also a case insensitive alias called `WIDTH_BUCKET` to provide compatibility with other databases.

**Syntax**

```
widthBucket(operand, low, high, count)
```

**Aliases**: `width_bucket`

**Arguments**

- `operand` — The value for which to determine the bucket. [`(U)Int8/16/32/64`](/docs/sql-reference/data-types/int-uint)
- `low` — The lower bound of the histogram range. [`(U)Int8/16/32/64`](/docs/sql-reference/data-types/int-uint)
- `high` — The upper bound of the histogram range. [`(U)Int8/16/32/64`](/docs/sql-reference/data-types/int-uint)
- `count` — The number of equal-width buckets. Cannot be zero. [`UInt8/16/32/64`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns the bucket number as an integer. Returns 0 if operand < low, returns count+1 if operand >= high. [`UInt8/16/32/64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
widthBucket(10.15, -8.6, 23, 18)
```

```
11
```

- [acos](#acos)- [acosh](#acosh)- [asin](#asin)- [asinh](#asinh)- [atan](#atan)- [atan2](#atan2)- [atanh](#atanh)- [cbrt](#cbrt)- [cos](#cos)- [cosh](#cosh)- [degrees](#degrees)- [e](#e)- [erf](#erf)- [erfc](#erfc)- [exp](#exp)- [exp10](#exp10)- [exp2](#exp2)- [factorial](#factorial)- [hypot](#hypot)- [intExp10](#intExp10)- [intExp2](#intExp2)- [lgamma](#lgamma)- [log](#log)- [log10](#log10)- [log1p](#log1p)- [log2](#log2)- [pi](#pi)- [pow](#pow)- [proportionsZTest](#proportionsZTest)- [radians](#radians)- [sigmoid](#sigmoid)- [sign](#sign)- [sin](#sin)- [sinh](#sinh)- [sqrt](#sqrt)- [tan](#tan)- [tanh](#tanh)- [tgamma](#tgamma)- [widthBucket](#widthBucket)

Was this page helpful?