Table of Contents
Mortgage Calculator
Many online mortgage calculators like calculate the monthly payments required given:
- the loan amount (ex. $200,000)
- the time you'll take to pay it off (ex. 20 years)
- the interest rate (ex. 3.5%)
Which, here, would be $1,159.92 a month.
Instead of typing different inputs (loan amount, time to pay, interest rates) to see the different results one at a time, I wanted to see how changing these inputs gradually would affect the results.
More importantly, I wanted to see how much interest I would end up paying the bank in the end, which, oddly enough, is not something many online calculators really tell you.
So I went and made my own mortgage calculator using Geogebra.
Geogebra Instructions:
- Click on the image to load the GeoGebra Applet.
- If you see an empty rectangle, click in the center to start the applet.
- To use it, simply drag the dots (in green) in the applet and look at the results summary (in blue).
Results
The first two “results” in the summary on the right are pretty standard:
- There's the time to pay, which is an input variable, not a result, and
- the monthly payment, which can be calculated using the cool math shown below.
The last results are essentially all saying the same thing different ways: How much interest will I end up paying the bank on top of the initial loan:
- as a percentage of the loan
- as a total amount of money
- as a total number of years making payments only on the interest
So in that example:
- I'd be paying 39% of $200,000 in interest
- which is $78,381
- which is the same as if, for 5.6 years, my entire monthly payments were only going towards paying the interest. Which means that only about 14.4 years (of the 20) are spent repaying the actual $200,000 I borrowed.
Sliding the time down lowers this interest (which is why it's good to pay your debt quickly), but realistically, it also raises the monthly payments. So as with all real life problems, it's a trade off.
The function that governs the “Relative Interest Paid” curve is somewhat complex, however, its linear approximation is not. It turns out that the interest paid can be approximated using: $y = \frac{r}{2}\cdot t$ . Which means that for every extra year that I take to pay my mortgage, I'll pay the bank an extra $\frac{r}{2}$ of the amount I borrowed. In this example, it amounts to an extra $3500 of interest per extra year; another example of why it's better to pay your debt quickly.
If you're curious about the math behind all of this, read on…
Under the Hood
Amount Left to Pay
Imagine that we borrow the total amount $P$ from the bank (that's the $200,000 in the above example). We'll now track the amount $Q$ we owe the bank after each month.
At the beginning, we owe:
\begin{align*} Q_0 &= P \end{align*}
If the interest is compounded monthly, after a month, we need to add one twelfth of the interest $r$ to $Q_0$ and subtract our monthly payment $x$. So we'll owe:
\begin{align*} Q_1 &= Q_0 \left( 1 + \frac{r}{12} \right) - x && \text{Add interest and subtract payment.}\\ &= P \left( 1 + \frac{r}{12} \right) - x && \text{Substitute } Q_0 \text{ with above.}\\ \end{align*}
After two months, we again need to add one twelfth of the interest $r$ to $Q_1$ and subtract our monthly payment $x$. So we'll owe:
\begin{align*} Q_2 &= Q_1 \left( 1 + \frac{r}{12} \right) - x && \text{Same idea as above.} \\ &= \left[P \left( 1 + \frac{r}{12} \right) - x\right] \left( 1 + \frac{r}{12} \right) - x && \text{Substitute } Q_1 \text{ with above.} \\ &= P \left( 1 + \frac{r}{12} \right)^2 - x \left( 1 + \frac{r}{12} \right) - x && \text{Distribute.} \\ \end{align*}
After three months, … Ok, by now we get the idea:
\begin{align*} Q_3 &= Q_2 \left( 1 + \frac{r}{12} \right) - x && \text{Same idea as above.} \\ &= \left[ P \left( 1 + \frac{r}{12} \right)^2 - x \left( 1 + \frac{r}{12} \right) - x \right ] \left( 1 + \frac{r}{12} \right) - x && \text{Substitute } Q_2 \text{ with above.} \\ &= P \left( 1 + \frac{r}{12} \right)^3 - x \left( 1 + \frac{r}{12} \right)^2 - x \left( 1 + \frac{r}{12} \right)- x && \text{Distribute.} \\ &= P \left( 1 + \frac{r}{12} \right)^3 - x \left[ \left( 1 + \frac{r}{12} \right)^2 + \left( 1 + \frac{r}{12} \right) + 1 \right] && \text{Factor out the } x\\ \end{align*}
At this point, we see enough of a pattern to infer that after the $n^\text{th}$ month, we'll owe:
\begin{align*} Q_n &= P \left( 1 + \frac{r}{12} \right)^n - x \left[ \left( 1 + \frac{r}{12} \right)^{n-1} + \left( 1 + \frac{r}{12} \right)^{n-2} + \cdots + \left( 1 + \frac{r}{12} \right)^{2} + \left( 1 + \frac{r}{12} \right) + 1 \right]\\ \end{align*}
Turns out that we can simplify this even more. To see how click below:
\begin{align*} Q_n &= P \left( 1 + \frac{r}{12} \right)^n - x \frac{ \left( 1 + \frac{r}{12} \right)^{n} - 1}{\left( 1 + \frac{r}{12} \right) - 1}\\ &= P \left( 1 + \frac{r}{12} \right)^n - \frac{12}{r} x \left[ \left( 1 + \frac{r}{12} \right)^{n} - 1 \right]\\ \end{align*}
There we go. Now, we know how much we have left to pay after $n$ months of making payments of $x$. But the real question we have is:
What payments $x$ do I need if I want to finish paying my mortgage after a certain time?
Monthly Payments Required
To answer that question, let $Q_n = 0$ (since we want to finish paying), and solve for $x$:
\begin{align*} &0 = P \left( 1 + \frac{r}{12} \right)^n - \frac{12}{r} x \left[ \left( 1 + \frac{r}{12} \right)^{n} - 1 \right]\\ \Rightarrow &\frac{12}{r} x \left[ \left( 1 + \frac{r}{12} \right)^{n} - 1 \right] = P \left( 1 + \frac{r}{12} \right)^n \\ \Rightarrow &x = P \frac{r}{12} \cdot \frac{ \left( 1 + \frac{r}{12} \right)^n}{\left( 1 + \frac{r}{12} \right)^{n} - 1 } \\ & \quad = P \frac{r}{12} \cdot \frac{1}{1 - \left( 1 + \frac{r}{12} \right)^{-n} } \\ & \quad = P \frac{r}{12} \cdot \frac{1}{1 - \left( 1 + \frac{r}{12} \right)^{-12t} } \\ \end{align*}
In the last step, we simply use $t$ in years instead of $n$ in months. Let's try it. If:
- $ P = 200000 $
- $ r = 0.035 $
- $ t = 20 $
We get:
\begin{align*} x & = 200000 \frac{0.035}{12} \cdot \frac{1}{1 - \left( 1 + \frac{0.035}{12} \right)^{-12\cdot 20} } \\ & \approx 200000 \frac{0.035}{12} \cdot 1.9884317 \\ & \approx 1159.92 \end{align*}
Relative Interest Paid Function
Now, onto the important part: how much interest am I paying the bank?
The interest paid, $I$, is simply (the total paid) – (the loan), which is:
$$ I = 12t \cdot x - P $$
Recall that $12 t$ is the number of months (or number of payments) and $x$ is the monthly payments.
Because I like percentages, I'll calculate the interest paid relative to the amount borrowed:
\begin{align*} \frac{I}{P} & =\frac{1}{P} \left( 12t \cdot x - P \right) & \text{and substituting } x \text{ from above} \\ & =\frac{1}{P} \left [12t \cdot \left( P \frac{r}{12} \cdot \frac{1}{1 - \left( 1 + \frac{r}{12} \right)^{-12t} } \right) - P \right] \\ & = \frac{rt}{1 - \left( 1 + \frac{r}{12} \right)^{-12t} } - 1 \\ \end{align*}
This is the function of t that is graphed in the Geogebra applet, and interestingly enough, its linear approximation is simply $ \frac{I}{P} \approx \frac{r}{2} \cdot t$ , which is a straight line with a slope of $\frac{r}{2}$ .

