Skip to content

Commit dbaf746

Browse files
bpo-29956: Improve the math.exp() related documentation. (python#1073)
1 parent 7e4db2f commit dbaf746

3 files changed

Lines changed: 28 additions & 14 deletions

File tree

Doc/library/cmath.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ rectangular coordinates to polar coordinates and back.
4747

4848
Return the phase of *x* (also known as the *argument* of *x*), as a
4949
float. ``phase(x)`` is equivalent to ``math.atan2(x.imag,
50-
x.real)``. The result lies in the range [-π, π], and the branch
50+
x.real)``. The result lies in the range [-\ *π*, *π*], and the branch
5151
cut for this operation lies along the negative real axis,
5252
continuous from above. On systems with support for signed zeros
5353
(which includes most systems in current use), this means that the
@@ -86,7 +86,8 @@ Power and logarithmic functions
8686

8787
.. function:: exp(x)
8888

89-
Return the exponential value ``e**x``.
89+
Return *e* raised to the power *x*, where *e* is the base of natural
90+
logarithms.
9091

9192

9293
.. function:: log(x[, base])
@@ -243,7 +244,6 @@ Classification functions
243244
Constants
244245
---------
245246

246-
247247
.. data:: pi
248248

249249
The mathematical constant *π*, as a float.
@@ -253,32 +253,37 @@ Constants
253253

254254
The mathematical constant *e*, as a float.
255255

256+
256257
.. data:: tau
257258

258259
The mathematical constant *τ*, as a float.
259260

260261
.. versionadded:: 3.6
261262

263+
262264
.. data:: inf
263265

264266
Floating-point positive infinity. Equivalent to ``float('inf')``.
265267

266268
.. versionadded:: 3.6
267269

270+
268271
.. data:: infj
269272

270273
Complex number with zero real part and positive infinity imaginary
271274
part. Equivalent to ``complex(0.0, float('inf'))``.
272275

273276
.. versionadded:: 3.6
274277

278+
275279
.. data:: nan
276280

277281
A floating-point "not a number" (NaN) value. Equivalent to
278282
``float('nan')``.
279283

280284
.. versionadded:: 3.6
281285

286+
282287
.. data:: nanj
283288

284289
Complex number with zero real part and NaN imaginary part. Equivalent to

Doc/library/math.rst

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ Number-theoretic and representation functions
4242
*y*. On platforms that support signed zeros, ``copysign(1.0, -0.0)``
4343
returns *-1.0*.
4444

45+
4546
.. function:: fabs(x)
4647

4748
Return the absolute value of *x*.
4849

50+
4951
.. function:: factorial(x)
5052

5153
Return *x* factorial. Raises :exc:`ValueError` if *x* is not integral or
5254
is negative.
5355

56+
5457
.. function:: floor(x)
5558

5659
Return the floor of *x*, the largest integer less than or equal to *x*.
@@ -220,12 +223,15 @@ Power and logarithmic functions
220223

221224
.. function:: exp(x)
222225

223-
Return e raised to the power *x*, where e = 2.718281... is the base
224-
of natural logarithms.
226+
Return *e* raised to the power *x*, where *e* = 2.718281... is the base
227+
of natural logarithms. This is usually more accurate than ``math.e ** x``
228+
or ``pow(math.e, x)``.
229+
225230

226231
.. function:: expm1(x)
227232

228-
Return ``e**x - 1``. For small floats *x*, the subtraction in ``exp(x) - 1``
233+
Return *e* raised to the power *x*, minus 1. Here *e* is the base of natural
234+
logarithms. For small floats *x*, the subtraction in ``exp(x) - 1``
229235
can result in a `significant loss of precision
230236
<https://en.wikipedia.org/wiki/Loss_of_significance>`_\; the :func:`expm1`
231237
function provides a way to compute this quantity to full precision::
@@ -290,10 +296,10 @@ Power and logarithmic functions
290296

291297
Return the square root of *x*.
292298

299+
293300
Trigonometric functions
294301
-----------------------
295302

296-
297303
.. function:: acos(x)
298304

299305
Return the arc cosine of *x*, in radians.
@@ -339,10 +345,10 @@ Trigonometric functions
339345

340346
Return the tangent of *x* radians.
341347

348+
342349
Angular conversion
343350
------------------
344351

345-
346352
.. function:: degrees(x)
347353

348354
Convert angle *x* from radians to degrees.
@@ -352,6 +358,7 @@ Angular conversion
352358

353359
Convert angle *x* from degrees to radians.
354360

361+
355362
Hyperbolic functions
356363
--------------------
357364

@@ -440,23 +447,25 @@ Constants
440447

441448
.. data:: pi
442449

443-
The mathematical constant π = 3.141592..., to available precision.
450+
The mathematical constant *π* = 3.141592..., to available precision.
444451

445452

446453
.. data:: e
447454

448-
The mathematical constant e = 2.718281..., to available precision.
455+
The mathematical constant *e* = 2.718281..., to available precision.
456+
449457

450458
.. data:: tau
451459

452-
The mathematical constant τ = 6.283185..., to available precision.
453-
Tau is a circle constant equal to , the ratio of a circle's circumference to
460+
The mathematical constant *τ* = 6.283185..., to available precision.
461+
Tau is a circle constant equal to 2\ *π*, the ratio of a circle's circumference to
454462
its radius. To learn more about Tau, check out Vi Hart's video `Pi is (still)
455463
Wrong <https://www.youtube.com/watch?v=jG7vhMMXagQ>`_, and start celebrating
456464
`Tau day <http://tauday.com/>`_ by eating twice as much pie!
457465

458466
.. versionadded:: 3.6
459467

468+
460469
.. data:: inf
461470

462471
A floating-point positive infinity. (For negative infinity, use

Doc/whatsnew/3.6.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ return value.
908908
cmath
909909
-----
910910

911-
The new :const:`cmath.tau` (τ) constant has been added.
911+
The new :const:`cmath.tau` (*τ*) constant has been added.
912912
(Contributed by Lisa Roach in :issue:`12345`, see :pep:`628` for details.)
913913

914914
New constants: :const:`cmath.inf` and :const:`cmath.nan` to
@@ -1199,7 +1199,7 @@ be reopened.
11991199
math
12001200
----
12011201

1202-
The tau (τ) constant has been added to the :mod:`math` and :mod:`cmath`
1202+
The tau (*τ*) constant has been added to the :mod:`math` and :mod:`cmath`
12031203
modules.
12041204
(Contributed by Lisa Roach in :issue:`12345`, see :pep:`628` for details.)
12051205

0 commit comments

Comments
 (0)