This module provides the usual basic transcendental
mathematical functions. All trig functions use angles in
radians. (For a similar set of functions using the complex
number system, see the
Python library documentation for the cmath
module.)
The math module has two constant
attributes:
pi | The constant 3.14159... |
e | The base of natural logarithms, 2.71828... |
Functions in this module include:
acos(
|
Angle (in radians) whose cosine is , that is,
arccosine of .
|
acosh(
|
Inverse hyperbolic cosine of
|
asin(
|
Arcsine of .
|
asinh(
|
Inverse hyperbolic sine of
|
atan(
|
Arctangent of .
|
atanh(
|
Inverse hyperbolic tangent of
|
atan2( |
Angle whose slope is
, even if
is zero.
|
ceil(
|
True ceiling function, defined as the smallest
integer that is greater than or equal to . For
example, ceil(3.9) yields 4.0,
while ceil(-3.9) yields -3.0.
|
cos(
|
Cosine of , where is expressed in
radians.
|
cosh(
|
Hyperbolic cosine of .
|
degrees(
|
For
in radians, returns that angle in degrees.
|
erf(
| Error function. |
erfc(
| Error function complement. |
exp(
|
e to the power.
|
fabs(
|
Returns the absolute value of as a float value.
|
factorial(
|
Returns the factorial of , which must be a
nonnegative integer.
|
floor(
|
True floor function, defined as the largest
integer that is less than or equal to . For
example, floor(3.9) is 3.0, and
floor(-3.9) is -4.0.
|
fmod(
|
Returns (.
|
frexp(
|
For a float value , returns a tuple ( where is the
mantissa and is the exponent. For , it
returns (0.0, 0); otherwise, abs( is a
float in the half-open interval [0.5, 1) and
is
an integer, such that x == m*2**e.
|
gamma(
| Gamma function. |
hypot(
|
The square root of (2+2).
|
ldexp(
|
Returns .
This is the inverse of frexp().
|
lgamma(
|
Natural log of abs(gamma(.
|
log(
|
With one argument, returns the natural log of
.
With the second argument, returns the log of
to
the base .
|
log10(
|
Common log (base 10) of .
|
modf(
|
Returns a tuple ( where
is the
fractional part of , is the integral part (as a
float), and both have the same sign as .
|
radians(
|
For
in degrees, returns that angle in radians.
|
sin(
|
Sine of .
|
sinh(
|
Hyperbolic sine of .
|
sqrt(
|
Square root of .
|
tan(
|
Tangent of .
|
tanh(
|
Hyperbolic tangent of .
|