On this page
math.expm1
Prev: math.exp2 | Up: math | Next: math.fabs
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.expm1
Tags: #public #python3 #stdlib #math
Import
import math
from math import expm1
Signature & Overview
math.expm1(x, /)
Return exp(x)-1.
Usage
import math
x = 1e-10
assert math.isclose(math.expm1(x), x, rel_tol=1e-9)
Gotchas
- Avoids precision loss near zero:
math.exp(1e-15) - 1loses almost all significant digits, whereasmath.expm1(1e-15)stays accurate to full float precision.
REPL Inspect
from math import expm1
help(expm1)
Linked from
Related notes
- tuts/python3/stdlib_module/math/exp2 Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/fabs Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib