Loan balance vs time  

principal or loan balance at  
Interest rate  
Loan term  
Loan product, important parameter which fully specifies a loan  
Repayment rate (dollars per time)  
Fraction of loan term  
Fraction of payment to interest  
Fraction of initial payment to interest;
like  
Total payment to interest  
Sum of all payments  
Overpay ratio 
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
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.
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] 
 \( = \)   \(  \) 
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\).
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 nondimensionalize 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.
Then substitute in \(\tau\).
This equation points toward a superior nondimensionalization 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.

or  

This general equation describes all loans in a collapsed, nondimensional 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).
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.
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\).
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.
We already solved for \(t_\text{term} \) above.
Find the overpay ratio by substituting \(t_\text{term}\).
Notice that \(\frac{rB_0}{P} = \phi_0\) is the expression for the fraction of the payment dedicated to paying interest at \(t=0\).
Set \(B=\) 0 and solve for the payment rate.
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.
Finally solve for the overpay ratio as a function of the loan product.
If you want to solve for the interest, \(I\), instead of the overpay ratio, simply subtract 1.