Math
The math
module can be imported with the statement import math
.
The math
module is used to do math. To do statistics, use the statistics
module.
Constants
math.pi
: Pi.math.tau
: Tau.math.sqrt_pi
: square root of pi (math.sqrt(math.pi)
).math.sqrt_tau
: square root of tau (math.sqrt(math.tau)
).math.e
: Euler's number.
Functions
math.sqrt
Syntax: math.sqrt(n)
Returns (square root of ),
math.isqrt
Syntax: math.isqrt(n)
Returns (integer square root of ),
math.root
Syntax: math.root(n, k)
Returns the (-th root of ),
math.iroot
Syntax: math.iroot(n, k)
Returns (integer -th root of ),
math.degrees
Syntax: math.degrees(angle)
Transforms a radian angle to a degree angle.
math.radians
Syntax: math.radians(angle)
Transform a degree angle to a radian angle.
math.sin
Syntax: math.sin(angle)
Returns sine of an angle in radians.
math.cos
Syntax: math.cos(angle)
Returns cosine of an angle in radians.
math.tan
Syntax: math.tan(angle)
Returns tangent of an angle in radians.
math.asin
Syntax: math.asin(sin)
Returns arcsine of an sin (result in radians).
math.acos
Syntax: math.acos(cos)
Returns arccosine of an cos (result in radians).
math.atan
Syntax: math.atan(tan)
Returns arctangent of an tan (result in radians).
math.abs
Syntax: math.abs(n)
Returns (absolute value of ),
math.log
Syntax: math.log(n, <base>)
Returns the natural logarithm (base
=) of if no base is given, or the logarithm of in the given base.
math.log2
Syntax: math.log2(n)
Same as math.log(n, 2)
.
math.factorial
Added in 0.19.0-beta
Syntax: math.factorial(n)
Returns (factorial of ).