Math
Mathematical functions: trigonometry, rounding, exponentials, logarithms, and utilities.
abs
Absolute value.
abs(x) → Absolute value of x
acos
Inverse cosine (arc cosine).
acos(x) → Angle in radians
asin
Inverse sine (arc sine).
asin(x) → Angle in radians
atan
Inverse tangent (arc tangent).
atan(x) → Angle in radians
atan2
Two-argument arc tangent.
atan2(y, x) → Angle in radians from the positive x-axis to (x, y)
cbrt
Cube root, handling negative inputs correctly.
cbrt(x) → r
ceil
Round up to nearest integer.
ceil(x) → Smallest integer >= x
clamp
Clamp a value to the interval [lo, hi].
clamp(x, lo, hi) → r
cos
Cosine (radians).
cos(x) → Cosine of x
cosh
Hyperbolic cosine.
cosh(x) → Hyperbolic cosine of x
deg2rad
Convert degrees to radians.
deg2rad(x) → r
divrem
Quotient and remainder.
divrem(a, b) → Tuple (quotient, remainder)
exp
Exponential function e^x.
exp(x) → e raised to the power x
floor
Round down to nearest integer.
floor(x) → Largest integer <= x
hypot
Compute the hypotenuse length sqrt(x^2 + y^2) without overflow.
hypot(x, y) → r
isapprox
Test whether two values are approximately equal (within 1e-10).
isapprox(a, b) → r
lerp
Linear interpolation between a and b.
lerp(a, b, t) → r
log
Natural logarithm (base e).
log(x) → Natural log of x
log10
Base-10 logarithm.
log10(x) → Log base 10 of x
log2
Base-2 logarithm.
log2(x) → Log base 2 of x
logb
Logarithm with arbitrary base.
logb(b, x) → r
rad2deg
Convert radians to degrees.
rad2deg(x) → r
round
Round to nearest integer.
round(x) → Nearest integer to x
sign
Sign of a value (-1, 0, or 1).
sign(x) → -1 if x < 0, 0 if x == 0, 1 if x > 0
sin
Sine (radians).
sin(x) → Sine of x
sinh
Hyperbolic sine.
sinh(x) → Hyperbolic sine of x
sqrt
Square root.
sqrt(x) → Square root of x
tan
Tangent (radians).
tan(x) → Tangent of x
tanh
Hyperbolic tangent.
tanh(x) → Hyperbolic tangent of x
trunc
Truncate toward zero.
trunc(x) → Integer part of x (toward zero)