Module math
Mathematical Functions.
This library is an interface to the standard C math library.
It provides all its functions inside the table math
.
Type math
math.abs(x) |
Returns the absolute value of |
math.acos(x) |
Returns the arc cosine of |
math.asin(x) |
Returns the arc sine of |
math.atan(x) |
Returns the arc tangent of |
math.atan2(y, x) |
Returns the arc tangent of |
math.ceil(x) |
Returns the smallest integer larger than or equal to |
math.cos(x) |
Returns the cosine of |
math.cosh(x) |
Returns the hyperbolic cosine of |
math.deg(x) |
Returns the angle |
math.exp(x) |
Returns the value e^x. |
math.floor(x) |
Returns the largest integer smaller than or equal to |
math.fmod(x, y) |
Returns the remainder of the division of |
math.frexp(x) |
Returns |
math.huge |
The value |
math.ldexp(m, e) |
Returns m2^e ( |
math.log(x, base) |
Returns the logarithm of |
math.max(x, ...) |
Returns the maximum value among its arguments. |
math.min(x, ...) |
Returns the minimum value among its arguments. |
math.modf(x) |
Returns two numbers, the integral part of |
math.pi |
The value of pi. |
math.pow(x, y) |
Returns x^y. |
math.rad(x) |
Returns the angle |
math.random(m, n) |
This function is an interface to the simple pseudo-random generator
function |
math.randomseed(x) |
Sets |
math.sin(x) |
Returns the sine of |
math.sinh(x) |
Returns the hyperbolic sine of |
math.sqrt(x) |
Returns the square root of |
math.tan(x) |
Returns the tangent of |
math.tanh(x) |
Returns the hyperbolic tangent of |
Type math
Field(s)
- math.abs(x)
-
Returns the absolute value of
x
.Parameter
-
#number x
:
Return value
#number:
-
- math.acos(x)
-
Returns the arc cosine of
x
(in radians).Parameter
-
#number x
:
Return value
#number:
-
- math.asin(x)
-
Returns the arc sine of
x
(in radians).Parameter
-
#number x
:
Return value
#number:
-
- math.atan(x)
-
Returns the arc tangent of
x
(in radians).Parameter
-
#number x
:
Return value
#number:
-
- math.atan2(y, x)
-
Returns the arc tangent of
y/x
(in radians), but uses the signs of both parameters to find the quadrant of the result.(It also handles correctly the case of
x
being zero.)Parameters
-
#number y
: -
#number x
:
Return value
#number:
-
- math.ceil(x)
-
Returns the smallest integer larger than or equal to
x
.Parameter
-
#number x
:
Return value
#number:
-
- math.cos(x)
-
Returns the cosine of
x
(assumed to be in radians).Parameter
-
#number x
:
Return value
#number:
-
- math.cosh(x)
-
Returns the hyperbolic cosine of
x
.Parameter
-
#number x
:
Return value
#number:
-
- math.deg(x)
-
Returns the angle
x
(given in radians) in degrees.Parameter
-
#number x
:
Return value
#number:
-
- math.exp(x)
-
Returns the value e^x.
Parameter
-
#number x
:
Return value
#number:
-
- math.floor(x)
-
Returns the largest integer smaller than or equal to
x
.Parameter
-
#number x
:
Return value
#number:
-
- math.fmod(x, y)
-
Returns the remainder of the division of
x
byy
that rounds the quotient towards zero.Parameters
-
#number x
: -
#number y
:
Return value
#number:
-
- math.frexp(x)
-
Returns
m
ande
such that x = m2^e,e
is an integer and the absolute value ofm
is in the range [0.5, 1) (or zero whenx
is zero).Parameter
-
#number x
:
Return value
#number:
-
- #number math.huge
-
The value
HUGE_VAL
, a value larger than or equal to any other numerical value.
- math.ldexp(m, e)
-
Returns m2^e (
e
should be an integer).Parameters
-
#number m
: -
#number e
:
Return value
#number:
-
- math.log(x, base)
-
Returns the logarithm of
x
in the given base.The default for
base
ise
(so that the function returns the natural logarithm ofx
).Parameters
-
#number x
: -
#number base
:
Return value
#number:
-
- math.max(x, ...)
-
Returns the maximum value among its arguments.
Parameters
-
#number x
: first number -
#number ...
: other numbers
Return value
#number:
-
- math.min(x, ...)
-
Returns the minimum value among its arguments.
Parameters
-
#number x
: first number -
#number ...
: other numbers
Return value
#number:
-
- math.modf(x)
-
Returns two numbers, the integral part of
x
and the fractional part ofx
.Parameter
-
#number x
:
Return value
#number:
-
- #number math.pi
-
The value of pi.
- math.pow(x, y)
-
Returns x^y.
(You can also use the expression
x^y
to compute this value.)Parameters
-
#number x
: -
#number y
:
Return value
#number:
-
- math.rad(x)
-
Returns the angle
x
(given in degrees) in radians.Parameter
-
#number x
:
Return value
#number:
-
- math.random(m, n)
-
This function is an interface to the simple pseudo-random generator function
rand
provided by ANSI C.(No guarantees can be given for its statistical properties.)
When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number
m
,math.random
returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbersm
andn
,math.random
returns a uniform pseudo-random integer in the range [m, n].Parameters
-
#number m
: -
#number n
:
Return value
#number:
-
- math.randomseed(x)
-
Sets
x
as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.Parameter
-
#number x
:
Return value
#number:
-
- math.sin(x)
-
Returns the sine of
x
(assumed to be in radians).Parameter
-
#number x
:
Return value
#number:
-
- math.sinh(x)
-
Returns the hyperbolic sine of
x
.Parameter
-
#number x
:
Return value
#number:
-
- math.sqrt(x)
-
Returns the square root of
x
.(You can also use the expression
x^0.5
to compute this value.)Parameter
-
#number x
:
Return value
#number:
-
- math.tan(x)
-
Returns the tangent of
x
(assumed to be in radians).Parameter
-
#number x
:
Return value
#number:
-
- math.tanh(x)
-
Returns the hyperbolic tangent of
x
.Parameter
-
#number x
:
Return value
#number:
-