Skip to content

Commit 4425774

Browse files
Rewrite the math module documentation.
1 parent a5bac9c commit 4425774

File tree

1 file changed

+66
-62
lines changed

1 file changed

+66
-62
lines changed

Doc/library/math.rst

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ noted otherwise, all return values are floats.
2727

2828

2929
==================================================== ============================================
30-
**Number-theoretic functions**
31-
--------------------------------------------------------------------------------------------------
32-
:func:`comb(n, k) <comb>` Number of ways to choose *k* items from *n* items without repetition and without order
33-
:func:`factorial(n) <factorial>` *n* factorial
34-
:func:`gcd(*integers) <gcd>` Greatest common divisor of the integer arguments
35-
:func:`isqrt(n) <isqrt>` Integer square root of a nonnegative integer *n*
36-
:func:`lcm(*integers) <lcm>` Least common multiple of the integer arguments
37-
:func:`perm(n, k) <perm>` Number of ways to choose *k* items from *n* items without repetition and with order
38-
3930
**Floating point arithmetic**
4031
--------------------------------------------------------------------------------------------------
4132
:func:`ceil(x) <ceil>` Ceiling of *x*, the smallest integer greater than or equal to *x*
@@ -126,59 +117,6 @@ noted otherwise, all return values are floats.
126117
==================================================== ============================================
127118

128119

129-
Number-theoretic functions
130-
--------------------------
131-
132-
These functions are aliases of corresponding functions in the
133-
:mod:`math.integer` module.
134-
135-
.. function:: comb(n, k)
136-
137-
An alias of :func:`math.integer.comb`.
138-
139-
.. versionadded:: 3.8
140-
141-
142-
.. function:: factorial(n)
143-
144-
An alias of :func:`math.integer.factorial`.
145-
146-
.. versionchanged:: 3.10
147-
Floats with integral values (like ``5.0``) are no longer accepted.
148-
149-
150-
.. function:: gcd(*integers)
151-
152-
An alias of :func:`math.integer.gcd`.
153-
154-
.. versionadded:: 3.5
155-
156-
.. versionchanged:: 3.9
157-
Added support for an arbitrary number of arguments. Formerly, only two
158-
arguments were supported.
159-
160-
161-
.. function:: isqrt(n)
162-
163-
An alias of :func:`math.integer.isqrt`.
164-
165-
.. versionadded:: 3.8
166-
167-
168-
.. function:: lcm(*integers)
169-
170-
An alias of :func:`math.integer.lcm`.
171-
172-
.. versionadded:: 3.9
173-
174-
175-
.. function:: perm(n, k=None)
176-
177-
An alias of :func:`math.integer.perm`.
178-
179-
.. versionadded:: 3.8
180-
181-
182120
Floating point arithmetic
183121
-------------------------
184122

@@ -779,6 +717,69 @@ Special functions
779717
.. versionadded:: 3.2
780718

781719

720+
Number-theoretic functions
721+
--------------------------
722+
723+
For backward compatibility, the :mod:`math` module provides also aliases of
724+
the following functions from the :mod:`math.integer` module:
725+
726+
.. list-table:: **Number-theoretic functions**
727+
728+
* - .. function:: comb(n, k)
729+
:no-typesetting:
730+
731+
:func:`comb(n, k) <math.integer.comb>`
732+
- Number of ways to choose *k* items from *n* items without repetition and without order
733+
734+
* - .. function:: factorial(n)
735+
:no-typesetting:
736+
737+
:func:`factorial(n) <math.integer.factorial>`
738+
- *n* factorial
739+
740+
* - .. function:: gcd(*integers)
741+
:no-typesetting:
742+
743+
:func:`gcd(*integers) <math.integer.gcd>`
744+
- Greatest common divisor of the integer arguments
745+
746+
* - .. function:: isqrt(n)
747+
:no-typesetting:
748+
749+
:func:`isqrt(n) <math.integer.isqrt>`
750+
- Integer square root of a nonnegative integer *n*
751+
752+
* - .. function:: lcm(*integers)
753+
:no-typesetting:
754+
755+
:func:`lcm(*integers) <math.integer.lcm>`
756+
- Least common multiple of the integer arguments
757+
758+
* - .. function:: perm(n, k)
759+
:no-typesetting:
760+
761+
:func:`perm(n, k) <math.integer.perm>`
762+
- Number of ways to choose *k* items from *n* items without repetition and with order
763+
764+
.. versionadded:: 3.5
765+
The :func:`gcd` function.
766+
767+
.. versionadded:: 3.8
768+
The :func:`comb`, :func:`perm` and :func:`isqrt` functions.
769+
770+
.. versionadded:: 3.9
771+
The :func:`lcm` function.
772+
773+
.. versionchanged:: 3.9
774+
Added support for an arbitrary number of arguments in the :func:`gcd`
775+
function.
776+
Formerly, only two arguments were supported.
777+
778+
.. versionchanged:: 3.10
779+
Floats with integral values (like ``5.0``) are no longer accepted in the
780+
:func:`factorial` function.
781+
782+
782783
Constants
783784
---------
784785

@@ -860,3 +861,6 @@ Constants
860861

861862
Module :mod:`cmath`
862863
Complex number versions of many of these functions.
864+
865+
Module :mod:`math.integer`
866+
Integer-specific mathematics functions.

0 commit comments

Comments
 (0)