Mortgage math

What’s the monthly payment on a $360,000 mortgage, at an interest rate of 3%, to be repaid over 30 years?

Just let me quickly have a Google…

No! What’s the fun in that? Let’s re-derive the formulas from scratch. We will, in the end, reach this conclusion:

p = \frac{L\cdot r}{1-\frac{1}{(1+r)^n}}

Although this post talks about a mortgage, this formula applies to any fixed-rate installment loans, such as a car loan or a purchase through Affirm.

Note: This is not a money blog. None of this is financial advice. This post will touch on a few minor financial topics, but only to clarify the math.

Principal and Interest

For most mortgages, interest does not compound. Let me say that again: mortgage interest does not compound. Unless your mortgage has a “negative amortization feature” (which, in the US, would be clearly indicated on page 4 of your Closing Disclosure), your monthly payment will cover the entirety of interest accrued in that month.

If you have an interest-only mortgage, then that’s all you have to pay on a monthly basis, but you’ll never pay off your loan. If you want to be debt-free at some point, then your monthly payment will also include some principal. This is the portion of the payment that lowers your balance (i.e. money owed to the bank).

With each payment, your balance goes down a little, which means you’ll pay a little less in interest the next month. Typically, your total payment will stay the same, which means a smaller and smaller portion of your payment will go toward interest, and a larger and larger portion will go toward principal. On a 30-year mortgage, the last payment will be 99% principal.

The math is a little bit tricky, so let’s first look at a simpler case.

Equal Principal Payment

We chose $360,000 as the mortgage amount to make the math easier. This might be a lot or not much at all depending on where you are and when you’re reading this. Side note: this is the money you’re borrowing, outside of down payment and all other fees.

Instead of keeping the total payment the same from month to month, let’s make the principal payment equal. If the mortgage lasts 30 years (i.e. 360 months), then we should be paying $1,000 in principal each month. This is what the payment schedule would look like:

MonthBalance Before PaymentPrincipalInterestTotal PaymentBalance After Payment
1$360,000$1,000360x$1,000 + 360x$359,000
2$359,000$1,000359x$1,000 + 359x$358,000
3$358,000$1,000358x$1,000 + 358x$357,000
360$1,000$1,000x$1,000 + x$0 (paid off)

The interest amount of course depends on your interest rate. Although different months have a different number of days, banks usually treat all 12 months equally. In other words, your monthly rate is simply 1/12 of your annual rate. If your (annual) interest rate is 3%, your monthly rate is simply 3% / 12 = 0.25%. If our $360,000 mortgage had a 3% interest rate, the payment schedule would look like this:

MonthBalance Before PaymentPrincipalInterestTotal PaymentBalance After Payment
1$360,000$1,000$900$1,900$359,000
2$359,000$1,000$897.50$1,897.50$358,000
3$358,000$1,000$895$1,895$357,000
360$1,000$1,000$2.50$1,002.50$0 (paid off)

We can do a simple division on the interest rate because mortgage interest does not compound. Interests are paid in full each month, and only the remaining balance is generating interest. For every $100 in unpaid balance, 25 cents of interest are generated (and paid) each month, for a total of $3 a year (i.e. an annual interest rate of 3%).

Side note…

In the US, mortgage rates are quoted in increments of 0.125% (an eighth of a percent). In other words, they can only be “round numbers” such as 3%, 3.125%, 3.25%, 3.375%, etc.

However, the government treats certain loan charges paid at closing as prepaid interest, and lenders are required to calculate an effective APR (annual percentage rate) that takes into account those charges. This is to protect consumers and prevent lenders from advertising a low rate that you can only get if you pay a large fee upfront. It also makes comparing different loans easier. Because lender fees can be any amount, the effective APR will often be a less round number (like 3.473%).

In this post, when we talk about the interest rate, we’re talking about the “round numbers”.

Equal P&I Payment

P&I = Principal and Interest, i.e. the total monthly payment. (We’re disregarding any escrow/impound account which is essentially a budgeting tool and not part of the mortgage.)

The equal-principal schedule is unpopular in the US because the monthly payments are unequal (more difficult to budget) and the largest payments are at the beginning (when you’re still moving and furnishing and can’t spare any money), but you do pay less in total in the end. In some other countries, borrowers are asked if they want an equal-principal schedule or an equal-P&I schedule; in the US, mortgages default to equal-P&I.

