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 ofxmath.sqrt(x)- returns the square-root ofxmath.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 toxsuch that it is greater-than or equal-toxmath.floor(x)- returns the integer closest toxsuch that it is less-than or equal-toxmath.deg(x)- treatsxas an angle in radians and returns the equivalent angle in degreesmath.rad(x)- treatsxas 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 >= 2then returnstrueiffnis prime, elseundefmath.gcd(a, b)- ifa > 0 & b > 0then return the greatest common divisor ofaandb, elseundefmath.lcm(a, b)- ifa > 0 & b > 0then return the lowest common multiple ofaandb, elseundef
math.rand()- returns a pseudo-random 64-bit signed integer from a uniform distribution