Table of Contents

Mortgage Calculator

Many online mortgage calculators like calculate the monthly payments required given:

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:

Results

The first two “results” in the summary on the right are pretty standard:

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:

So in that example:

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:

Click to display ⇲

Click to hide ⇱

Imagine we want to add the following: $$ S = a^{n-1} + a^{n-2} + \cdots + a^{2} + a + 1 $$

The trick is to multiply all of this by $a$ and then subtract the original. Here's what I mean: $$ aS = a^{n} + a^{n-1} + \cdots + a^{3} + a^2 + a $$

So: $$aS - S = a^n - 1 $$

See, all the terms in the middle cancelled out so we're left with $a^n$ from $aS$ and $1$ from $S$. Now, we solve for $S$:

$$ S = \frac{a^n - 1}{a - 1} $$

So, going back to $Q_n$, all we need to do is say that $ a = \left( 1 + \frac{r}{12} \right) $. So we get:

\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:

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}$ .