Continuous compounding is a limit
A yearly rate , written as a decimal, paid times a year grows $1 to in a year (case study 1.4.6). Continuous compounding is what this approaches as grows without end: a limit at infinity, as in lesson 2.1.3.
The limit has the shape lesson 2.1.3 warned about. The base tends to 1 while the power grows without end, and the result is neither 1 nor infinite. The two pulls balance at , just as .
Rule: Continuous compounding
The growth of $1 in a year, compounded more and more often, tends to . Over years the same limit gives .
At 5%, compounding more often climbs towards the continuous value , quickly at first and then slowly. On $1,000,000 the shortfall falls like about dollars.
Try it
SymPy computes the limit exactly for any positive rate , then the three-year version, .
n and r are declared positive so SymPy can simplify.
How fast is the limit reached?
The table shows the gap between continuous and -times-a-year compounding, at , per $1 over a year.
| 1 | 12 | 365 | 8760 | |
|---|---|---|---|---|
| gap | 0.0012711 | 0.00010920 | 0.0000036 | 0.00000015 |
| gap | 0.0012711 | 0.0013104 | 0.0013140 | 0.0013141 |
The gap is always positive: compounding times a year always falls short of continuous. The last row is the key. The gap times settles on a number, about 0.0013141: another limit at infinity.
So for large the gap is about . Compound ten times as often and the gap shrinks about ten times. That number is , which is 0.0013141 at 5%; lesson 2.7.2 shows where it comes from.
Rule: Size of the gap
For large the gap shrinks like , and it grows with the square of the rate.
Try it
The cell rebuilds the table and compares the last row with . The table rounds the outputs to 5 significant figures, and the two smallest gaps to 2.
The :.7g format shows 7 significant figures.
What it means in money
On $1,000,000 for a year at 5%, monthly compounding falls $109.20 short of continuous, and daily compounding $3.60 short. For most purposes daily and continuous compounding are interchangeable, which is why models use the simpler .
The gap grows with the horizon. Over 10 years, monthly compounding on $1,000,000 falls $1,711.77 short of continuous; over 30 years, $13,944.76. A pricing model that says "continuous" while the contract says "monthly" is off by that much.
Try it
The one-year shortfalls from the opening, then the 10- and 30-year shortfalls for monthly compounding, .
The loop finds the smallest that brings the one-year gap below one millionth per $1.
Try other rates and horizons. The gap on $1,000,000 shrinks as compounding gets more frequent, while gap settles; a higher rate or a longer horizon makes both bigger.
Explore
Compound more often and the growth climbs, but more and more slowly, towards continuous compounding, the dashed line. The axis for n is spaced by powers of 10.
- Compounded monthly
- (1 + 0.05/12)^(12 × 1) = 1.0511619
- Continuously
- e^(0.05 × 1) = 1.0512711
- Gap on $1,000,000.00
- $109.20
- Gap × n
- $1,310.38: it settles as n grows, so the gap shrinks like 1 ÷ n
What goes wrong in practice
The formula is simple; the inputs and the computer are where it fails.
Rates are decimals. Typing 5 for 5% gives continuously and monthly: growth factors no deposit could earn. A factor far from 1 for a one-year deposit means the rate went in as a percentage.
Zero and negative rates. At every convention gives exactly 1, and the gap is 0. Rates can also be negative: some central banks have set them below zero. The limit still holds, and the gap is still positive because is.
At , $1 shrinks to 0.99501248 continuously and to 0.99501144 monthly. Monthly compounding still ends lower, by $1.04 on $1,000,000. The formula does need : a loss of 100% or more in one period wipes out the balance.
Very large breaks the computer. The computer stores about 16 significant digits, so loses most of when is huge. Lesson 2.1.1 met the same trap, and here the results go wrong long before looks extreme:
| computed gap | 0.0014001 | about |
At the computed gap is negative, which is impossible. At , is stored as exactly 1, so the computed growth is 1: no interest at all.
Two habits avoid this. For continuous compounding, use math.exp(r * t) directly, never a huge . For a huge , write (lesson 1.4.3) and compute with math.log1p(z), which stays accurate for tiny .
Try it
For each the cell prints the gap times two ways: from (1 + r / n) ** n, then from math.log1p. The second gives 0.0013141 where the first fails.
At even the second gap prints 0: a gap of about is below what 16 digits can show. Use the estimate there. Lesson 2.8.1 returns to rounding.
How often is often enough?
Write two functions.
compounding_gap(r, n)returns .periods_needed(r, tol)returns the smallest whole withcompounding_gap(r, n) < tol. Counting up from 1 is fine.
The tests check the gap at a few rates, including zero and a negative rate. They also compare periods_needed with the estimate .
See the tests
import math
def test_annual_gap():
"""At 5% compounded once, the gap is e^0.05 − 1.05"""
expect_close(compounding_gap(0.05, 1), math.exp(0.05) - 1.05, what="compounding_gap(0.05, 1)")
def test_monthly_gap():
"""At 5% compounded monthly, the gap is about 0.0001092"""
expect_close(compounding_gap(0.05, 12), 0.00010919849429114059, what="compounding_gap(0.05, 12)", rel=1e-6)
def test_zero_rate():
"""At a zero rate every convention grows $1 to exactly $1, so the gap is 0"""
expect_close(compounding_gap(0.0, 12), 0.0, what="compounding_gap(0, 12)")
def test_negative_rate():
"""At −2%, monthly compounding still falls short of continuous, by about 0.00001635"""
expect_close(compounding_gap(-0.02, 12), math.exp(-0.02) - (1 - 0.02 / 12) ** 12, what="compounding_gap(-0.02, 12)", rel=1e-6)
assert compounding_gap(-0.02, 12) > 0, "the gap should be positive at a negative rate too"
def test_periods_for_one_millionth():
"""At 5%, 1315 periods bring the gap below one millionth"""
expect_equal(periods_needed(0.05, 1e-6), 1315, what="periods_needed(0.05, 1e-6)")
def test_smallest_n():
"""The answer is the smallest n: one period fewer is not enough"""
n = periods_needed(0.10, 1e-5)
assert compounding_gap(0.10, n) < 1e-5, f"gap at your n = {n} is not below 1e-5"
assert compounding_gap(0.10, n - 1) >= 1e-5, f"n − 1 = {n - 1} already works, so {n} is not the smallest"
def test_close_to_estimate():
"""The answer is close to the estimate r² e^r / (2 tol)"""
estimate = 0.10**2 * math.exp(0.10) / (2 * 1e-5)
n = periods_needed(0.10, 1e-5)
assert abs(n - estimate) / estimate < 0.01, f"expected about {estimate:.0f}, got {n}"
Summary card
- Continuous compounding is the limit , and over years . The base tends to 1, yet the limit is not 1.
- The gap to the limit is about : it shrinks like , and -times-a-year compounding always falls short, even at negative rates.
- Daily compounding is within a few dollars per million of continuous over a year; the gap grows with the horizon.
- Enter rates as decimals. Compute continuous growth with
math.exp, and for huge withmath.log1p; tiny gaps cannot be computed by subtraction.