This post is a reference to check that the whole content pipeline works: maths, code, charts and footnotes1.
The formula
Capital invested at annual rate , compounded times a year for years, is worth:
As , we get continuous compounding .
In code
def compound(c0: float, r: float, years: int, n: int = 12) -> float:
return c0 * (1 + r / n) ** (n * years)
print(round(compound(10_000, 0.07, 30), 2))
The curve
Figure 1 compares three rates over forty years. The gap looks modest at first, then widens: that is the exponential at work.
- 3%
- 5%
- 7%
Taking logarithms, : on a log scale each curve becomes a straight line of slope , as figure 2 shows.
- 3%
- 5%
- 7%
Orders of magnitude
| Duration | 1% | 3% | 5% | 7% | 10% |
|---|---|---|---|---|---|
| 10 years | 11,046 | 13,439 | 16,289 | 19,672 | 25,937 |
| 20 years | 12,202 | 18,061 | 26,533 | 38,697 | 67,275 |
| 30 years | 13,478 | 24,273 | 43,219 | 76,123 | 174,494 |
| 40 years | 14,889 | 32,620 | 70,400 | 149,745 | 452,593 |
Notes
-
Footnotes are supported natively by Markdown. ↩