Mathematics of Mortgage
Mortgage, Mathematics
\(\require{cancel}\) \(\def\oot{\frac{1}{2}}\)
Introduction
When I got my first mortgage, it looked a bit mysterious to me. I did watch a few YouTube videos about it, most of which claim to give you some hack to pay off your mortgage faster. “Pay it bi-weekly!” they say; as if it is a secret sauce. “Make sure you call your bank to tell them the extra payment goes to the principal!”
The mortgage math is actually quite simple. There is nothing secret about it. If you pay more, you will pay off your mortgage faster. And there is absolutely no difference between the principal and the interest. The only thing that matters is the amount you owe at any given time; and it gets a positive contribution from the interest and a negative contribution from your payments.
There are so many web calculators and Excel calculators you can use to compute the “$” value, and I won’t be creating a new number crunching tool here; in fact, there will be absolutely no numbers in this post. I would like to discuss a mathematical framework that can be used to understand the mortgage math and provide closed form expressions for the total interest paid over the life of the mortgage.
Exponential Growth
People use the term “exponential growth” a little too liberally. They will call simple quadratic growth “exponential growth” just because the rate increases. With mortgage, however, if you make no monthly payments, the loan will literally grow exponentially. The interest is proportional to the amount you owe, and it is added on top of the existing amount. Let’s call the total amount of money you owe at time \(t\) as \(\mathcal{M}(t)\). The interest is the amount of change in \(\mathcal{M}(t)\) at time \(t\), and when there is no payment, it is given by:
\[\begin{equation} \frac{d}{dt}\mathcal{M}(t) = r\mathcal{M}(t) \label{eq:exponential_growthde}. \end{equation}\] where \(r\) is the interest rate. It is easy to solve this differential equation to get the following expression: \[\begin{equation} \mathcal{M}(t) = \mathcal{M}_0 e^{rt} \label{eq:exponential_growth}, \end{equation}\] where \(\mathcal{M}_0\) is the initial loan amount.
Monthly payments
What keeps the loan from growing exponentially is the monthly payments; which we will denote as \(p\). With the constant payment, the correct differential equation becomes:
\[\begin{equation} \frac{d}{dt}\mathcal{M}(t) = r\mathcal{M}(t) - p \label{eq:exponential_growthdewithpayment}. \end{equation}\] Let’s stop for a moment to appreciate this equation. For the loan to reduce, the right hand side of the equation must be negative. This is only possible if the monthly payment \(p\) is larger than the interest at any given time. The interest is proportional to the amount you owe, which has its maximum value at the beginning of the loan. The payments typically are slightly larger than the interest at the beginning, and therefore the right hand side is barely negative initially. The initial payments are not making a big dent in the loan. We will look at this in more detail later. Let’s go back to the differential equation and solve it.
The fastest way to solve this differential equation is to absorb the constant term into \(\mathcal{M}(t)\) to get the following equation: \[\begin{equation} \frac{d}{dt}\left[\mathcal{M}(t)-\frac{p}{r}\right] = r\left[\mathcal{M}(t) - \frac{p}{r}\right] \label{eq:exponential_growthdewithpayment2}. \end{equation}\] where we inserted a constant into the derivative to make the terms look similar.
Let’s define a new variable \(\tilde{\mathcal{M}}(t) \equiv \mathcal{M}(t)-\frac{p}{r}\), which will make Eq. \(\ref{eq:exponential_growthdewithpayment2}\) identical to Eq. \(\ref{eq:exponential_growthde}\). Using the solution from Eq. \(\ref{eq:exponential_growth}\), and converting back to the original variable, we get the following expression: \[\begin{equation} \mathcal{M}(t) =\frac{p}{r}-\left[\frac{p}{r}-\mathcal{M}_0\right] e^{rt}=\frac{p}{r}\left[1-\left(1-\mathcal{M}_0\frac{r}{p}\right) e^{rt}\right] \label{eq:exponential_growthwithpayment}. \end{equation}\]
Mortgages are typically set for a given period of time, which will be denoted as \(T\). At \(t=T\), the loan is paid off if \(\mathcal{M}(T)=0.\) What would be the monthly payment \(p\) to pay off the loan at \(t=T\)? We can compute that by setting \(\mathcal{M}(T)=0\) in Eq. \(\ref{eq:exponential_growthwithpayment}\) and solving for \(p\):
\[\begin{equation} p = \mathcal{M}_0\frac{ r }{1-e^{-rT}} \label{eq:exponential_growthwithpayment_solve_p}. \end{equation}\]
The total amount of payments over the life of the loan is given by: \[\begin{equation} \mathcal{P} = pT=\mathcal{M}_0\frac{ r T }{1-e^{-rT}} \label{eq:exponential_growthwithpayment_total_payment}. \end{equation}\] Eq. \(\ref{eq:exponential_growthwithpayment_total_payment}\) is begging for a new definition: \(R\equiv\frac{\mathcal{P}}{\mathcal{M}_0}\), which is the total amount of payments over the life of the loan as a multiple of the initial loan amount:
\[\begin{equation} R\equiv\frac{ \mathcal{P} }{\mathcal{M}_0} = \frac{ r T }{1-e^{-rT}} \label{eq:exponential_growthwithpayment_total_payment_ratio}. \end{equation}\]
You can see that the dependence is always on the product \(r \,T\). We can do some back of the envelope calculations. When \(rT\ll 1\), we can do Taylor expansion to get:
\[\begin{equation} R\simeq 1 + \frac{rT}{2} \label{eq:exponential_growthwithpayment_total_payment_ratio_app1}. \end{equation}\] The \(1/2\) factor may be surprising at first glance. However, it is totally expected. When \(rT\ll 1\), either the payment time is very short or the interest rate is very low or both. This means the loan is dominated by the payments; i.e., it reduces linearly with time. Its average value is half of the initial loan amount; which is why we get \(1/2\) factor for the interest part.
But, gone are the days of the low interest rates. If you attempt to compute the ratio for realistic \(r\) values today, you need to use either the full expression, or include another term in the expansion.
\[\begin{equation} R \simeq 1 + \frac{rT}{2} + \frac{r^2T^2}{12} \label{eq:exponential_growthwithpayment_total_payment_ratio_app2}. \end{equation}\]
When \(rT\gg 1\), we can go to the opposite limit where we can drop the \(e^{-rT}\) term in the denominator completely:
\[\begin{equation} R\simeq rT \label{eq:exponential_growthwithpayment_total_payment_ratio_app3}. \end{equation}\]
The math should tell you that the 50 year mortgage discussion is such nonsense. I leave it to you to plug in the numbers and see for yourself.
Paying off the mortgage early
Mortgages are typically set for a fixed period of time. The lender will actually use Eq. \(\ref{eq:exponential_growthwithpayment_solve_p}\) to compute the monthly payment \(p\)1. However, no one is stopping you from paying more than the minimum amount. We can flip the equation around to treat the monthly payment \(p\) as an input and calculate the time it takes to pay off the loan.
\[\begin{equation} T = \frac{1}{r} \ln \left( \frac{1}{1 - \frac{r\mathcal{M}_0}{p}} \right) \label{eq:exponential_growthwithpayment_solve_t}. \end{equation}\]
Yes, that is the super secret that will be revealed to you by the Youtubers. Pay more, preferably early. Thank you, captain obvious.
We can also tell how the pay off time changes with the monthly payment. The change of the pay off time with respect to the payment is given by: \[\begin{equation} \frac{dT}{dp} = -\frac{1}{r} \frac{r\mathcal{M}_0}{p(p - r\mathcal{M}_0)} = -\frac{\mathcal{M}_0}{p(p - r\mathcal{M}_0)} \label{eq:exponential_growthwithpayment_solve_t_derivative}, \end{equation}\] which reduces to \(-\frac{\mathcal{M}_0}{p^2}=\frac{d}{dp}\left(\frac{\mathcal{M}_0}{p}\right)\) when \(p \gg r\mathcal{M}_0\), as expected.
Time dependent payment
So far we have assumed that the monthly payment \(p\) is constant. What if the payment is time-dependent, i.e., \(p(t)\)? The differential equation becomes:
\[\begin{equation} \frac{d}{dt}\mathcal{M}(t) = r\mathcal{M}(t) - p(t) \label{eq:exponential_growthdewithpayment_time}. \end{equation}\]
This is a first-order linear differential equation. We can solve it using the method of integrating factors. First, let’s rewrite the equation in the standard form:
\[\begin{equation} \frac{d}{dt}\mathcal{M}(t) - r\mathcal{M}(t) = -p(t) \label{eq:exponential_growthdewithpayment_time_standard}. \end{equation}\]
The integrating factor is given by \(\mu(t) = e^{-\int r \, dt} = e^{-rt}\). Multiplying both sides of Eq. \(\ref{eq:exponential_growthdewithpayment_time_standard}\) by the integrating factor:
\[\begin{equation} e^{-rt}\frac{d}{dt}\mathcal{M}(t) - r e^{-rt}\mathcal{M}(t) = -p(t) e^{-rt} \label{eq:exponential_growthdewithpayment_time_integrating}. \end{equation}\]
The left-hand side is now the derivative of \(\mathcal{M}(t) e^{-rt}\):
\[\begin{equation} \frac{d}{dt}\left[\mathcal{M}(t) e^{-rt}\right] = -p(t) e^{-rt} \label{eq:exponential_growthdewithpayment_time_derivative}. \end{equation}\]
Integrating both sides from \(0\) to \(t\):
\[\begin{equation} \mathcal{M}(t) e^{-rt} - \mathcal{M}_0 = -\int_0^t p(\tau) e^{-r\tau} \, d\tau \label{eq:exponential_growthdewithpayment_time_integrated}. \end{equation}\]
Solving for \(\mathcal{M}(t)\):
\[\begin{equation} \mathcal{M}(t) = \mathcal{M}_0 e^{rt} - e^{rt}\int_0^t p(\tau) e^{-r\tau} \, d\tau \label{eq:exponential_growthwithpayment_time}. \end{equation}\]
This is the general solution for the mortgage balance when payments are time-dependent. The first term represents the exponential growth of the initial loan amount, while the second term accounts for the accumulated effect of all payments up to time \(t\), each discounted by the exponential growth factor.
For the special case of constant payments \(p(t) = p\), we can evaluate the integral:
\[\begin{equation} \int_0^t p e^{-r\tau} \, d\tau = p \int_0^t e^{-r\tau} \, d\tau = \frac{p}{r}\left(1 - e^{-rt}\right) \label{eq:constant_payment_integral}. \end{equation}\]
Substituting this into Eq. \(\ref{eq:exponential_growthwithpayment_time}\):
\[\begin{eqnarray} \mathcal{M}(t) &=& \mathcal{M}_0 e^{rt} - e^{rt} \frac{p}{r}\left(1 - e^{-rt}\right) = \mathcal{M}_0 e^{rt} - \frac{p}{r}\left(e^{rt} - 1\right)\nonumber\\ &=& \frac{p}{r} + \left(\mathcal{M}_0 - \frac{p}{r}\right) e^{rt} \label{eq:exponential_growthwithpayment_time_constant}. \end{eqnarray}\]
This matches our earlier result in Eq. \(\ref{eq:exponential_growthwithpayment}\), confirming that the integrating factor method gives the correct solution.
Footnotes
There will be additional costs related to insurance and property taxes, but they don’t play into interest.↩︎