math
import mathFunctions
Section titled “Functions”| Function | Signature | Description |
|---|---|---|
min | (Int, Int) -> Int | Return the smaller of two integers. |
max | (Int, Int) -> Int | Return the larger of two integers. |
abs | (Int) -> Int | Return the absolute value of an integer. |
pow | (Int, Int) -> Int | Raise an integer base to an integer exponent. |
pi | () -> Float | Return the mathematical constant pi (3.14159…). |
e | () -> Float | Return Euler’s number e (2.71828…). |
sin | (Float) -> Float | Return the sine of an angle in radians. |
cos | (Float) -> Float | Return the cosine of an angle in radians. |
tan | (Float) -> Float | Return the tangent of an angle in radians. |
log | (Float) -> Float | Return the natural logarithm (base e) of a float. |
exp | (Float) -> Float | Return e raised to the given power. |
sqrt | (Float) -> Float | Return the square root of a float. |
log10 | (Float) -> Float | Return the base-10 logarithm of a float. |
log2 | (Float) -> Float | Return the base-2 logarithm of a float. |
sign | (Int) -> Int | Return the sign of an integer: -1, 0, or 1. |
fmin | (Float, Float) -> Float | Return the smaller of two floats. |
fmax | (Float, Float) -> Float | Return the larger of two floats. |
fpow | (Float, Float) -> Float | Raise a float base to a float exponent. |
factorial | (Int) -> Int | Return the factorial of a non-negative integer. |
choose | (Int, Int) -> Int | Return the binomial coefficient C(n, k) = n! / (k! * (n-k)!). |
log_gamma | (Float) -> Float | Return the natural logarithm of the gamma function at x. |
Reference
Section titled “Reference”math.min(a: Int, b: Int) -> Int
Section titled “math.min(a: Int, b: Int) -> Int”Return the smaller of two integers.
math.min(3, 7) // => 3math.max(a: Int, b: Int) -> Int
Section titled “math.max(a: Int, b: Int) -> Int”Return the larger of two integers.
math.max(3, 7) // => 7math.abs(n: Int) -> Int
Section titled “math.abs(n: Int) -> Int”Return the absolute value of an integer.
math.abs(-5) // => 5math.pow(base: Int, exp: Int) -> Int
Section titled “math.pow(base: Int, exp: Int) -> Int”Raise an integer base to an integer exponent.
math.pow(2, 10) // => 1024math.pi() -> Float
Section titled “math.pi() -> Float”Return the mathematical constant pi (3.14159…).
math.pi() // => 3.141592653589793math.e() -> Float
Section titled “math.e() -> Float”Return Euler’s number e (2.71828…).
math.e() // => 2.718281828459045math.sin(x: Float) -> Float
Section titled “math.sin(x: Float) -> Float”Return the sine of an angle in radians.
math.sin(0.0) // => 0.0math.cos(x: Float) -> Float
Section titled “math.cos(x: Float) -> Float”Return the cosine of an angle in radians.
math.cos(0.0) // => 1.0math.tan(x: Float) -> Float
Section titled “math.tan(x: Float) -> Float”Return the tangent of an angle in radians.
math.tan(0.0) // => 0.0math.log(x: Float) -> Float
Section titled “math.log(x: Float) -> Float”Return the natural logarithm (base e) of a float.
math.log(1.0) // => 0.0math.exp(x: Float) -> Float
Section titled “math.exp(x: Float) -> Float”Return e raised to the given power.
math.exp(1.0) // => 2.718281828459045math.sqrt(x: Float) -> Float
Section titled “math.sqrt(x: Float) -> Float”Return the square root of a float.
math.sqrt(16.0) // => 4.0math.log10(x: Float) -> Float
Section titled “math.log10(x: Float) -> Float”Return the base-10 logarithm of a float.
math.log10(100.0) // => 2.0math.log2(x: Float) -> Float
Section titled “math.log2(x: Float) -> Float”Return the base-2 logarithm of a float.
math.log2(8.0) // => 3.0math.sign(n: Int) -> Int
Section titled “math.sign(n: Int) -> Int”Return the sign of an integer: -1, 0, or 1.
math.sign(-42) // => -1math.fmin(a: Float, b: Float) -> Float
Section titled “math.fmin(a: Float, b: Float) -> Float”Return the smaller of two floats.
math.fmin(1.5, 2.5) // => 1.5math.fmax(a: Float, b: Float) -> Float
Section titled “math.fmax(a: Float, b: Float) -> Float”Return the larger of two floats.
math.fmax(1.5, 2.5) // => 2.5math.fpow(base: Float, exp: Float) -> Float
Section titled “math.fpow(base: Float, exp: Float) -> Float”Raise a float base to a float exponent.
math.fpow(2.0, 0.5) // => 1.4142135623730951math.factorial(n: Int) -> Int
Section titled “math.factorial(n: Int) -> Int”Return the factorial of a non-negative integer.
math.factorial(5) // => 120math.choose(n: Int, k: Int) -> Int
Section titled “math.choose(n: Int, k: Int) -> Int”Return the binomial coefficient C(n, k) = n! / (k! * (n-k)!).
math.choose(5, 2) // => 10math.log_gamma(x: Float) -> Float
Section titled “math.log_gamma(x: Float) -> Float”Return the natural logarithm of the gamma function at x.
math.log_gamma(5.0) // => 3.178...