Math.E

Added in vES1 · Updated March 14, 2026 · Math
javascript math constants euler exponential

Math.E is a static property of the Math object that represents the base of natural logarithms, approximately 2.718281828459045. It is a read-only constant; you cannot change its value.

This irrational constant, known as Euler’s number, appears frequently in mathematics, particularly in calculus, compound interest calculations, and exponential growth or decay problems.

Syntax

Math.E

Value

Math.E; // 2.718281828459045

Examples

Basic Usage

console.log(Math.E);
// 2.718281828459045

Calculating Natural Logarithm

The natural logarithm of Math.E is always 1:

console.log(Math.log(Math.E));
// 1

Exponential Function

Math.exp(x) calculates e^x (e raised to the power of x):

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

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

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

Compound Interest Calculation

Math.E is useful for calculating continuously compounded interest:

function continuousCompound(principal, rate, time) {
  return principal * Math.exp(rate * time);
}

// $1000 at 5% continuously compounded for 10 years
console.log(continuousCompound(1000, 0.05, 10));
// 1648.7212707001282

// $500 at 3% continuously compounded for 5 years
console.log(continuousCompound(500, 0.03, 5));
// 580.4594377253751

Population Growth Model

Exponential growth using Euler’s number:

function populationGrowth(initial, growthRate, time) {
  return initial * Math.exp(growthRate * time);
}

// Start with 100, grow at 2% per time unit
console.log(populationGrowth(100, 0.02, 10));
// 122.14039680188982

console.log(populationGrowth(100, 0.02, 50));
// 271.8281828459045

Radioactive Decay

Exponential decay also uses Euler’s number:

function radioactiveDecay(initialAmount, halfLife, time) {
  const decayConstant = Math.log(2) / halfLife;
  return initialAmount * Math.exp(-decayConstant * time);
}

// 100g sample with 30 year half-life after 100 years
console.log(radioactiveDecay(100, 30, 100));
// 9.987321192567654e-2 (approximately 10% remaining)

Common Patterns

Euler’s Identity

One of the most famous equations in mathematics combines the five fundamental constants:

// e^(i*π) + 1 = 0
// This is Euler's identity, but JS can't directly compute complex numbers
// However, we can show the relationship:
console.log(Math.exp(Math.PI));
// 23.140692632779267 (e^π)

Scaling Values Using Exponential Functions

function normalizeExponential(value, min, max) {
  const range = max - min;
  const normalized = (value - min) / range;
  return min + range * Math.exp(normalized);
}

console.log(normalizeExponential(0, 1, 10));
// 2.718281828459045

console.log(normalizeExponential(0.5, 1, 10));
// 6.064943780316895

console.log(normalizeExponential(1, 1, 10));
// 10

Why Use Math.E?

Using Math.E instead of hardcoding 2.718281828459045 provides several advantages:

  1. Precision — The constant is defined to full floating-point precision
  2. Readability — Code clearly expresses the mathematical concept
  3. Standardization — Matches mathematical notation in formulas
  4. Performance — The value is computed once by the JavaScript engine

See Also

  • Math.exp() — returns e raised to the power of a number
  • Math.log() — returns the natural logarithm of a number
  • Math.pow() — returns the base to the exponent power