""" Exercise A.4 from "A primer on... Solve a system of diff. eqs describing the evolution of a loan. """ import numpy as np import matplotlib.pyplot as plt N = 25 * 12 L = 5e6 p = 5.0 x = np.zeros(N+1) y = np.zeros(N+1) months = range(N + 1) x[0] = L for n in months[1:]: y[n] = p / (100 * 12) * x[n - 1] + L / N x[n] = x[n - 1] + p / (100 * 12) * x[n - 1] - y[n] #plt.plot(months, x) plt.plot(months, y) plt.show()