cpython-withatomic / Doc / libmath.tex

The branch 'legacy-trunk' does not exist.
\section{Built-in Module \sectcode{math}}

\renewcommand{\indexsubitem}{(in module math)}
This module is always available.
It provides access to the mathematical functions defined by the C
They are:

Return the arc cosine of \var{x}.

Return the arc sine of \var{x}.

Return the arc tangent of \var{x}.

\begin{funcdesc}{atan2}{x, y}
Return \code{atan(x / y)}.

Return the ceiling of \var{x}.

Return the cosine of \var{x}.

Return the hyperbolic cosine of \var{x}.

Return \code{e**\var{x}}.

Return the absolute value of the real \var{x}.

Return the floor of \var{x}.

\begin{funcdesc}{fmod}{x, y}
Return \code{x \% y}.

Return the matissa and exponent for \var{x}.  The mantissa is

\begin{funcdesc}{hypot}{x, y}
Return the Euclidean distance, \code{sqrt(x*x + y*y)}.

\begin{funcdesc}{ldexp}{x, i}
Return \code{\var{x} * (2**\var{i})}.

Return the fractional and integer parts of \var{x}.  Both results
carry the sign of \var{x}.

\begin{funcdesc}{pow}{x, y}
Return \code{\var{x}**\var{y}}.

Return the sine of \var{x}.

Return the hyperbolic sine of \var{x}.

Return the square root of \var{x}.

Return the tangent of \var{x}.

Return the hyperbolic tangent of \var{x}.

Note that \code{frexp} and \code{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:

The mathematical constant \emph{pi}.

The mathematical constant \emph{e}.

  \seemodule{cmath}{Complex number versions of many of these functions.}