Compound Interest


Tags: finance
Reading time: about 7 minutes

Compound interest is keeping the earned interest in the same account that earns interest. Instead of earning interest and moving it to another account to be used, compound interest is re-investing the interest.

In [2]:
YEARLY_INTEREST = 14 / 100 # 14%
STARTING_BALANCE = 50_000
MONTHS = 48

MONTHLY_INTEREST = YEARLY_INTEREST / 12

Simple interest

Before we explain compound interest, let’s first talk about non-compound or simple interest. Simple interest is calculated using the starting balance. Any interest earnings do not contribute to future earnings. This makes it easy to calculate and reason about. Let’s draw a plot of our earnings per month.

In [3]:
graph = []

for _ in range(MONTHS):
    gain = STARTING_BALANCE * MONTHLY_INTEREST
    graph.append(gain)

plt.xlabel('Month')
plt.ylabel('Monthly gain ($)')
plt.plot(graph)
plt.show()
Out:
<Figure size 720x480 with 1 Axes>

As expected, our earnings are constant every month. If we plot our total earnings, we should see a linear plot.

In [4]:
graph = []

totalGain = 0

for _ in range(MONTHS):
    totalGain += STARTING_BALANCE * MONTHLY_INTEREST
    graph.append(totalGain)

plt.xlabel('Month')
plt.ylabel('Total gain ($)')
plt.plot(graph)
plt.show()
Out:
<Figure size 720x480 with 1 Axes>

Compound interest

Let’s do the same calculations for compount interest. Instead of calculating the gain from the starting balance, we will use the current balance with all the earnings so far.

In [5]:
balance = STARTING_BALANCE

graph = []

for _ in range(MONTHS):
    gain = balance * MONTHLY_INTEREST
    balance += gain
    graph.append(gain)

plt.plot(graph)
plt.xlabel('Month')
plt.ylabel('Monthly gain ($)')
plt.show()
Out:
<Figure size 720x480 with 1 Axes>
In [6]:
balance = STARTING_BALANCE

graph = []

for _ in range(MONTHS):
    balance += balance * MONTHLY_INTEREST
    graph.append(balance - STARTING_BALANCE)

plt.plot(graph)
plt.xlabel('Month')
plt.ylabel('Total gain ($)')
plt.show()
Out:
<Figure size 720x480 with 1 Axes>

Comparing the results

Let’s make a single graph that compares the total gain over time for the two types of interest we just talked about.

In [7]:
# Simple
graph = []
totalGain = 0

for _ in range(MONTHS):
    totalGain += STARTING_BALANCE * MONTHLY_INTEREST
    graph.append(totalGain)
plt.plot(graph, label="Simple")

# Compound

balance = STARTING_BALANCE
graph = []

for _ in range(MONTHS):
    balance += balance * MONTHLY_INTEREST
    graph.append(balance - STARTING_BALANCE)
plt.plot(graph, label='Compound')

# Draw
plt.legend()
plt.xlabel('Month')
plt.ylabel('Total gain ($)')
plt.show()
Out:
<Figure size 720x480 with 1 Axes>

As we can see, our balance ends up being higher if we compound our interest. Let’s see how just how much money we’re leaving on the table.

In [8]:
print("Month\tNon-compound\tCompound\tDifference")

noncomp = STARTING_BALANCE
comp = STARTING_BALANCE

for month in range(1, MONTHS + 1):
    comp += comp * MONTHLY_INTEREST
    noncomp += STARTING_BALANCE * MONTHLY_INTEREST
    difference = (comp - noncomp) / noncomp * 100
    print(f"{month}\t{noncomp:.2f}\t{comp:.2f}\t{difference:.2f}%")
Out:
Month	Non-compound	Compound	Difference
1	50583.33	50583.33	0.00%
2	51166.67	51173.47	0.01%
3	51750.00	51770.50	0.04%
4	52333.33	52374.49	0.08%
5	52916.67	52985.52	0.13%
6	53500.00	53603.69	0.19%
7	54083.33	54229.06	0.27%
8	54666.67	54861.73	0.36%
9	55250.00	55501.79	0.46%
10	55833.33	56149.31	0.57%
11	56416.67	56804.38	0.69%
12	57000.00	57467.10	0.82%
13	57583.33	58137.55	0.96%
14	58166.67	58815.82	1.12%
15	58750.00	59502.01	1.28%
16	59333.33	60196.20	1.45%
17	59916.67	60898.49	1.64%
18	60500.00	61608.97	1.83%
19	61083.33	62327.74	2.04%
20	61666.67	63054.90	2.25%
21	62250.00	63790.54	2.47%
22	62833.33	64534.76	2.71%
23	63416.67	65287.67	2.95%
24	64000.00	66049.36	3.20%
25	64583.33	66819.93	3.46%
26	65166.67	67599.50	3.73%
27	65750.00	68388.16	4.01%
28	66333.33	69186.02	4.30%
29	66916.67	69993.19	4.60%
30	67500.00	70809.78	4.90%
31	68083.33	71635.89	5.22%
32	68666.67	72471.64	5.54%
33	69250.00	73317.15	5.87%
34	69833.33	74172.51	6.21%
35	70416.67	75037.86	6.56%
36	71000.00	75913.30	6.92%
37	71583.33	76798.95	7.29%
38	72166.67	77694.94	7.66%
39	72750.00	78601.38	8.04%
40	73333.33	79518.40	8.43%
41	73916.67	80446.11	8.83%
42	74500.00	81384.65	9.24%
43	75083.33	82334.14	9.66%
44	75666.67	83294.71	10.08%
45	76250.00	84266.48	10.51%
46	76833.33	85249.59	10.95%
47	77416.67	86244.16	11.40%
48	78000.00	87250.35	11.86%

The following pages link here

Citation

If you find this work useful, please cite it as:
@article{yaltirakliwikicompoundinterest,
  title   = "Compound Interest",
  author  = "Yaltirakli, Gokberk",
  journal = "gkbrk.com",
  year    = "2024",
  url     = "https://www.gkbrk.com/wiki/compound-interest/"
}
Not using BibTeX? Click here for more citation styles.
IEEE Citation
Gokberk Yaltirakli, "Compound Interest", November, 2024. [Online]. Available: https://www.gkbrk.com/wiki/compound-interest/. [Accessed Nov. 12, 2024].
APA Style
Yaltirakli, G. (2024, November 12). Compound Interest. https://www.gkbrk.com/wiki/compound-interest/
Bluebook Style
Gokberk Yaltirakli, Compound Interest, GKBRK.COM (Nov. 12, 2024), https://www.gkbrk.com/wiki/compound-interest/

Comments

© 2024 Gokberk Yaltirakli