math.expm1

Full name
math.expm1
Library
math
Syntax

math.expm1(x)

Description

The math.expm1 function returns the number e (2.718281...) raised to the power indicated as an argument after subtracting 1 from the result obtained.

As indicated in the Python documentation, for small values of x the result obtained by math.expm1(x) is much more accurate than that obtained by math.exp(x) -1.

Parameters
  • x: Power to raise the number e. The function will return that result minus 1.
Result

The math.expm1 function returns a real number.

Examples

We can calculate (e ** 2) -1 with the following code:

math.expm1(2)

6.38905609893065

For the value of x in the previous example, we can verify that the result of the math.expm1 function is equivalent to that obtained using the math.exp function (and subtracting 1) with the following code:

math.isclose(math.expm1(2), math.exp(2) -1)

True

Submitted by admin on Fri, 01/29/2021 - 16:07