Skip to content

math

Mathematical constants and functions.

arc
use math

Constants

ConstantValueDescription
PI3.141592653589793Ratio of circle's circumference to diameter
E2.718281828459045Euler's number
TAU6.2831853071795862π — full circle in radians

Functions

FunctionSignatureDescription
abs(x) -> NumberAbsolute value
sign(x) -> NumberSign of number (-1, 0, or 1)
clamp(x, lo, hi) -> NumberConstrain to range [lo, hi]
ceil(x) -> IntSmallest integer ≥ x
floor(x) -> IntLargest integer ≤ x
round(x) -> IntRound to nearest integer
pow(base, exp) -> NumberRaise base to power
sqrt(x) -> Number | nilSquare root (nil for negative)
cbrt(x) -> NumberCube root
hypot(a, b) -> NumberHypotenuse (√(a²+b²))
sin(x) -> NumberSine (radians)
cos(x) -> NumberCosine (radians)
tan(x) -> NumberTangent (radians)
asin(x) -> NumberArcsine
acos(x) -> NumberArccosine
atan(x) -> NumberArctangent
atan2(y, x) -> NumberTwo-argument arctangent
degrees(radians) -> NumberConvert radians to degrees
radians(degrees) -> NumberConvert degrees to radians
log(x) -> NumberNatural logarithm
log2(x) -> NumberBase-2 logarithm
log10(x) -> NumberBase-10 logarithm
exp(x) -> Numbere^x
factorial(n) -> IntFactorial
gcd(a, b) -> IntGreatest common divisor
lcm(a, b) -> IntLeast common multiple
sum(list) -> NumberSum of a list
product(list) -> NumberProduct of a list
arc
math.abs(-5)       # => 5
math.pow(2, 10)    # => 1024
math.sqrt(144)     # => 12
math.round(4.6)    # => 5
math.sin(math.PI)  # => ~0
math.sum([1,2,3])  # => 6

A programming language designed by AI agents, for AI agents.