math Module
The math module provides basic mathematical operations.
Functions
Abs(number)
Returns the absolute value of a number.
Parameters:
number: An integer or a float.
Returns:
(number, error): The absolute value of the number, or an error if the argument is not a number.
Example:
| Abs Example | |
|---|---|
Ceil(x)
Returns the least integer value greater than or equal to x.
Parameters:
x: A number (int or float).
Returns:
(number, error): The ceiling ofxas a float, or an error.
Example:
| Ceil Example | |
|---|---|
Floor(x)
Returns the greatest integer value less than or equal to x.
Parameters:
x: A number (int or float).
Returns:
(number, error): The floor ofxas a float, or an error.
Example:
| Floor Example | |
|---|---|
Round(x)
Returns the nearest integer to x, rounding halves away from zero.
Parameters:
x: A number (int or float).
Returns:
(number, error): The rounded value as a float, or an error.
Example:
| Round Example | |
|---|---|
RoundToEven(x)
Returns the nearest integer to x, rounding ties to even.
Parameters:
x: A number (int or float).
Returns:
(number, error): The rounded value as a float, or an error.
Example:
| RoundToEven Example | |
|---|---|
Trunc(x)
Returns the integer value of x toward zero.
Parameters:
x: A number (int or float).
Returns:
(number, error): The truncated value as a float, or an error.
Example:
| Trunc Example | |
|---|---|
Pow10(n)
Returns 10**n.
Parameters:
n: An integer exponent.
Returns:
(number, error): The result as a float, or an error.
Example:
| Pow10 Example | |
|---|---|
Sqrt(x) and Cbrt(x)
Return the square root and cube root of x respectively.
Parameters:
x: A number (int or float).
Returns:
(number, error): The root as a float, or an error.
Example:
| Sqrt Example | |
|---|---|
Mod(x, y) and Remainder(x, y)
Mod returns the truncating floating remainder of x/y. Remainder returns the IEEE 754 floating remainder.
Parameters:
x,y: Numbers (int or float).
Returns:
(number, error): The remainder as a float, or an error.
Example:
| Mod Example | |
|---|---|
Exp(x), Exp2(x), Expm1(x), Log(x), Log10(x), Log2(x), Log1p(x)
Exponential and logarithmic functions.
Example:
| Exponential and Logarithmic | |
|---|---|
Trigonometric: Sin(x), Cos(x), Tan(x), Asin(x), Acos(x), Atan(x), Atan2(y, x), Sincos(x)
Compute trigonometric values in radians.
Example:
| Trigonometric Functions | |
|---|---|
Hyperbolic: Sinh(x), Cosh(x), Tanh(x), Asinh(x), Acosh(x), Atanh(x)
Hyperbolic functions and their inverses.
Example:
| Hyperbolic Functions | |
|---|---|
Special: Gamma(x), Lgamma(x), Erf(x), Erfc(x)
Special functions from mathematics and statistics.
Example:
| Special Functions | |
|---|---|
Utilities: Copysign, Signbit, Dim, FMA, Hypot, Frexp, Ldexp, Modf, Nextafter, Nextafter32
Floating helpers and IEEE 754 utilities.
Example:
| Utility Functions | |
|---|---|
Bit-level: Float32bits, Float64bits, Float32frombits, Float64frombits, Inf, IsInf, IsNaN, NaN, Ilogb, Logb
Inspect and construct floating point values and metadata.
Example:
Constants: Pi(), E(), Phi()
Return common mathematical constants.
Example:
| Mathematical Constants | |
|---|---|
Max(a, b)
Returns the maximum of two numbers.
Parameters:
a: An integer or a float.b: An integer or a float.
Returns:
(number, error): The larger of the two numbers, or an error if the arguments are not numbers.
Example:
| Max Example | |
|---|---|
Min(a, b)
Returns the minimum of two numbers.
Parameters:
a: An integer or a float.b: An integer or a float.
Returns:
(number, error): The smaller of the two numbers, or an error if the arguments are not numbers.
Example:
| Min Example | |
|---|---|
Pow(base, exponent)
Returns the base to the power of the exponent.
Parameters:
base: An integer or a float.exponent: An integer or a float.
Returns:
(number, error): The result of the power operation, or an error if the arguments are not numbers.
Example: