Why This Matters
An exponential function has the variable in the exponent: f(x) = b^x. This seemingly small change from polynomial functions creates radically different behavior. Exponential growth doubles or triples repeatedly -- this is how viruses spread, compound interest accumulates, and algorithm running times explode when you have nested loops over all subsets. Exponential decay is the mirror image: radioactive elements halve their mass at regular intervals, cooling objects lose heat proportionally to their temperature difference, and learning curves flatten out over time.
If you have ever heard someone say "it grows exponentially," understanding these functions lets you know exactly what that means -- and why O(2^n) algorithms are practically unusable for large inputs.
Define Terms
Visual Model
The full process at a glance. Click Start tour to walk through each step.
Exponential functions grow or decay multiplicatively. The base determines whether the function grows (b greater than 1) or decays (b between 0 and 1).
Code Example
// Exponential growth: f(x) = 2^x
for (let x = 0; x <= 10; x++) {
console.log(`2^${x} = ${Math.pow(2, x)}`);
}
// Exponential decay: f(x) = (1/2)^x
for (let x = 0; x <= 10; x++) {
console.log(`(1/2)^${x} = ${Math.pow(0.5, x).toFixed(4)}`);
}
// Growth/decay model: A * b^t
function expModel(initial, rate, time) {
// rate is per-period growth rate (e.g., 0.05 for 5%)
const base = 1 + rate;
return initial * Math.pow(base, time);
}
// Compound interest: $1000 at 5% for 10 years
console.log("After 10 years:", expModel(1000, 0.05, 10).toFixed(2)); // 1628.89
// Radioactive decay: 100g with 10% decay per year
console.log("After 5 years:", expModel(100, -0.10, 5).toFixed(2)); // 59.05
// Compare exponential vs polynomial growth
for (let n = 1; n <= 20; n += 5) {
console.log(`n=${n}: n^3=${Math.pow(n,3)}, 2^n=${Math.pow(2,n)}`);
}
// Doubling time: how many periods to double?
function doublingTime(rate) {
return Math.log(2) / Math.log(1 + rate);
}
console.log("Doubling time at 5%:", doublingTime(0.05).toFixed(1), "periods");
console.log("Doubling time at 7%:", doublingTime(0.07).toFixed(1), "periods");Interactive Experiment
Try these exercises:
- Calculate 2^n for n = 10, 20, 30, 40, 50. How fast does the value grow?
- Compare n^2 and 2^n for n = 1 through 20. At what point does 2^n overtake n^2 permanently?
- Model a bank account with $500 initial deposit and 3% annual interest. How much after 20 years? 50 years?
- If a radioactive substance has a half-life of 5 years, what fraction remains after 15 years? Express as (1/2)^(t/5).
- Use the rule of 72: divide 72 by the interest rate percentage to estimate doubling time. Compare with the exact formula.
Quick Quiz
Coding Challenge
Write a function called `expModel` that takes an initial value, a rate (positive for growth, negative for decay), and a number of time periods, then returns the final value rounded to 2 decimal places. The formula is: result = initial * (1 + rate) ^ time.
Real-World Usage
Exponential functions model multiplicative processes across many fields:
- Algorithm complexity: O(2^n) algorithms like brute-force subset enumeration become infeasible quickly. For n = 30, there are over a billion subsets.
- Compound interest: Banks use A * (1 + r/n)^(nt) to calculate compound interest, a direct application of exponential growth.
- Epidemiology: Early-stage virus spread follows exponential growth: each infected person infects a fixed number of others.
- Machine learning: Gradient descent uses exponentially decaying learning rates. Softmax functions use e^x to convert values to probabilities.
- Radioactive decay: The half-life model N(t) = N_0 * (1/2)^(t/h) describes how unstable atoms decay over time.