Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a4cfb42

Browse files
committed
Add entry for the math module.
1 parent ad81f2b commit a4cfb42

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Doc/whatsnew/3.2.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,45 @@ datetime and time
972972

973973
(Contributed by Alexander Belopolsky and Victor Stinner.)
974974

975+
math
976+
----
977+
978+
The :mod:`math` module has been updated with five new functions inspired by the
979+
C99 standard.
980+
981+
The :func:`~math.isfinite` function provides a reliable and fast way to detect
982+
special values. It returns *True* for regular numbers and *False* for *Nan* or
983+
*Infinity*:
984+
985+
>>> [isfinite(x) for x in (123, 4.56, float('Nan'), float('Inf'))]
986+
[True, True, False, False]
987+
988+
The :func:`~math.expm1` function computes ``e**x-1`` for small values of *x*
989+
without incuring the loss of precision that usually accompanies the subtraction
990+
of nearly equal quantities:
991+
992+
>>> expm1(0.013671875) # more accurate way to compute e**x-1 for a small x
993+
0.013765762467652909
994+
995+
The :func:`~math.erf` function computes a probability integral of `Gaussian
996+
error function <http://en.wikipedia.org/wiki/Error_function>`_:
997+
998+
>>> erf(1.0/sqrt(2.0)) # portion of normal distribution within 1 standard deviation
999+
0.682689492137086
1000+
1001+
:func:`~math.gamma` is a continuous extension of the factorial function. See
1002+
http://en.wikipedia.org/wiki/Gamma_function for details. Because the function
1003+
is related to factorials, it grows large even for small values of *x*, so there
1004+
is also a :func:`~math.lgamma` for computing the natural logarithm of the gamma
1005+
function:
1006+
1007+
>>> gamma(7.0) # six factorial
1008+
720.0
1009+
>>> lgamma(801.0) # log(800 factorial)
1010+
4551.950730698041
1011+
1012+
(Contributed by Mark Dickinson.)
1013+
9751014
abc
9761015
---
9771016

0 commit comments

Comments
 (0)