Plotting Compound Interest Part 2
If we wanted an easy way to compute the interest earned each year we could break down the formula. Interest earned would be:
$ I_{t} = A_{t} – A_{t-1} $
$ I_{t} = P * (1+r)^t – P * (1+r)^{t-1}$
In [9]:
years = list(range(1,31))
I = [compoundInterest(p,r,t) - compoundInterest(p,r,t-1) for t in years]
print(I)
In [10]:
import matplotlib.pyplot as plt
plt.plot(years,I)
plt.xlabel("Year")
plt.ylabel("Interest")
plt.title("Compound Interest Payments")
plt.show()
In [11]:
print(A[:-1])
print()
print(A[1:])
In [12]:
I = [a-b for a,b in zip(A[1:], A[:-1])]
print(I)