Trigonometric functions

PromQL supports the standard trigonometric functions for use in mathematical and scientific queries. All angles are in radians; convert with deg() and rad().

acos

Computes the arccosine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

acos(<expr>)
none

Example

Find the angle whose cosine is 0.5 — the result is 60 degrees.

deg(acos(vector(0.5)))
Expected output
Value

60

acosh

Computes the inverse hyperbolic cosine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

acosh(<expr>)
none

Example

Compute the inverse hyperbolic cosine of 2 — ≈ 1.317.

acosh(vector(2))
Expected output
Value

1.317

asin

Computes the arcsine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

asin(<expr>)
none

Example

Find the angle whose sine is 0.5 — the result is 30 degrees.

deg(asin(vector(0.5)))
Expected output
Value

30

asinh

Computes the inverse hyperbolic sine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

asinh(<expr>)
none

Example

Compute the inverse hyperbolic sine of 1 — ≈ 0.881.

asinh(vector(1))
Expected output
Value

0.8814

atan

Computes the arctangent of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

atan(<expr>)
none

Example

Find the angle whose tangent is 1 — the result is 45 degrees.

deg(atan(vector(1)))
Expected output
Value

45

atanh

Computes the inverse hyperbolic tangent of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

atanh(<expr>)
none

Example

Compute the inverse hyperbolic tangent of 0.5 — ≈ 0.549.

atanh(vector(0.5))
Expected output
Value

0.5493

cos

Computes the cosine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

cos(<expr>)
none

Example

Compute the cosine of 60 degrees — the result is 0.5.

cos(rad(vector(60)))
Expected output
Value

0.5

cosh

Computes the hyperbolic cosine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

cosh(<expr>)
none

Example

Compute the hyperbolic cosine of 1 — ≈ 1.543.

cosh(vector(1))
Expected output
Value

1.543

deg

Converts every sample value of the input vector from radians to degrees, preserving all labels.

Syntax

deg(<expr>)
none

Example

Convert π radians to degrees — the result is 180.

deg(vector(pi()))
Expected output
Value

180

pi

Returns π as a scalar. Wrap it in vector() when a vector result is needed, or use it directly as a scalar argument.

Syntax

pi()
none

Example

Return π as a chartable vector.

vector(pi())
Expected output
Value

3.142

rad

Converts every sample value of the input vector from degrees to radians, preserving all labels.

Syntax

rad(<expr>)
none

Example

Convert 180 degrees to radians — the result is π, ≈ 3.14159.

rad(vector(180))
Expected output
Value

3.142

sin

Computes the sine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

sin(<expr>)
none

Example

Compute the sine of 30 degrees — the result is 0.5.

sin(rad(vector(30)))
Expected output
Value

0.5

sinh

Computes the hyperbolic sine of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

sinh(<expr>)
none

Example

Compute the hyperbolic sine of 1 — ≈ 1.175.

sinh(vector(1))
Expected output
Value

1.175

tan

Computes the tangent of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

tan(<expr>)
none

Example

Compute the tangent of 45 degrees — the result is 1.

tan(rad(vector(45)))
Expected output
Value

1

tanh

Computes the hyperbolic tangent of every sample value of the input vector, preserving all labels. Angles are in radians; convert with rad() and deg().

Syntax

tanh(<expr>)
none

Example

Compute the hyperbolic tangent of 1 — ≈ 0.762.

tanh(vector(1))
Expected output
Value

0.7616