aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Doc/library/math.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/math.rst')
-rw-r--r--Doc/library/math.rst62
1 files changed, 59 insertions, 3 deletions
diff --git a/Doc/library/math.rst b/Doc/library/math.rst
index 394a462b946..55f2de07553 100644
--- a/Doc/library/math.rst
+++ b/Doc/library/math.rst
@@ -10,8 +10,8 @@
--------------
-This module provides access to the mathematical functions defined by the C
-standard.
+This module provides access to common mathematical functions and constants,
+including those defined by the C standard.
These functions cannot be used with complex numbers; use the functions of the
same name from the :mod:`cmath` module if you require support for complex
@@ -42,6 +42,8 @@ noted otherwise, all return values are floats.
:func:`fabs(x) <fabs>` Absolute value of *x*
:func:`floor(x) <floor>` Floor of *x*, the largest integer less than or equal to *x*
:func:`fma(x, y, z) <fma>` Fused multiply-add operation: ``(x * y) + z``
+:func:`fmax(x, y) <fmax>` Maximum of two floating-point values
+:func:`fmin(x, y) <fmin>` Minimum of two floating-point values
:func:`fmod(x, y) <fmod>` Remainder of division ``x / y``
:func:`modf(x) <modf>` Fractional and integer parts of *x*
:func:`remainder(x, y) <remainder>` Remainder of *x* with respect to *y*
@@ -53,10 +55,13 @@ noted otherwise, all return values are floats.
:func:`frexp(x) <frexp>` Mantissa and exponent of *x*
:func:`isclose(a, b, rel_tol, abs_tol) <isclose>` Check if the values *a* and *b* are close to each other
:func:`isfinite(x) <isfinite>` Check if *x* is neither an infinity nor a NaN
+:func:`isnormal(x) <isnormal>` Check if *x* is a normal number
+:func:`issubnormal(x) <issubnormal>` Check if *x* is a subnormal number
:func:`isinf(x) <isinf>` Check if *x* is a positive or negative infinity
:func:`isnan(x) <isnan>` Check if *x* is a NaN (not a number)
:func:`ldexp(x, i) <ldexp>` ``x * (2**i)``, inverse of function :func:`frexp`
:func:`nextafter(x, y, steps) <nextafter>` Floating-point value *steps* steps after *x* towards *y*
+:func:`signbit(x) <signbit>` Check if *x* is a negative number
:func:`ulp(x) <ulp>` Value of the least significant bit of *x*
**Power, exponential and logarithmic functions**
@@ -245,6 +250,30 @@ Floating point arithmetic
.. versionadded:: 3.13
+.. function:: fmax(x, y)
+
+ Get the larger of two floating-point values, treating NaNs as missing data.
+
+ When both operands are (signed) NaNs or zeroes, return ``nan`` and ``0``
+ respectively and the sign of the result is implementation-defined, that
+ is, :func:`!fmax` is not required to be sensitive to the sign of such
+ operands (see Annex F of the C11 standard, §F.10.0.3 and §F.10.9.2).
+
+ .. versionadded:: next
+
+
+.. function:: fmin(x, y)
+
+ Get the smaller of two floating-point values, treating NaNs as missing data.
+
+ When both operands are (signed) NaNs or zeroes, return ``nan`` and ``0``
+ respectively and the sign of the result is implementation-defined, that
+ is, :func:`!fmin` is not required to be sensitive to the sign of such
+ operands (see Annex F of the C11 standard, §F.10.0.3 and §F.10.9.3).
+
+ .. versionadded:: next
+
+
.. function:: fmod(x, y)
Return the floating-point remainder of ``x / y``,
@@ -373,6 +402,24 @@ Floating point manipulation functions
.. versionadded:: 3.2
+.. function:: isnormal(x)
+
+ Return ``True`` if *x* is a normal number, that is a finite
+ nonzero number that is not a subnormal (see :func:`issubnormal`).
+ Return ``False`` otherwise.
+
+ .. versionadded:: next
+
+
+.. function:: issubnormal(x)
+
+ Return ``True`` if *x* is a subnormal number, that is a finite
+ nonzero number with a magnitude smaller than :data:`sys.float_info.min`.
+ Return ``False`` otherwise.
+
+ .. versionadded:: next
+
+
.. function:: isinf(x)
Return ``True`` if *x* is a positive or negative infinity, and
@@ -411,6 +458,15 @@ Floating point manipulation functions
Added the *steps* argument.
+.. function:: signbit(x)
+
+ Return ``True`` if the sign of *x* is negative and ``False`` otherwise.
+
+ This is useful to detect the sign bit of zeroes, infinities and NaNs.
+
+ .. versionadded:: next
+
+
.. function:: ulp(x)
Return the value of the least significant bit of the float *x*:
@@ -774,7 +830,7 @@ Constants
The mathematical constant *τ* = 6.283185..., to available precision.
Tau is a circle constant equal to 2\ *π*, the ratio of a circle's circumference to
its radius. To learn more about Tau, check out Vi Hart's video `Pi is (still)
- Wrong <https://www.youtube.com/watch?v=jG7vhMMXagQ>`_, and start celebrating
+ Wrong <https://vimeo.com/147792667>`_, and start celebrating
`Tau day <https://tauday.com/>`_ by eating twice as much pie!
.. versionadded:: 3.6