Module math
standard mathematical functions.
Functions
- abs (x)
-
Returns the absolute value of
x. - acos (x)
-
Returns the arc cosine of
x(in radians). - asin (x)
-
Returns the arc sine of
x(in radians). - atan (x)
-
Returns the arc tangent of
x(in radians). - 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 ofxbeing zero.) - ceil (x)
-
Returns the smallest integer larger than or equal to
x. - cos (x)
-
Returns the cosine of
x(assumed to be in radians). - cosh (x)
-
Returns the hyperbolic cosine of
x. - deg (x)
-
Returns the angle
x(given in radians) in degrees. - exp (x)
- Returns the value e^x.
- floor (x)
-
Returns the largest integer smaller than or equal to
x. - fmod (x, y)
-
Returns the remainder of the division of
xbyythat rounds the quotient towards zero. - frexp (x)
-
Returns
mandesuch that x = m2^e,eis an integer and the absolute value ofmis in the range [0.5, 1) (or zero whenxis zero). - ldexp (m, e)
-
Returns m2^e (
eshould be an integer). - log (x)
-
Returns the natural logarithm of
x. - log10 (x)
-
Returns the base-10 logarithm of
x. - max (x, ...)
- Returns the maximum value among its arguments.
- min (x, ...)
- Returns the minimum value among its arguments.
- modf (x)
-
Returns two numbers, the integral part of
xand the fractional part ofx. - pow (x, y)
-
Returns x^y. (You can also use the expression
x^yto compute this value.) - rad (x)
-
Returns the angle
x(given in degrees) in radians. - random (m, n)
-
This function is an interface to the simple pseudo-random generator
function
randprovided 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 numberm,math.randomreturns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbersmandn,math.randomreturns a uniform pseudo-random integer in the range [m, n]. - randomseed (x)
-
Sets
xas the “seed” for the pseudo-random generator: equal seeds produce equal sequences of numbers. - sin (x)
-
Returns the sine of
x(assumed to be in radians). - sinh (x)
-
Returns the hyperbolic sine of
x. - sqrt (x)
-
Returns the square root of
x. (You can also use the expressionx^0.5to compute this value.) - tan (x)
-
Returns the tangent of
x(assumed to be in radians). - tanh (x)
-
Returns the hyperbolic tangent of
x.