Skip to content

math

Floating-point mathematics and integer number theory.

Except where noted, functions accept only Int and Float (or their subclasses) — not arbitrary types.

Functions

acos x -> Float

Computes the inverse cosine in radians.

Parameters

NameTypeDescription
x (Int | Float)

acosh x -> Float

Computes the inverse hyperbolic cosine.

Parameters

NameTypeDescription
x (Int | Float)

asin x -> Float

Computes the inverse sine in radians.

Parameters

NameTypeDescription
x (Int | Float)

asinh x -> Float

Computes the inverse hyperbolic sine.

Parameters

NameTypeDescription
x (Int | Float)

atan x -> Float

Computes the inverse tangent in radians.

Parameters

NameTypeDescription
x (Int | Float)

atan2 y x -> Float

Computes the inverse tangent of y / x, using both signs to select a quadrant.

Parameters

NameTypeDescription
y (Int | Float) Vertical coordinate.
x (Int | Float) Horizontal coordinate.

atanh x -> Float

Computes the inverse hyperbolic tangent.

Parameters

NameTypeDescription
x (Int | Float)

cbrt x -> Float

Computes the cube root.

Parameters

NameTypeDescription
x (Int | Float)

copysign x sign -> Float

Returns the magnitude of x with the sign of sign.

Parameters

NameTypeDescription
x (Int | Float) Value providing the magnitude.
sign (Int | Float) Value providing the sign.

cos x -> Float

Computes the cosine of an angle in radians.

Parameters

NameTypeDescription
x (Int | Float)

cosh x -> Float

Computes the hyperbolic cosine.

Parameters

NameTypeDescription
x (Int | Float)

degrees x -> Float

Converts radians to degrees.

Parameters

NameTypeDescription
x (Int | Float)

exp x -> Float

Computes e raised to x.

Parameters

NameTypeDescription
x (Int | Float)

exp2 x -> Float

Computes two raised to x.

Parameters

NameTypeDescription
x (Int | Float)

expm1 x -> Float

Computes e raised to x, minus one, accurately near zero.

Parameters

NameTypeDescription
x (Int | Float)

gcd first *rest -> Int

Computes the greatest common divisor of one or more integers.

Parameters

NameTypeDescription
first Int First value.
*rest Int Additional values.

hypot first second *rest -> Float

Computes the Euclidean norm of two or more coordinates.

Parameters

NameTypeDescription
first (Int | Float) First coordinate.
second (Int | Float) Second coordinate.
*rest (Int | Float) Additional coordinates.

lcm first *rest -> Int

Computes the least common multiple of one or more integers.

Parameters

NameTypeDescription
first Int First value.
*rest Int Additional values.

ln x -> Float

Computes the natural logarithm.

Parameters

NameTypeDescription
x (Int | Float)

ln1p x -> Float

Computes the natural logarithm of 1 + x accurately near zero.

Parameters

NameTypeDescription
x (Int | Float)

log :base x -> Float

Computes the logarithm in a required base.

Parameters

NameTypeDescription
:base (Int | Float) Logarithm base.
x (Int | Float) Value whose logarithm is computed.

log10 x -> Float

Computes the base-ten logarithm.

Parameters

NameTypeDescription
x (Int | Float)

log2 x -> Float

Computes the base-two logarithm.

Parameters

NameTypeDescription
x (Int | Float)

pow base exponent -> (Int | Float)

Raises base to exponent.

Parameters

NameTypeDescription
base (Int | Float) Base value.
exponent (Int | Float) Exponent value.

Returns

An Int when both arguments are integers and exponent is non-negative; otherwise a Float.

Errors

OverflowError if an integer result does not fit in Int.

radians x -> Float

Converts degrees to radians.

Parameters

NameTypeDescription
x (Int | Float)

sin x -> Float

Computes the sine of an angle in radians.

Parameters

NameTypeDescription
x (Int | Float)

sinh x -> Float

Computes the hyperbolic sine.

Parameters

NameTypeDescription
x (Int | Float)

sqrt x -> Float

Computes the square root.

Parameters

NameTypeDescription
x (Int | Float)

tan x -> Float

Computes the tangent of an angle in radians.

Parameters

NameTypeDescription
x (Int | Float)

tanh x -> Float

Computes the hyperbolic tangent.

Parameters

NameTypeDescription
x (Int | Float)

Values

E

The base of the natural logarithm.

PI

The ratio of a circle's circumference to its diameter.

TAU

One full turn in radians.