Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. Math
  6. expm1()

Math.expm1()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheMath.expm1() static method returnse raised to the power of a number, subtracted by 1. That is

𝙼𝚊𝚝𝚑.𝚎𝚡𝚙𝚖𝟷(𝚡)=ex1\mathtt{\operatorname{Math.expm1}(x)} = \mathrm{e}^x - 1

Try it

console.log(Math.expm1(0));// Expected output: 0console.log(Math.expm1(1));// Expected output: 1.718281828459045console.log(Math.expm1(-1));// Expected output: -0.6321205588285577console.log(Math.expm1(2));// Expected output: 6.38905609893065

Syntax

js
Math.expm1(x)

Parameters

x

A number.

Return value

A number representing ex - 1, where e isthe base of the natural logarithm.

Description

For very small values ofx, adding 1 can reduce or eliminate precision. The double floats used in JS give you about 15 digits of precision. 1 + 1e-15 = 1.000000000000001, but 1 + 1e-16 = 1.000000000000000 and therefore exactly 1.0 in that arithmetic, because digits past 15 are rounded off.

When you calculateex\mathrm{e}^x, where x is a number very close to 0, you should get an answer very close to 1 + x because:limx0ex1x=1\lim_{x \to 0} \frac{\mathrm{e}^x - 1}{x} = 1. If you calculateMath.exp(1.1111111111e-15) - 1, you should get an answer close to1.1111111111e-15. Instead, due to the highest significant figure in the result ofMath.exp being the units digit1, the final value ends up being1.1102230246251565e-15, with only 3 correct digits. If you calculateMath.expm1(1.1111111111e-15) instead, you will get a much more accurate answer,1.1111111111000007e-15, with 11 correct digits of precision.

Becauseexpm1() is a static method ofMath, you always use it asMath.expm1(), rather than as a method of aMath object you created (Math is not a constructor).

Examples

Using Math.expm1()

js
Math.expm1(-Infinity); // -1Math.expm1(-1); // -0.6321205588285577Math.expm1(-0); // -0Math.expm1(0); // 0Math.expm1(1); // 1.718281828459045Math.expm1(Infinity); // Infinity

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-math.expm1

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp