Python math.expm1() Method

Python math 模块Python math Module

Python math.expm1(x)The method returns e raised to the power of x minus 1,Ex - 1, where e = 2.718281... is the base of the natural logarithm.

math.expm1(x)The method is more precise than callingmath.exp()subtracting 1.

Python Version: 2.7

Syntax

The syntax of the math.expm1() method is as follows:

math.expm1(x)

Parameter Description:

  • xx -- Required, a number, specifies the exponent. If x is not a number, returns TypeError.

Return Value

A floating-point value, representing Ex - 1。

Example

The following example specifies different exponents:

Example

# Import the math package
import math

# Specify different exponents
print(math.expm1(32))
print(math.expm1(-10.89))

Output result:

78962960182679.69
-0.9999813562576685

Python math 模块Python math Module

Other Extensions