Every financial instrument in existence is built on one formula. Central banks use it to set policy. Banks use it to price loans. Pension funds use it to project returns. Most people who interact with it daily couldn’t derive it. Let’s fix that.
The formula
The discrete compounding formula — for interest applied n times per year:
A = P * (1 + r/n)^(n*t)Where:
P= principal (initial amount)r= nominal annual rate (as a decimal)n= compounding frequency per yeart= time in yearsA= final amount
As n → ∞ (compounding infinitely often — continuously):
A = P * e^(r*t)This follows from the definition of e: lim(n→∞) (1 + r/n)^n = e^r. The same e that appears everywhere in calculus, probability, and information theory. Compound interest is why e exists.
The gap between annual and continuous compounding shrinks as the rate increases. The dashed gold line is real purchasing power after 3% annual inflation — what your money actually buys.
What the tabs show you
Growth curves: Four lines — annual, monthly, continuous, and real (inflation-adjusted continuous). The gap between annual and continuous is the effective annual rate: e^r - 1. At 7% nominal, effective = 7.251%. At 15%, effective = 16.183%. The difference compounds itself.
Compounding frequency: Same rate, same time — different n. The surprise: the jump from annual to monthly matters far more than the jump from monthly to continuous. Going from n=1 to n=12 captures most of the benefit. Going from n=12 to n=∞ adds barely anything at typical rates.
Rule of 72 & math: The Rule of 72 estimates doubling time as 72 / r%. It’s derived from t = ln(2) / ln(1+r) ≈ 0.693/r for small r, with 72 chosen (instead of the mathematically exact 69.3) because it has more integer factors (convenient for mental math).
The Fisher equation: what your money actually buys
Nominal returns are lies. The real return — what your purchasing power actually grows by — follows the Fisher equation:
1 + r_real = (1 + r_nominal) / (1 + π)Where π is inflation. The approximation r_real ≈ r_nom - π (which you see in introductory finance) has an error of about r_nom × π — negligible at 1-2% inflation, meaningful at 5-10%.
Try setting inflation to 8% (2022-level in Europe) and nominal return to 2% (typical savings account). The real return is negative: your money in the bank was purchasing-power-negative. The tool shows you exactly how much wealth was destroyed.
The software engineering angle
Compound interest is the simplest recursive function:
def compound(P: float, r: float, n: int, t: int) -> float: """Discrete: A = P * (1 + r/n)^(n*t)""" return P * ((1 + r/n) ** (n * t))
# Continuous: special case as n → ∞import mathdef compound_continuous(P: float, r: float, t: int) -> float: return P * math.exp(r * t)The continuous case collapses to a single exp() call. In financial systems, this is used for:
- Bond pricing: discount factors
e^(-rt)whereris the risk-free rate - Stock price modelling (GBM):
S(t) = S(0) * e^((r - σ²/2)*t + σ*√t*Z)— the geometric Brownian motion underlying Black-Scholes - Interest rate swaps: present value of floating-rate cash flows
- Loan amortization: monthly payment derivation requires solving
P = C * (1-(1+r_m)^(-N))/r_mforC(wherer_m= monthly rate =r/12,N= total number of payments)
Understanding the derivation — especially the limit lim(n→∞)(1+r/n)^n = e^r — makes these formulas feel obvious rather than magical. They’re all the same idea, parameterized differently.
The brutal truth about inflation
The chart makes this visceral. At 7% nominal return and 3% inflation over 30 years:
- Nominal: ~$76,000 on a $10,000 investment
- Real: ~$40,500 in today’s purchasing power
Inflation silently erodes ~47% of your nominal gains. The goal isn’t to maximize A — it’s to maximize A / P_inflation(t), the real value. This is why central banks targeting 2% inflation (not 0%) is a deliberate policy choice, not an oversight.
For the DeFi connection — how AMMs and yield farming interact with real interest rates — see the series starting with UniswapV2 math.