$$B(t) \quad \text{or} \quad B(\tau)$$ Loan balance vs time
$$B_0$$ principal or loan balance at $$t=0$$
$$r$$ Interest rate
$$t_\text{term}$$ Loan term
$$rt_\text{term}$$ Loan product, important parameter which fully specifies a loan
$$P$$ Repayment rate (dollars per time)
$$\tau$$ Fraction of loan term $$\tau= \frac{t}{t_\text{term}}$$
$$\phi$$ Fraction of payment to interest $$\phi = \frac{rB}{P}$$
$$\phi_0$$ Fraction of initial payment to interest; like $$rt_\text{term}$$, $$\phi_0$$ can be used to fully specify a loan$$\phi_0 = \frac{rB_0}{P}$$
$$I$$ Total payment to interest
$$V$$ Sum of all payments $$V = B_0+I$$
$$\frac{V}{B_0}$$ Overpay ratio $$\frac{V}{B_0} = \frac{B_0+I}{B_0}$$

Loans are a first order ordinary differential equation

The rich ruleth over the poor, and the borrower is servant to the lender. - Proverbs 22:7 King James Bible

Neither a borrower nor a lender be;

For the loan oft loses both itself and friend,

And borrowing dulls the edge of husbandry. - Lord Polonius, Act 1, Scene 3, Hamlet by William Shakespeare

The problem of loans

Loans are an interesting thing. In theory, the borrower is interested in two things, (1) the repayment rate which must be compatible with their cash flow, and (2) the amount of interest the loan issuer will charge which must not be so large that the borrower decides to forgo the loan altogether. The borrower is offered a loan based on 2 or 3 parameters where only 2 of the 3 are required to fully specify the loan. These are the interest rate, $$r$$, the loan term, $$t_\text{term}$$, and the repayment rate $$P/B_0$$. The problem of loans is generally in computing the amount of interest charged over the life of the loan or the overpay ratio, $$V/B_0$$, and whichever parameter of the three listed earlier is not given by the lender. In this article, we will show that the overpay ratio $$V/B_0$$, is a function of the loan product $$rt_\text{term}$$ but that the repayment rate $$P/B_0$$, is a function of $$r$$ and $$t_\text{term}$$ separately.

In practice, the borrower is often ignorant of all of the math presented here and simply accepts a loan for anything they have decided to finance through debt if a lender is willing to lend them the money at all. The marginally more informed understand that a higher interest rate loan will incur more interest and a longer loan term will reduce the monthly payments a bit but for even most "savvy" consumers, that is about the extent of understanding. Ignorance of the equations presented here leaves the borrower wandering through the financial system like a blind man feeling his way through a rattlesnake pit wondering what all the buzz is about and if perhaps it has anything to do with the considerable pain. The purpose of this series of articles is to show not just the relevant equations, but also the origins of the equations which govern loans thereby restoring the blind man's sight and leading him out of the snake pit.

The continuous solution

Classically trained engineers are well versed in setting up differential equations for the time rate of change of conserved quantities by using the following formula.

[Rate of change of x] $$=$$ [Sum of the rates of x growth] $$-$$ [Sum of the rates of x depletion]
[Rate of change of loan balance] $$=$$ [Interest] $$-$$ [Repayment rate]
$$\displaystyle \frac{\partial B}{\partial t}$$ $$=$$ $$rB$$ $$-$$ $$P$$

To find the balance on a loan, the quantity of x in the equation above is the loan balance $$B$$. The balance grows with interest over time, $$rB$$ where $$r$$ is in units of inverse time (usually % per year), and the balance is depleted by payments made by the borrower $$P$$.

\begin{align} \frac{\partial B}{\partial t} &= rB - P \\ \frac{1}{r} \int_{B_0}^{B} \frac{r\partial B}{ rB - P }& = \int_0^{t} \partial t \\ \log ( rB -P)-\log(rB_0-P) &= rt \\ B &= \left(B_0-\frac{P}{r}\right)e^{rt}+\frac{P}{r} \end{align}

While this equation does describe all loans with constant repayment rates, it would be cumbersome to plot and does not capture the problem succinctly. In this situation, engineers non-dimensionalize their equations meaning they try to express them as unitless ratios. The intuitive approach is to replace $$t$$ with $$\tau t_\text{term}$$ and divide by $$B_0$$ so the expression is for $$\frac{B(\tau)}{B_0}$$.

Begin by finding the repayment term by setting $$B=$$ 0.

$$rt_\text{term} = -\log\left(1-\frac{rB_0}{P}\right)$$

Then substitute in $$\tau$$.

\begin{align} \frac{B(t)}{B_0} &= \left(1-\frac{P}{rB_o}\right)e^{rt}+\frac{P}{rB_o}\\ \frac{B(\tau)}{B_0} &= \left(1-\frac{P}{rB_0}\right)e^{-\tau \log(1-\frac{rB_0}{P})}+\frac{P}{rB_0}\\ \frac{B(\tau)}{B_0} &= \frac{1-\frac{P}{rB_0}}{\left(1-\frac{rB_0}{P}\right)^{\tau}}+\frac{P}{rB_0} \end{align}

This equation points toward a superior non-dimensionalization strategy. If we multiply the above by $$\frac{rB_0}{P}$$ we will have an equation for $$\phi(\tau) = \frac{rB(\tau)}{P} = f(\tau,\phi_0)$$ which allows us to collapse all loans onto a single graph. $$\phi(t)$$ is a unitless ratio - the fraction of each loan payment put toward interest. $$\phi_0$$ is the fraction of the initial loan payment put toward interest at $$t=$$ 0 and like the loan product, $$rt_\text{term}$$, it fully specifies the loan. To convert between $$rt_\text{term}$$ and $$\phi_0$$ use the equations below.

$$\displaystyle rt_\text{term} = -\log\left(1-\phi_0\right)$$ or $$\displaystyle \phi_0= 1-e^{-rt_\text{term}}$$

\begin{align} \frac{B(\tau)}{B_0}\frac{rB_0}{P} &= \frac{rB_0}{P} \left[ \frac{1-\frac{P}{rB_0}}{\left(1-\frac{rB_0}{P}\right)^{\tau}}+\frac{P}{rB_0} \right]\\ \frac{rB(\tau)}{P} &= \frac{\frac{rB_0}{P}-1}{\left(1-\frac{rB_0}{P}\right)^{\tau}}+1\\ \phi(\tau) &= \frac{\phi_0-1}{\left(1-\phi_0\right)^{\tau}}+1\\\label{eq:phi} \phi(\tau) &= 1 - \frac{1-\phi_0}{(1-\phi_0)^{\tau}} \end{align}

This general equation describes all loans in a collapsed, non-dimensional form specified by either the loan product $$rt_\text{term}$$ or initial fraction of payment to interest $$\phi_0$$. Consider the visual carefully. The area above the curve is proportional to the amount borrowed while the area of the unit square is proportional to the total repaid on the loan. This is the overpay ratio, $$\frac{V}{B_0}$$. It is also worth pointing out that for $$rt_\text{term}>$$ 3, over 95% of the loan payment at the beginning of the term is paid to interest and therefore a small increase in repayment rate (say 5 or 10%) radically changes the overpay ratio (and has the added benefit of shortening the life of the loan). \begin{align}\frac{V}{B_0} &= \frac{B_0+I}{B_0} =\frac{rt_\text{term}}{1- e^{-rt_\text{term}}}\\ &= -\frac{1}{\phi_0} \log\left[ 1-\phi_0\right] \end{align}

Solving for useful loan parameters

Here we will consider the situation where one of the three loan parameters is unspecified (either $$r$$, $$t_\text{term}$$, or $$P/B_0$$), as is often the case since a loan has two degrees of freedom. We will solve for the missing parameter and the overpay ratio in each case.

Known $$\frac{P}{B_0}$$ and $$t_\text{term}$$

There is no succinct formula for $$r$$ as $$f\left( t_\text{term}, \frac{P}{B_0}\right)$$ using standard calculator functions. $$r$$ must usually be found numerically. There is a function called a Lambert W function which allows us to write a closed form expression for $$r$$ and it is available in scientific computing packages like SciPy. The Lambert W function $$W$$ is the inverse of $$f(x)=xe^x$$.

$$r = \frac{1}{t_\text{term}} W\left(-\frac{Pt_\text{term} e^{-Pt_\text{term} /B_0}}{B_0}\right) +\frac{P}{B_0}$$

The overpay ratio is the product of the two knowns since $$Pt_\text{term}$$ is the amount repaid, $$V$$, and $$B_0$$ is the amount borrowed.

$$\frac{V}{B_0} = \frac{P}{B_0}t_\text{term}$$

Known $$r$$ and $$\frac{P}{B_0}$$

We already solved for $$t_\text{term}$$ above.

$$t_\text{term} = -\frac{1}{r}\log\left(1-\frac{rB_0}{P}\right)$$

Find the overpay ratio by substituting $$t_\text{term}$$. $$\frac{V}{B_0} = \frac{P}{B_0}t_\text{term}=-\frac{P}{rB_0} \log\left(1-\frac{rB_0}{P}\right)$$

Notice that $$\frac{rB_0}{P} = \phi_0$$ is the expression for the fraction of the payment dedicated to paying interest at $$t=0$$.

$$\frac{V}{B_0} = -\frac{1}{\phi_0} \log\left[ 1-\phi_0\right]$$

Most common case - known $$r$$ and $$t_\text{term}$$

Set $$B=$$ 0 and solve for the payment rate.

$$\frac{P}{B_0} = \frac{r}{1- e^{-rt_\text{term}}}$$

Notice that the solution for $$P$$ has units of \$/time and that the time units will reflect whatever units are used for $$r$$. Usually $$r$$ is given in per year and we desire to compute $$P$$ per month. Therefore we will have to divide this result by 12 to account for the unit conversion.

$$P \left[\frac{{\}}{\text{year}}\right] = P \left[\frac{{\}}{\text{year}}\right] \left[\frac{\text{1 year}}{\text{12 month}}\right] = \frac{P}{12} \left[\frac{{\}}{\text{month}}\right]$$

Finally solve for the overpay ratio as a function of the loan product.

$$\frac{V}{B_0} = t_\text{term} \frac{P}{B_0} = \frac{rt_\text{term}}{1- e^{-rt_\text{term}}}$$

If you want to solve for the interest, $$I$$, instead of the overpay ratio, simply subtract 1.

$$\frac{I}{B_0} = \frac{I+B_0}{B_0}-\frac{B_0}{B_0} =\frac{V}{B_0}-1 = \frac{rt_\text{term}}{1- e^{-rt_\text{term}}}-1$$