Mathematical Functions and Operators¶
This page documents mathematical operators and functions available in Polars SQL.
Mathematical Operators¶
Operator |
Description |
|---|---|
|
Addition |
|
Subtraction |
|
Multiplication |
|
Division. Integer division performs truncation. Division by zero returns |
|
Modulus (remainder). Division by zero returns |
Mathematical Functions¶
- abs(x) -> [same as input]()¶
Returns the absolute value of
x.
- ceil(x) -> [same integer type for integer input, double otherwise]()¶
Returns
xrounded up to the nearest integer.
- ceiling(x) -> double()¶
Returns
xrounded up to the nearest integer.
- degrees(x) -> double()¶
Converts angle
xin radians to degrees.
- exp(x) -> double()¶
Returns Euler’s number raised to the power of
x.
- floor(x) -> [same integer type for integer input, double otherwise]()¶
Returns
xrounded down to the nearest integer.
- ln(x) -> double()¶
Returns the natural logarithm of
x.
- log10(x) -> double()¶
Returns the base 10 logarithm of
x.
- log(x) -> double()¶
Equivalent to
log10().
- log(x, base) -> double()
Returns the logarithm of
xusing the suppliedbase.
- mod(n, m) -> [common numeric type]()¶
Returns the modulus (remainder) of
ndivided bym. Division by zero returnsNULL.
- power(x, p) -> double()¶
Returns
xraised to the power ofp.
- radians(x) -> double()¶
Converts angle
xin degrees to radians.
- round(x) -> double()¶
Returns
xrounded to the nearest integer.
- round(x, d) -> double()¶
Returns
xrounded toddecimal places.dmust be an integer and can be negative.
- sqrt(x) -> double()¶
Returns the square root of
x.
- fact(x) -> bigint()¶
Returns the factorial of
xafter casting it to an integer. Values outside the supported integer factorial range returnNULL.
Trigonometric Functions¶
All trigonometric function arguments are expressed in radians. See unit
conversion functions degrees() and radians().
- acos(x) -> double()¶
Returns the arc cosine of
x.
- asin(x) -> double()¶
Returns the arc sine of
x.
- atan(x) -> double()¶
Returns the arc tangent of
x.
- atan2(y, x) -> double()¶
Returns the arc tangent of
y / x.
- cos(x) -> double()¶
Returns the cosine of
x.
- sin(x) -> double()¶
Returns the sine of
x.
- tan(x) -> double()¶
Returns the tangent of
x.