exponential

Math.exp

Returns e^x, where e is Euler's number (~2.71828). The inverse of Math.log (the natural logarithm).

Math.exp(x)

Parameters & edge cases

Case Behavior
x The exponent to raise e to
overflow Math.exp(710) returns Infinity — the double-precision ceiling
underflow Math.exp(-745) rounds to 0

Examples

console.log(Math.exp(0)); // 1

e^0 = 1.

console.log(Math.exp(1)); // 2.718281828459045

e^1 = Math.E.

console.log(Math.exp(2)); // 7.38905609893065

e² — used often in growth and softmax.

console.log(Math.exp(-1)); // 0.36787944117144233

1/e — for exponential decay.

Gotcha

For values near 0, use Math.expm1(x) instead of Math.exp(x) - 1 — the naive subtraction loses precision.

Related

← All JS Math methods · Array methods