Trigonometry#

ACOS

Compute inverse cosine of the input column (in radians).

ACOSD

Compute inverse cosine of the input column (in degrees).

ASIN

Compute inverse sine of the input column (in radians).

ASIND

Compute inverse sine of the input column (in degrees).

ATAN

Compute inverse tangent of the input column (in radians).

ATAND

Compute inverse tangent of the input column (in degrees).

ATAN2

Compute the inverse tangent of column_2/column_1 (in radians).

ATAN2D

Compute the inverse tangent of column_2/column_1 (in degrees).

COT

Compute the cotangent of the input column (in radians).

COTD

Compute cotangent of the input column (in degrees).

COS

Compute the cosine of the input column (in radians).

COSD

Compute the cosine of the input column (in degrees).

DEGREES

Convert between radians and degrees.

RADIANS

Convert between degrees and radians.

SIN

Compute the sine of the input column (in radians).

SIND

Compute the sine of the input column (in degrees).

TAN

Compute the tangent of the input column (in radians).

TAND

Compute the tangent of the input column (in degrees).

ACOS#

Compute inverse cosine of the input column (in radians).

Example:

df = pl.DataFrame({"rads": [-1.0, -0.5, 0.5, 1.0]})
df.sql("SELECT rads, ACOS(rads) AS acos FROM self")
# shape: (4, 2)
# ┌──────┬──────────┐
# │ rads ┆ acos     │
# │ ---  ┆ ---      │
# │ f64  ┆ f64      │
# ╞══════╪══════════╡
# │ -1.0 ┆ 3.141593 │
# │ -0.5 ┆ 2.094395 │
# │ 0.5  ┆ 1.047198 │
# │ 1.0  ┆ 0.0      │
# └──────┴──────────┘

ACOSD#

Compute inverse cosine of the input column (in degrees).

Example:

df = pl.DataFrame({"degs": [-0.5, 0.0, 0.5]})
df.sql("SELECT degs, ACOSD(degs) AS acosd FROM self")
# shape: (3, 2)
# ┌──────┬───────┐
# │ degs ┆ acosd │
# │ ---  ┆ ---   │
# │ f64  ┆ f64   │
# ╞══════╪═══════╡
# │ -0.5 ┆ 120.0 │
# │ 0.0  ┆ 90.0  │
# │ 0.5  ┆ 60.0  │
# └──────┴───────┘

ASIN#

Compute inverse sine of the input column (in radians).

Example:

df = pl.DataFrame({"rads": [-1.0, -0.75, -0.0, 0.5]})
df.sql("SELECT rads, ASIN(rads) AS asin FROM self")
# shape: (4, 2)
# ┌───────┬───────────┐
# │ rads  ┆ asin      │
# │ ---   ┆ ---       │
# │ f64   ┆ f64       │
# ╞═══════╪═══════════╡
# │ -1.0  ┆ -1.570796 │
# │ -0.75 ┆ -0.848062 │
# │ -0.0  ┆ -0.0      │
# │ 0.5   ┆ 0.523599  │
# └───────┴───────────┘

ASIND#

Compute inverse sine of the input column (in degrees).

Example:

df = pl.DataFrame({"degs": [-0.5, 0.0, 0.5]})
df.sql("SELECT degs, ASIND(degs) AS asind FROM self")
# shape: (3, 2)
# ┌──────┬───────┐
# │ degs ┆ asind │
# │ ---  ┆ ---   │
# │ f64  ┆ f64   │
# ╞══════╪═══════╡
# │ -0.5 ┆ -30.0 │
# │ 0.0  ┆ 0.0   │
# │ 0.5  ┆ 30.0  │
# └──────┴───────┘

ATAN#

Compute inverse tangent of the input column (in radians).

Example:

df = pl.DataFrame({"rads": [-1.0, 0.0, 1.0, 2.0]})
df.sql("SELECT rads, ATAN(rads) AS atan FROM self")
# shape: (4, 2)
# ┌──────┬───────────┐
# │ rads ┆ atan      │
# │ ---  ┆ ---       │
# │ f64  ┆ f64       │
# ╞══════╪═══════════╡
# │ -1.0 ┆ -0.785398 │
# │ 0.0  ┆ 0.0       │
# │ 1.0  ┆ 0.785398  │
# │ 2.0  ┆ 1.107149  │
# └──────┴───────────┘

ATAND#

Compute inverse tangent of the input column (in degrees).

Example:

df = pl.DataFrame({"degs": [-1.0, 0.0, 1.0]})
df.sql("SELECT degs, ATAND(degs) AS atand FROM self")
# shape: (3, 2)
# ┌──────┬───────┐
# │ degs ┆ atand │
# │ ---  ┆ ---   │
# │ f64  ┆ f64   │
# ╞══════╪═══════╡
# │ -1.0 ┆ -45.0 │
# │ 0.0  ┆ 0.0   │
# │ 1.0  ┆ 45.0  │
# └──────┴───────┘

ATAN2#

Compute the inverse tangent of column_2/column_1 (in radians).

Example:

df = pl.DataFrame(
    {
        "a": [-2.0, -1.0, 1.0, 2.0],
        "b": [1.5, 1.0, 0.5, 0.0],
    }
)
df.sql("SELECT a, b, ATAN2(a, b) AS atan2_ab FROM self")
# shape: (4, 3)
# ┌──────┬─────┬───────────┐
# │ a    ┆ b   ┆ atan2_ab  │
# │ ---  ┆ --- ┆ ---       │
# │ f64  ┆ f64 ┆ f64       │
# ╞══════╪═════╪═══════════╡
# │ -2.0 ┆ 1.5 ┆ -0.927295 │
# │ -1.0 ┆ 1.0 ┆ -0.785398 │
# │ 1.0  ┆ 0.5 ┆ 1.107149  │
# │ 2.0  ┆ 0.0 ┆ 1.570796  │
# └──────┴─────┴───────────┘

ATAN2D#

Compute the inverse tangent of column_2/column_1 (in degrees).

Example:

df = pl.DataFrame(
    {
        "a": [0, 90, 180, 360],
        "b": [360, 270, 180, 90],
    }
)
df.sql("SELECT a, b, ATAN2D(a, b) AS atan2d_ab FROM self")
# shape: (4, 3)
# ┌─────┬─────┬───────────┐
# │ a   ┆ b   ┆ atan2d_ab │
# │ --- ┆ --- ┆ ---       │
# │ i64 ┆ i64 ┆ f64       │
# ╞═════╪═════╪═══════════╡
# │ 0   ┆ 360 ┆ 0.0       │
# │ 90  ┆ 270 ┆ 18.434949 │
# │ 180 ┆ 180 ┆ 45.0      │
# │ 360 ┆ 90  ┆ 75.963757 │
# └─────┴─────┴───────────┘

COT#

Compute the cotangent of the input column (in radians).

Example:

df = pl.DataFrame({"rads": [-2.0, -1.0, 0.0, 1.0, 2.0]})
df.sql("SELECT rads, COT(rads) AS cot FROM self")
# shape: (5, 2)
# ┌──────┬───────────┐
# │ rads ┆ cot       │
# │ ---  ┆ ---       │
# │ f64  ┆ f64       │
# ╞══════╪═══════════╡
# │ -2.0 ┆ 0.457658  │
# │ -1.0 ┆ -0.642093 │
# │ 0.0  ┆ inf       │
# │ 1.0  ┆ 0.642093  │
# │ 2.0  ┆ -0.457658 │
# └──────┴───────────┘

COTD#

Compute cotangent of the input column (in degrees).

Example:

df = pl.DataFrame({"degs": [0, 90, 180, 270, 360]})
df.sql("SELECT degs, COTD(degs) AS cotd FROM self")
# shape: (5, 2)
# ┌──────┬────────────┐
# │ degs ┆ cotd       │
# │ ---  ┆ ---        │
# │ f64  ┆ f64        │
# ╞══════╪════════════╡
# │ -2.0 ┆ -28.636253 │
# │ -1.0 ┆ -57.289962 │
# │ 0.0  ┆ inf        │
# │ 1.0  ┆ 57.289962  │
# │ 2.0  ┆ 28.636253  │
# └──────┴────────────┘

COS#

Compute the cosine of the input column (in radians).

Example:

df = pl.DataFrame({"rads": [-2.0, -1.0, 0.0, 1.0, 2.0]})
df.sql("SELECT rads, COS(rads) AS cos FROM self")
# shape: (5, 2)
# ┌──────┬───────────┐
# │ rads ┆ cos       │
# │ ---  ┆ ---       │
# │ f64  ┆ f64       │
# ╞══════╪═══════════╡
# │ -2.0 ┆ -0.416147 │
# │ -1.0 ┆ 0.540302  │
# │ 0.0  ┆ 1.0       │
# │ 1.0  ┆ 0.540302  │
# │ 2.0  ┆ -0.416147 │
# └──────┴───────────┘

COSD#

Compute the cosine of the input column (in degrees).

Example:

df = pl.DataFrame({"degs": [0, 45, 180, 225]})
df.sql("SELECT degs, COSD(degs) AS cosd FROM self")
# shape: (4, 2)
# ┌──────┬───────────┐
# │ degs ┆ cosd      │
# │ ---  ┆ ---       │
# │ i64  ┆ f64       │
# ╞══════╪═══════════╡
# │ 0    ┆ 1.0       │
# │ 45   ┆ 0.707107  │
# │ 180  ┆ -1.0      │
# │ 225  ┆ -0.707107 │
# └──────┴───────────┘

DEGREES#

Convert between radians and degrees.

Example:

import math

df = pl.DataFrame({"rads": [0.0, math.pi/2, math.pi, 3*math.pi/2]})
df.sql("SELECT rads, DEGREES(rads) AS degs FROM self")
# shape: (4, 2)
# ┌──────────┬───────┐
# │ rads     ┆ degs  │
# │ ---      ┆ ---   │
# │ f64      ┆ f64   │
# ╞══════════╪═══════╡
# │ 0.0      ┆ 0.0   │
# │ 1.570796 ┆ 90.0  │
# │ 3.141593 ┆ 180.0 │
# │ 4.712389 ┆ 270.0 │
# └──────────┴───────┘

RADIANS#

Convert between degrees and radians.

Example:

df = pl.DataFrame({"degs": [0, 90, 180, 270]})
df.sql("SELECT degs, RADIANS(degs) AS rads FROM self")
# shape: (4, 2)
# ┌──────┬──────────┐
# │ degs ┆ rads     │
# │ ---  ┆ ---      │
# │ i64  ┆ f64      │
# ╞══════╪══════════╡
# │ 0    ┆ 0.0      │
# │ 90   ┆ 1.570796 │
# │ 180  ┆ 3.141593 │
# │ 270  ┆ 4.712389 │
# └──────┴──────────┘

SIN#

Compute the sine of the input column (in radians).

Example:

import math

df = pl.DataFrame({"rads": [0.0, 1/4 * math.pi, 1/2 * math.pi, 3/4 * math.pi]})
df.sql("SELECT rads, SIN(rads) AS sin FROM self")
# shape: (4, 2)
# ┌──────────┬──────────┐
# │ rads     ┆ sin      │
# │ ---      ┆ ---      │
# │ f64      ┆ f64      │
# ╞══════════╪══════════╡
# │ 0.0      ┆ 0.0      │
# │ 0.785398 ┆ 0.707107 │
# │ 1.570796 ┆ 1.0      │
# │ 2.356194 ┆ 0.707107 │
# └──────────┴──────────┘

SIND#

Compute the sine of the input column (in degrees).

Example:

df = pl.DataFrame({"degs": [0, 90, 225, 270]})
df.sql("SELECT degs, SIND(degs) AS sind FROM self")
# shape: (4, 2)
# ┌──────┬───────────┐
# │ degs ┆ sind      │
# │ ---  ┆ ---       │
# │ i64  ┆ f64       │
# ╞══════╪═══════════╡
# │ 0    ┆ 0.0       │
# │ 90   ┆ 1.0       │
# │ 225  ┆ -0.707107 │
# │ 270  ┆ -1.0      │
# └──────┴───────────┘

TAN#

Compute the tangent of the input column (in radians).

Example:

import math

df = pl.DataFrame({"rads": [0.0, 1/4 * math.pi, 3/4 * math.pi]})
df.sql("SELECT rads, TAN(rads) AS tan FROM self")
# shape: (4, 2)
# ┌──────────┬───────────┐
# │ rads     ┆ tan       │
# │ ---      ┆ ---       │
# │ f64      ┆ f64       │
# ╞══════════╪═══════════╡
# │ 0.0      ┆ 0.0       │
# │ 0.785398 ┆ 1.0       │
# │ 1.570796 ┆ 1.6331e16 │
# │ 2.356194 ┆ -1.0      │
# └──────────┴───────────┘

TAND#

Compute the tangent of the input column (in degrees).

Example:

df = pl.DataFrame({"degs": [0, 45, 135, 225]})
df.sql("SELECT degs, TAND(degs) AS tand FROM self")
# shape: (4, 2)
# ┌──────┬──────┐
# │ degs ┆ tand │
# │ ---  ┆ ---  │
# │ i64  ┆ f64  │
# ╞══════╪══════╡
# │ 0    ┆ 0.0  │
# │ 45   ┆ 1.0  │
# │ 135  ┆ -1.0 │
# │ 225  ┆ 1.0  │
# └──────┴──────┘