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
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
acosh x -> Float
Computes the inverse hyperbolic cosine.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
asin x -> Float
Computes the inverse sine in radians.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
asinh x -> Float
Computes the inverse hyperbolic sine.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
atan x -> Float
Computes the inverse tangent in radians.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
atan2 y x -> Float
Computes the inverse tangent of y / x, using both signs to select a quadrant.
Parameters
| Name | Type | Description |
|---|---|---|
y |
(Int | Float) |
Vertical coordinate. |
x |
(Int | Float) |
Horizontal coordinate. |
atanh x -> Float
Computes the inverse hyperbolic tangent.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
cbrt x -> Float
Computes the cube root.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
copysign x sign -> Float
Returns the magnitude of x with the sign of sign.
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
cosh x -> Float
Computes the hyperbolic cosine.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
degrees x -> Float
Converts radians to degrees.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
exp x -> Float
Computes e raised to x.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
exp2 x -> Float
Computes two raised to x.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
expm1 x -> Float
Computes e raised to x, minus one, accurately near zero.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
gcd first *rest -> Int
Computes the greatest common divisor of one or more integers.
Parameters
| Name | Type | Description |
|---|---|---|
first |
Int |
First value. |
*rest |
Int |
Additional values. |
hypot first second *rest -> Float
Computes the Euclidean norm of two or more coordinates.
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
first |
Int |
First value. |
*rest |
Int |
Additional values. |
ln x -> Float
Computes the natural logarithm.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
ln1p x -> Float
Computes the natural logarithm of 1 + x accurately near zero.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
log :base x -> Float
Computes the logarithm in a required base.
Parameters
| Name | Type | Description |
|---|---|---|
:base |
(Int | Float) |
Logarithm base. |
x |
(Int | Float) |
Value whose logarithm is computed. |
log10 x -> Float
Computes the base-ten logarithm.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
log2 x -> Float
Computes the base-two logarithm.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
pow base exponent -> (Int | Float)
Raises base to exponent.
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
sin x -> Float
Computes the sine of an angle in radians.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
sinh x -> Float
Computes the hyperbolic sine.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
sqrt x -> Float
Computes the square root.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
tan x -> Float
Computes the tangent of an angle in radians.
Parameters
| Name | Type | Description |
|---|---|---|
x |
(Int | Float) |
tanh x -> Float
Computes the hyperbolic tangent.
Parameters
| Name | Type | Description |
|---|---|---|
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.