Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 1 | \section{Built-in Module \sectcode{math}} |
| 2 | |
| 3 | \bimodindex{math} |
| 4 | \renewcommand{\indexsubitem}{(in module math)} |
| 5 | This module is always available. |
| 6 | It provides access to the mathematical functions defined by the C |
| 7 | standard. |
| 8 | They are: |
| 9 | \iftexi |
| 10 | \begin{funcdesc}{acos}{x} |
| 11 | \funcline{asin}{x} |
| 12 | \funcline{atan}{x} |
| 13 | \funcline{atan2}{x, y} |
| 14 | \funcline{ceil}{x} |
| 15 | \funcline{cos}{x} |
| 16 | \funcline{cosh}{x} |
| 17 | \funcline{exp}{x} |
| 18 | \funcline{fabs}{x} |
| 19 | \funcline{floor}{x} |
| 20 | \funcline{fmod}{x, y} |
| 21 | \funcline{frexp}{x} |
Guido van Rossum | 411a8bd | 1994-10-20 22:00:28 +0000 | [diff] [blame] | 22 | \funcline{hypot}{x, y} |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 23 | \funcline{ldexp}{x, y} |
| 24 | \funcline{log}{x} |
| 25 | \funcline{log10}{x} |
| 26 | \funcline{modf}{x} |
| 27 | \funcline{pow}{x, y} |
| 28 | \funcline{sin}{x} |
| 29 | \funcline{sinh}{x} |
| 30 | \funcline{sqrt}{x} |
| 31 | \funcline{tan}{x} |
| 32 | \funcline{tanh}{x} |
| 33 | \end{funcdesc} |
| 34 | \else |
| 35 | \code{acos(\varvars{x})}, |
| 36 | \code{asin(\varvars{x})}, |
| 37 | \code{atan(\varvars{x})}, |
| 38 | \code{atan2(\varvars{x\, y})}, |
| 39 | \code{ceil(\varvars{x})}, |
| 40 | \code{cos(\varvars{x})}, |
| 41 | \code{cosh(\varvars{x})}, |
| 42 | \code{exp(\varvars{x})}, |
| 43 | \code{fabs(\varvars{x})}, |
| 44 | \code{floor(\varvars{x})}, |
| 45 | \code{fmod(\varvars{x\, y})}, |
| 46 | \code{frexp(\varvars{x})}, |
Guido van Rossum | 31cce97 | 1995-01-04 19:17:34 +0000 | [diff] [blame] | 47 | \code{hypot(\varvars{x\, y})}, |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 48 | \code{ldexp(\varvars{x\, y})}, |
| 49 | \code{log(\varvars{x})}, |
| 50 | \code{log10(\varvars{x})}, |
| 51 | \code{modf(\varvars{x})}, |
| 52 | \code{pow(\varvars{x\, y})}, |
| 53 | \code{sin(\varvars{x})}, |
| 54 | \code{sinh(\varvars{x})}, |
| 55 | \code{sqrt(\varvars{x})}, |
| 56 | \code{tan(\varvars{x})}, |
| 57 | \code{tanh(\varvars{x})}. |
| 58 | \fi |
| 59 | |
| 60 | Note that \code{frexp} and \code{modf} have a different call/return |
| 61 | pattern than their C equivalents: they take a single argument and |
| 62 | return a pair of values, rather than returning their second return |
| 63 | value through an `output parameter' (there is no such thing in Python). |
| 64 | |
Guido van Rossum | 5fdeeea | 1994-01-02 01:22:07 +0000 | [diff] [blame] | 65 | The module also defines two mathematical constants: |
| 66 | \iftexi |
| 67 | \begin{datadesc}{pi} |
| 68 | \dataline{e} |
| 69 | \end{datadesc} |
| 70 | \else |
| 71 | \code{pi} and \code{e}. |
| 72 | \fi |