To figure out the monthly P&I required so that the mortgage is paid off in exactly 360 months, we need to do a bit of tricky math. Let L be the loan amount ($360,000 in our previous example) and r be the monthly rate (0.25% in our previous example), and p be the monthly P&I payment (unknown at this point). Consider the first two months (switching column orders a bit):

MonthBalance Before PaymentP&IInterestPrincipal
(P&I – Interest)
Balance After Payment
1Lp L\cdot rp - L\cdot rL - (p - L\cdot r)
= L\cdot (1+r) - p
2L\cdot (1+r) - pp [L\cdot (1+r) - p]\cdot rp - [L\cdot (1+r) - p]\cdot r(too complicated)

Yeah, we’re going nowhere with this.

Fortunately, we don’t have to keep track of the principal and interest components of each month’s payment. If we only look at the total balance, then the math becomes simpler: each month, the total balance goes up by a factor of r (interest generated), then down by $p (payment).

Suppose the mortgage lasts n months (360 in our previous example), then we have:

MonthBalance After Payment
1L\cdot (1+r) - p
2[L\cdot (1+r) - p]\cdot (1+r) - p
n\underbrace{\{[L\cdot (1+r) - p]\cdot (1+r) - p \ldots \}\cdot (1+r) - p}_{\text{n times}} = 0

Since L, r, n are all known amounts, that last equation will let us solve for p.

Solving for p

Experienced mathematicians will find a solution right away, but we’ll take it one step at a time.

First, we unfold the equation, taking terms to the right one at a time:

\underbrace{\{[L\cdot (1+r) - p]\cdot (1+r) - p \ldots \}\cdot (1+r) - p}_{\text{n times}} = 0

\underbrace{[L\cdot (1+r) - p]\cdot (1+r) - p \ldots }_{\text{(n-1) times}} = \frac{p}{1+r}

\underbrace{[L\cdot (1+r) - p]\cdot (1+r) - p \ldots }_{\text{(n-2) times}} = \frac{\frac{p}{1+r}+p}{1+r}

L = \left. \frac{\frac{\frac{\frac{p}{1+r} + p}{1+r} + \cdots}{\cdots} + p}{1+r} \right\} \text{n times}

Next, we divide both sides by p.

\frac{L}{p} = \left. \frac{\frac{\frac{\frac{1}{1+r} + 1}{1+r} + \cdots}{\cdots} + 1}{1+r} \right\} \text{n times}

Next, we collapse the right hand side (call this equation A):

\frac{L}{p} = \frac{1}{(1+r)^n} + \frac{1}{(1+r)^{n-1}} + \ldots + \frac{1}{1+r}

Some readers will recognize the right hand side as a finite geometric series, but let’s say we don’t. We multiply both sides by (1 + r) (call this equation B):

\frac{L}{p} \cdot (1+r) = \frac{1}{(1+r)^{n-1}} + \frac{1}{(1+r)^{n-2}} + \ldots + 1

We subtract equation A from B. Notice most terms on the right hand side cancel out:

\frac{L}{p} \cdot r = 1 - \frac{1}{(1+r)^n}

Rearrange the equation a bit and we get our answer from the top of this post:

p = \frac{L\cdot r}{1-\frac{1}{(1+r)^n}}

Set L = $360,000, n = 360, r = 0.25%, and we get p = $1517.77, matching Google’s calculator (which rounds to the nearest dollar):

And the payment schedule would look something like this:

MonthBalance Before PaymentPrincipalInterestTotal PaymentBalance After Payment
1$360,000$617.77$900$1,517.77$359,382.23
2$359,382.23$619.31$898.46$1,517.77$358,762.92
3$358,762.92$620.86$896.91$1,517.77$358,142.06
360$1,513.99$1,513.99$3.78$1,517.77$0 (paid off)

Each row’s interest is 0.25% of its “balance before payment”, and the last payment nicely rounds off the loan with a principal payment equal to the balance.

In reality, though, because the monthly payment should really be $1,517.77452…, but you aren’t allowed to ever owe fractions of a cent, monthly balances are always rounded to the nearest cent, causing the last payment to be a few cents off to account for the accumulated error.