Standard mathematics library providing common scientific functions.
Functions take both floating point and integer values unless otherwise stated
math.abs(x)
- returns the absolute value (or magnitude) of a number, thus always non-negativemath.exp(x)
- returnse**x
, the natural exponentiationmath.log(x)
- returns the natural logarithm ofx
math.sqrt(x)
- returns the square-root ofx
math.pi
- the floating point representation of π within YASLmath.cos(x)
,math.sin(x)
,math.tan(x)
- the respective trigonometric functions taking an angle in radiansmath.acos(x)
,math.asin(x)
,math.atan(x)
- the inverse trigonometric functions returning an angle in radians in the range [-π/2, π/2]math.ceil(x)
- returns the integer closest tox
such that it is greater-than or equal-tox
math.floor(x)
- returns the integer closest tox
such that it is less-than or equal-tox
math.deg(x)
- treatsx
as an angle in radians and returns the equivalent angle in degreesmath.rad(x)
- treatsx
as an angle in degrees and returns the equivalent angle in radians
Function arguments will be type cast to integers unless otherwise specified
math.isprime(n)
- ifn >= 2
then returnstrue
iffn
is prime, elseundef
math.gcd(a, b)
- ifa > 0 & b > 0
then return the greatest common divisor ofa
andb
, elseundef
math.lcm(a, b)
- ifa > 0 & b > 0
then return the lowest common multiple ofa
andb
, elseundef
math.rand()
- returns a pseudo-random 64-bit signed integer from a uniform distribution