JavaScript Math.expm1() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

Math.expm1(x) returns ex - 1. It gives a more accurate answer than Math.exp(x) - 1 when x is very close to zero.

Math is built into JavaScript. Call the method directly. It is not a constructor, so never write new Math().

Syntax

Call Math.expm1() like this. Start with this line.

JavaScript
Math.expm1(x)
CallWhat it does
Math.expm1(x)Returns e^x - 1.

Built into JavaScript. Call Math.expm1() on the Math object — no import required.

Library declarations
JavaScript
Math.expm1(x)
JavaScript
interface Math {
  expm1(x: number): number;
}

Parameters

ParameterDescription
xRequired. A number. Other values are converted to a number first.

Return Value

Return ValueDescription
numberThe value of e^x - 1. Returns NaN if x cannot be turned into a number.

JavaScript Examples

Example 1 — Basic Use

The result is e^x - 1.

JavaScript
console.log(Math.expm1(0));    // 0
console.log(Math.expm1(1));    // 1.718281828459045
console.log(Math.expm1(-1));   // -0.6321205588285577
console.log(Math.expm1(2));    // 6.38905609893065
Try It Yourself

How It Works

  1. Zero. e^0 - 1 is 0.
  2. One. e - 1 is about 1.7183.
  3. Negative. For negative inputs the result is between -1 and 0.

Example 2 — Precision for Tiny Numbers

Watch how Math.exp(x) - 1 loses digits when x is very small.

JavaScript
var tiny = 1e-10;

console.log(Math.exp(tiny) - 1);  // 1.000000082740371e-10
console.log(Math.expm1(tiny));    // 1.00000000005e-10
Try It Yourself

How It Works

  1. Tiny x. 1e-10 is 0.0000000001.
  2. Subtraction loses digits. Math.exp(tiny) is 1.0000000001.... Subtracting 1 leaves only a few correct digits.
  3. expm1 is exact. Math.expm1(tiny) returns almost exactly 1e-10.

Example 3 — Small Growth Rate

Find the real percent growth for a small continuous rate.

JavaScript
var rate = 0.02;  // 2% continuous rate

var growth = Math.expm1(rate);
console.log(growth);                       // 0.02020134002675581
console.log((growth * 100).toFixed(4) + "%");  // 2.0201%
Try It Yourself

How It Works

  1. Rate. A continuous rate of 0.02.
  2. Real growth. Math.expm1(0.02) is the growth fraction, slightly above 0.02.
  3. Percent. Multiply by 100 and add %.

Browser & Runtime Support

Math.expm1() is part of ES2015 and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · ES2015

Math.expm1()

Supported in Chrome, Firefox, Safari, Edge, and Node.js for years. Safe for modern apps without a polyfill.

98% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Math.expm1 Excellent

Bottom line: Use Math.expm1() in new code. Only very old browsers, like Internet Explorer, lack it.

Frequently Asked Questions

Math.expm1(x) returns e^x - 1. The name means "exp minus 1". Math.expm1(0) is 0.
For very small x, Math.exp(x) is almost 1, and subtracting 1 loses precision. Math.expm1(x) stays accurate.
Math.log1p(). It returns the natural log of 1 + x.
It returns 0, because e^0 is 1 and 1 - 1 is 0.
It was added in ES2015 and works in all modern browsers and Node.js.

Next: f16round()

Learn how to round to the nearest 16-bit float.

f16round() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful