Course contentsShow
← JavaScript
Lesson 1607 of 2,72335. Standard Library and Built-insFree lesson

Math.exp and Exponential Growth

Compute e raised to a power using Math.exp, crucial for exponential growth and decay calculations.

Math.exp and Exponential Growth

You'll learn how to compute exponential values using Math.exp() for modeling growth and decay in real-world scenarios.

What is Math.exp()?

Math.exp(x) returns e raised to the power of x, where e (approximately 2.718) is Euler's number—the mathematical constant at the heart of exponential growth and decay. Think of it as the natural base for continuous growth, like compound interest calculated every instant or the spread of a viral post.

While you could write Math.E ** x or Math.pow(Math.E, x), Math.exp(x) is more precise and slightly faster because it's optimized for this specific calculation.

The Syntax

Math.exp(exponent)

Real-World Examples

// Basic usage
console.log(Math.exp(0));  // 1 (e^0)
console.log(Math.exp(1));  // 2.718... (e^1, which is e itself)
console.log(Math.exp(2));  // 7.389... (e^2)

// Population growth: P(t) = P₀ * e^(rt)
const initialPopulation = 1000;
const growthRate = 0.05; // 5% per year
const years = 10;
const futurePopulation = initialPopulation * Math.exp(growthRate * years);
console.log(futurePopulation); // ~1648.72

// Radioactive decay (negative exponent)
const halfLife = 5730; // Carbon-14 in years
const decayConstant = -Math.log(2) / halfLife;
const yearsElapsed = 1000;
const remaining = Math.exp(decayConstant * yearsElapsed);
console.log(remaining); // ~0.885 (88.5% remaining)

Why Use It?

Exponential functions model continuous compounding—whether it's money growing with interest, bacteria multiplying, or temperature cooling. Math.exp() is the inverse of Math.log(), making them perfect partners for solving exponential equations.

Key Takeaway: Use Math.exp(x) to compute e raised to any power, essential for calculating exponential growth, decay, and continuous compounding in scientific and financial applications.