diff --git a/Doc/library/cmath.rst b/Doc/library/cmath.rst index 28cd96b0e12da9..d2b88bf56dfea1 100644 --- a/Doc/library/cmath.rst +++ b/Doc/library/cmath.rst @@ -85,8 +85,7 @@ Power and logarithmic functions .. function:: exp(x) - Return *e* raised to the power *x*, where *e* is the base of natural - logarithms. + Return the exponential function at *x*. .. function:: log(x[, base]) diff --git a/Doc/library/math.rst b/Doc/library/math.rst index 797f32408eac3d..d73e4e30ffcc2c 100644 --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -364,9 +364,8 @@ Power and logarithmic functions .. function:: exp(x) - Return *e* raised to the power *x*, where *e* = 2.718281... is the base - of natural logarithms. This is usually more accurate than ``math.e ** x`` - or ``pow(math.e, x)``. + Return the exponential function at *x*. This is usually more accurate + than ``math.e ** x``. .. function:: exp2(x) @@ -378,9 +377,8 @@ Power and logarithmic functions .. function:: expm1(x) - Return *e* raised to the power *x*, minus 1. Here *e* is the base of natural - logarithms. For small floats *x*, the subtraction in ``exp(x) - 1`` - can result in a `significant loss of precision + Return ``exp(x) - 1``. For small floats *x*, the direct subtraction + in ``exp(x) - 1`` can result in a `significant loss of precision `_\; the :func:`expm1` function provides a way to compute this quantity to full precision: @@ -395,7 +393,7 @@ Power and logarithmic functions .. function:: log(x[, base]) - With one argument, return the natural logarithm of *x* (to base *e*). + With one argument, return the natural logarithm of *x*. With two arguments, return the logarithm of *x* to the given *base*, calculated as ``log(x)/log(base)``. @@ -403,7 +401,7 @@ Power and logarithmic functions .. function:: log1p(x) - Return the natural logarithm of *1+x* (base *e*). The + Return the natural logarithm of *1+x*. The result is calculated in a way which is accurate for *x* near zero. diff --git a/Modules/clinic/cmathmodule.c.h b/Modules/clinic/cmathmodule.c.h index b1da9452c61db8..217c0512312307 100644 --- a/Modules/clinic/cmathmodule.c.h +++ b/Modules/clinic/cmathmodule.c.h @@ -348,7 +348,7 @@ PyDoc_STRVAR(cmath_exp__doc__, "exp($module, z, /)\n" "--\n" "\n" -"Return the exponential value e**z."); +"Return the exponential function at z."); #define CMATH_EXP_METHODDEF \ {"exp", (PyCFunction)cmath_exp, METH_O, cmath_exp__doc__}, @@ -644,7 +644,7 @@ PyDoc_STRVAR(cmath_log__doc__, "\n" "log(z[, base]) -> the logarithm of z to the given base.\n" "\n" -"If the base not specified, returns the natural logarithm (base e) of z."); +"If the base not specified, returns the natural logarithm of z."); #define CMATH_LOG_METHODDEF \ {"log", _PyCFunction_CAST(cmath_log), METH_FASTCALL, cmath_log__doc__}, @@ -982,4 +982,4 @@ cmath_isclose(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=0146c656e67f5d5f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=c860b8fb26c5aff2 input=a9049054013a1b77]*/ diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h index 1f9725883b9820..f904ff7c14f51a 100644 --- a/Modules/clinic/mathmodule.c.h +++ b/Modules/clinic/mathmodule.c.h @@ -188,9 +188,7 @@ math_modf(PyObject *module, PyObject *arg) PyDoc_STRVAR(math_log__doc__, "log(x, [base=math.e])\n" -"Return the logarithm of x to the given base.\n" -"\n" -"If the base not specified, returns the natural logarithm (base e) of x."); +"Return the logarithm of x to the given base or the natural logarithm of x."); #define MATH_LOG_METHODDEF \ {"log", (PyCFunction)math_log, METH_VARARGS, math_log__doc__}, @@ -954,4 +952,4 @@ math_ulp(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=899211ec70e4506c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d4d52841fd827676 input=a9049054013a1b77]*/ diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 2038ac26e65857..bbc6c4e1dff55a 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -546,12 +546,12 @@ static Py_complex exp_special_values[7][7]; /*[clinic input] cmath.exp = cmath.acos -Return the exponential value e**z. +Return the exponential function at z. [clinic start generated code]*/ static Py_complex cmath_exp_impl(PyObject *module, Py_complex z) -/*[clinic end generated code: output=edcec61fb9dfda6c input=8b9e6cf8a92174c3]*/ +/*[clinic end generated code: output=edcec61fb9dfda6c input=87f2c74ee9a8ad46]*/ { Py_complex r; double l; @@ -957,12 +957,12 @@ cmath.log log(z[, base]) -> the logarithm of z to the given base. -If the base not specified, returns the natural logarithm (base e) of z. +If the base not specified, returns the natural logarithm of z. [clinic start generated code]*/ static PyObject * cmath_log_impl(PyObject *module, Py_complex x, PyObject *y_obj) -/*[clinic end generated code: output=4effdb7d258e0d94 input=230ed3a71ecd000a]*/ +/*[clinic end generated code: output=4effdb7d258e0d94 input=55c7d74ab7072229]*/ { Py_complex y; diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 544560e8322c72..d9c63c3ebbe456 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -1084,7 +1084,7 @@ FUNC1A(erfc, erfc, "Complementary error function at x.") FUNC1(exp, exp, 1, "exp($module, x, /)\n--\n\n" - "Return e raised to the power of x.") + "Return the exponential function at x.") FUNC1(exp2, exp2, 1, "exp2($module, x, /)\n--\n\n" "Return 2 raised to the power of x.") @@ -1143,7 +1143,7 @@ FUNC1A(lgamma, m_lgamma, "Natural logarithm of absolute value of Gamma function at x.") FUNC1(log1p, m_log1p, 0, "log1p($module, x, /)\n--\n\n" - "Return the natural logarithm of 1+x (base e).\n\n" + "Return the natural logarithm of 1+x.\n\n" "The result is computed in a way which is accurate for x near zero.") FUNC2(remainder, m_remainder, "remainder($module, x, y, /)\n--\n\n" @@ -2186,15 +2186,13 @@ math.log ] / -Return the logarithm of x to the given base. - -If the base not specified, returns the natural logarithm (base e) of x. +Return the logarithm of x to the given base or the natural logarithm of x. [clinic start generated code]*/ static PyObject * math_log_impl(PyObject *module, PyObject *x, int group_right_1, PyObject *base) -/*[clinic end generated code: output=7b5a39e526b73fc9 input=0f62d5726cbfebbd]*/ +/*[clinic end generated code: output=7b5a39e526b73fc9 input=e74bd6b80f8d66fd]*/ { PyObject *num, *den; PyObject *ans;