Sub topic 5
How a mortgage payment is built
This chapter assumes you can work with percentages and compound growth, and that you know a mortgage is a loan secured by a home. You don't need any finance background beyond that.
The previous chapters covered the costs of renting and owning. This chapter looks at the largest recurring ownership cost, the mortgage payment. You will learn how the payment is calculated, how each payment splits between interest and principal, and which parts of a monthly housing bill are not the mortgage at all.
The two parts of a loan payment
A fixed-rate mortgage is a loan with a constant interest rate and a constant payment. Each payment does two jobs:
- Interest pays the lender for the use of the money you still owe.
- Principal reduces the amount you still owe. This is the part that builds equity.
The payment stays the same every month, but the split changes. Interest is charged on the current balance. Early on the balance is large, so interest takes most of the payment. As the balance falls, interest shrinks and more of the same payment goes to principal.
The payment formula
Define three inputs:
Pis the amount borrowed (the principal).ris the monthly rate, which is the annual rate divided by 12.nis the number of monthly payments, which is years times 12.
The payment that pays off the loan exactly after n months is:
payment = P * r / (1 - (1 + r) ** -n)The formula finds a constant payment whose present value, discounted at the loan's rate, equals the amount borrowed. You don't need to derive it. You do need to know that the payment depends on the loan amount, the rate, and the term, and nothing else.
def monthly_payment(principal, annual_rate, years):
r = annual_rate / 12
n = years * 12
if r == 0:
return principal / n
return principal * r / (1 - (1 + r) ** -n)
print(round(monthly_payment(300_000, 0.06, 30), 2)) # 1798.65The r == 0 branch avoids dividing by zero. With no interest, the payment is just the principal split evenly.
Splitting the first payment
To split any payment, compute interest on the current balance and treat the remainder as principal.
def first_month_split(principal, annual_rate, payment):
interest = principal * annual_rate / 12
return interest, payment - interest
interest, principal_paid = first_month_split(300_000, 0.06, 1798.65)
print(round(interest, 2), round(principal_paid, 2)) # 1500.0 298.65In month one, about 83% of the payment is interest. Only 298.65 reduces the loan. This is why equity builds slowly at first, and why it matters when you compare owning for three years against owning for fifteen.
The full amortization schedule
Amortization means paying a loan off gradually through scheduled payments. An amortization schedule lists the interest, principal, and remaining balance for every month. The following program builds one and shows how the split shifts over time.
def monthly_payment(principal, annual_rate, years):
r = annual_rate / 12
n = years * 12
if r == 0:
return principal / n
return principal * r / (1 - (1 + r) ** -n)
def amortization_schedule(principal, annual_rate, years, extra=0.0):
"""Return a list of (month, interest, principal_paid, balance)."""
pay = monthly_payment(principal, annual_rate, years) + extra
balance = principal
rows = []
month = 0
while balance > 0.005:
month += 1
interest = balance * annual_rate / 12
principal_paid = min(pay - interest, balance)
balance -= principal_paid
rows.append((month, interest, principal_paid, balance))
return rows
schedule = amortization_schedule(300_000, 0.06, 30)
for month in (1, 60, 180, 360):
_, interest, principal_paid, balance = schedule[month - 1]
print(f"month {month:3d}: interest {interest:8.2f} "
f"principal {principal_paid:8.2f} balance {balance:10.2f}")
total_interest = sum(row[1] for row in schedule)
print(f"total interest over the loan: {total_interest:,.0f}") # about 347,500Three results are worth remembering for this loan:
- After 5 years (60 payments) the balance is about 279,160. You have repaid only about 20,800 of the 300,000, even though you have made payments totaling about 108,000.
- By the midpoint, month 180, interest and principal are close to even in size, but interest is still larger.
- Over 30 years the total interest is about 347,500. That is more than the amount borrowed.
The min(pay - interest, balance) guard keeps the last payment from overshooting the balance. The extra argument models paying more than required each month, which is covered below.
Term and rate: what changes the payment
Two levers set the size of the payment: the term and the rate. Both also change the total interest you pay.
| Loan (300,000 borrowed) | Monthly payment | Total interest |
|---|---|---|
| 30 years at 6% | 1,798.65 | about 347,500 |
| 15 years at 6% | 2,531.57 | about 155,700 |
| 30 years at 7% | 1,995.91 | about 418,500 |
Shortening the term from 30 to 15 years raises the payment by about 733 a month. In return, total interest falls by more than half. A one-point rate increase on the 30-year loan adds about 197 a month, roughly 71,000 over the life of the loan.
For a rent-versus-buy comparison, the lower payment of a long term is not free money. It is a trade of higher lifetime interest for lower monthly cash flow. If you invest the monthly difference at a good return, that trade can work. The opportunity-cost chapter returns to this.
The payment you actually write each month
The mortgage formula covers only principal and interest. Most lenders collect more than that, often as a single monthly bill. The common name is PITI:
- Principal
- Interest
- Taxes (property tax)
- Insurance (homeowner's insurance)
Lenders usually collect the tax and insurance portions into an escrow account, which they use to pay those bills when they come due. Some also add private mortgage insurance, which is covered below.
Suppose a 375,000 home with a 300,000 loan, property tax of 1.1% of the price a year, and insurance of 1,500 a year:
loan_payment = 1798.65
property_tax = 375_000 * 0.011 / 12 # 343.75
insurance = 1_500 / 12 # 125.00
piti = loan_payment + property_tax + insurance
print(round(piti, 2)) # 2267.40The bill is 2,267.40, about 26% more than the loan payment alone. Maintenance is not in this number and comes on top. Property tax and insurance can also rise, so unlike principal and interest, the PITI total is not fixed for the life of the loan.
Edge cases and common errors
Private mortgage insurance
If you put down less than 20%, many lenders require private mortgage insurance (PMI). It protects the lender, not you, and adds a monthly cost until your equity reaches a threshold. In the US conventional loans can usually drop PMI once the balance falls to about 80% of the original home value. Other countries and loan types handle this differently, so check your loan terms.
Adjustable rates
The formula above assumes a fixed rate. With an adjustable-rate mortgage the rate resets after an initial period, and the payment is recalculated on the remaining balance and remaining term. Do not use a single fixed-rate calculation to model an adjustable loan beyond its initial period.
Rounding
Lenders round the payment to the cent, so the final payment can differ by a few cents from the schedule. This does not matter for decision-making, but it explains small mismatches against a lender's statement.
Mixing up annual and monthly rates
The most common coding error is using the annual rate as the monthly rate, or counting years instead of months. Both inflate or deflate the payment by a large factor. Always divide the annual rate by 12 and multiply years by 12.
Extra payments
An extra payment goes entirely to principal. That reduces the balance, which reduces all future interest. The extra argument in amortization_schedule lets you test this. Extra payments early in the loan save the most interest, because they remove principal that would otherwise be charged interest for many years. Check that your lender applies extra payments to principal rather than to future installments, and that there is no prepayment penalty.
Why this matters for the rent-versus-buy model
The simulation later in this tutorial uses the same two ideas from this chapter. It reduces the balance each month by pay - balance * mort_rate / 12, which is the principal portion. It also adds the full payment, plus carrying costs, to the owner's monthly outlay. Equity is only the part of the price you have paid down, plus any appreciation. Because early payments are mostly interest, a short stay leaves you with little equity built from payments, which is one reason the break-even point is several years out.
Exercise
A 200,000 loan at 6% for 30 years has a monthly payment of 1,199.10. How much of the first payment is interest, and how much reduces the principal?
Show answer
The monthly rate is 0.06 / 12 = 0.005. First-month interest is 200,000 * 0.005 = 1,000.00. The principal portion is 1,199.10 - 1,000.00 = 199.10. About 83% of the first payment is interest, the same proportion as in the 300,000 example.
Exercise
Your quote shows a principal-and-interest payment of 1,798.65. Property tax is 4,125 a year and insurance is 1,500 a year. What is the monthly PITI payment, and what else should you budget for before comparing it to rent?
Show answer
Monthly tax is 4,125 / 12 = 343.75 and monthly insurance is 1,500 / 12 = 125.00. PITI is 1,798.65 + 343.75 + 125.00 = 2,267.40. You should also budget for maintenance and repairs, and for PMI if the down payment is under 20%.