This module is always available. It provides access to the mathematical functions defined by the C standard.
These functions cannot be used with complex numbers; use the functions of the same name from the cmath module if you require support for complex numbers. The distinction between functions which support complex numbers and those which don't is made since most users do not want to learn quite as much mathematics as required to understand complex numbers. Receiving an exception instead of a complex result allows earlier detection of the unexpected complex number used as a parameter, so that the programmer can determine how and why it was generated in the first place.
The following functions are provided by this module:
atan(y / x).
fmod(x, y), as defined by the platform C library. Note that the Python expression
x % ymay not return the same result.
(m, e). m is a float and e is an integer such that
x == m * 2**e. If x is zero, returns
(0.0, 0), otherwise
0.5 <= abs(m) < 1.
sqrt(x*x + y*y).
x * (2**i).
Note that frexp() and modf() have a different call/return pattern than their C equivalents: they take a single argument and return a pair of values, rather than returning their second return value through an `output parameter' (there is no such thing in Python).
The module also defines two mathematical constants:
-Infor raises ValueError or OverflowError is both platform- and release-dependent, and in cases where
math.log(0)raises an OverflowError,
math.log(0L)often raises a ValueError.