2020-04-03 13:23:32 +00:00
---
toc_priority: 44
toc_title: Mathematical
---
2020-04-30 18:19:18 +00:00
# Mathematical Functions {#mathematical-functions}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
All the functions return a Float64 number. The accuracy of the result is close to the maximum precision possible, but the result might not coincide with the machine representable number nearest to the corresponding real number.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## e() {#e}
2017-12-28 15:13:23 +00:00
2018-09-04 11:18:59 +00:00
Returns a Float64 number that is close to the number e.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## pi() {#pi}
2017-12-28 15:13:23 +00:00
2018-09-04 11:18:59 +00:00
Returns a Float64 number that is close to the number π.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## exp(x) {#expx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
Accepts a numeric argument and returns a Float64 number close to the exponent of the argument.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## log(x), ln(x) {#logx-lnx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
Accepts a numeric argument and returns a Float64 number close to the natural logarithm of the argument.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## exp2(x) {#exp2x}
2017-12-28 15:13:23 +00:00
2018-09-04 11:18:59 +00:00
Accepts a numeric argument and returns a Float64 number close to 2 to the power of x.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## log2(x) {#log2x}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
Accepts a numeric argument and returns a Float64 number close to the binary logarithm of the argument.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## exp10(x) {#exp10x}
2017-12-28 15:13:23 +00:00
2018-09-04 11:18:59 +00:00
Accepts a numeric argument and returns a Float64 number close to 10 to the power of x.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## log10(x) {#log10x}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
Accepts a numeric argument and returns a Float64 number close to the decimal logarithm of the argument.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## sqrt(x) {#sqrtx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
Accepts a numeric argument and returns a Float64 number close to the square root of the argument.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## cbrt(x) {#cbrtx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
Accepts a numeric argument and returns a Float64 number close to the cubic root of the argument.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## erf(x) {#erfx}
2017-04-03 19:49:50 +00:00
2020-05-08 08:04:09 +00:00
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’ .
2017-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +00:00
Example (three sigma rule):
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
``` sql
2017-12-28 15:13:23 +00:00
SELECT erf(3 / sqrt(2))
```
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
``` text
2017-12-28 15:13:23 +00:00
┌─erf(divide(3, sqrt(2)))─┐
│ 0.9973002039367398 │
└─────────────────────────┘
```
2017-06-13 04:15:47 +00:00
2020-03-20 10:10:48 +00:00
## erfc(x) {#erfcx}
2017-06-13 04:15:47 +00:00
2020-03-20 10:10:48 +00:00
Accepts a numeric argument and returns a Float64 number close to 1 - erf(x), but without loss of precision for large ‘ x’ values.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## lgamma(x) {#lgammax}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
The logarithm of the gamma function.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## tgamma(x) {#tgammax}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
Gamma function.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## sin(x) {#sinx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
The sine.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## cos(x) {#cosx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
The cosine.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## tan(x) {#tanx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
The tangent.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## asin(x) {#asinx}
2017-12-28 15:13:23 +00:00
The arc sine.
2020-03-20 10:10:48 +00:00
## acos(x) {#acosx}
2017-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +00:00
The arc cosine.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## atan(x) {#atanx}
2017-12-28 15:13:23 +00:00
2017-04-26 19:16:38 +00:00
The arc tangent.
2017-04-03 19:49:50 +00:00
2020-03-20 10:10:48 +00:00
## pow(x, y), power(x, y) {#powx-y-powerx-y}
2017-12-28 15:13:23 +00:00
2018-09-04 11:18:59 +00:00
Takes two numeric arguments x and y. Returns a Float64 number close to x to the power of y.
2018-10-16 10:47:17 +00:00
2020-03-20 10:10:48 +00:00
## intExp2 {#intexp2}
2019-01-30 10:39:46 +00:00
Accepts a numeric argument and returns a UInt64 number close to 2 to the power of x.
2020-03-20 10:10:48 +00:00
## intExp10 {#intexp10}
2019-01-30 10:39:46 +00:00
Accepts a numeric argument and returns a UInt64 number close to 10 to the power of x.
2020-01-30 10:34:55 +00:00
[Original article ](https://clickhouse.tech/docs/en/query_language/functions/math_functions/ ) <!--hide-->