Sub topic 4
How a fixed-rate loan payment is calculated
This chapter assumes you can work with percentages and exponents and read a basic Python function. It also assumes you know the difference between a nominal and an effective annual rate from the previous chapter. The goal is to see where the payment on a car loan or mortgage comes from, so you can check a lender's quote yourself.
What a fixed-rate payment promises
A fixed-rate, fully amortizing loan has three properties:
- The interest rate does not change.
- You pay the same amount every month.
- After the last payment, the balance is exactly zero.
The third property determines the payment. The lender picks a payment that is large enough to cover each month's interest and still pay down the principal. The principal is the amount borrowed, and it must reach zero on schedule. Each payment has two parts:
- Interest: the current balance times the monthly rate.
- Principal: whatever is left of the payment after interest.
Because the balance falls, the interest part shrinks each month and the principal part grows. The total payment stays the same.
The monthly rate and the number of payments
The formula needs two inputs in monthly units:
r, the monthly rate. For most consumer loans,r = annual rate / 12. A 7% loan hasr = 0.07 / 12 = 0.005833.n, the number of payments. A 5-year loan hasn = 5 × 12 = 60.
Mixing units is the most common error. If you use an annual rate with a monthly payment count, the result is wrong by a wide margin.
The formula
The standard payment formula is:
payment = P × r / (1 − (1 + r)^(−n))P is the principal. The formula comes from requiring the loan to end at zero. Each payment is worth less in today's money the further away it is, because today's money could earn interest in the meantime. The lender sets the payment so that the discounted value of all n payments equals the amount lent:
P = payment × [1 − (1 + r)^(−n)] / rSolving for payment gives the formula above. The bracketed term is the present value of an annuity, a stream of equal payments, and it is the only moving part.
Computing it in Python
def monthly_payment(principal, annual_rate, years):
"""Fixed monthly payment for a fully amortizing loan."""
r = annual_rate / 12 # monthly rate
n = years * 12 # number of payments
if r == 0:
return principal / n
return principal * r / (1 - (1 + r) ** -n)
payment = monthly_payment(20000, 0.07, 5)
total_paid = payment * 5 * 12
print(f"Monthly payment: {payment:.2f}")
print(f"Total interest: {total_paid - 20000:.2f}")For a 20,000 loan at 7% over 5 years, the payment is about 396.02 and the total interest is about 3,761. The r == 0 branch handles a zero-interest loan. Without it, the formula divides by zero.
Checking the formula by simulation
You can confirm the formula by running the loan month by month. Each month, add interest to the balance and subtract the payment. If the formula is right, the balance ends at zero.
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 final_balance(principal, annual_rate, years, show_months=2):
r = annual_rate / 12
pay = monthly_payment(principal, annual_rate, years)
balance = principal
for month in range(1, years * 12 + 1):
interest = balance * r
principal_part = pay - interest
balance = balance - principal_part
if month <= show_months:
print(f"Month {month}: interest {interest:.2f}, "
f"principal {principal_part:.2f}, balance {balance:.2f}")
return balance
print(f"Final balance: {final_balance(20000, 0.07, 5):.2f}")The first two lines of output are:
- Month 1: interest 116.67, principal 279.35, balance 19,720.65.
- Month 2: interest 115.04, principal 280.98.
Of the first payment of 396.02, about 29% goes to interest. By the last payment, almost all of it goes to principal. The final balance prints as 0.00, give or take a floating-point rounding error.
How each input moves the payment
Changing one input at a time shows which ones matter most.
| Change | Effect on payment | Effect on total interest |
|---|---|---|
| Higher principal | Rises in proportion | Rises in proportion |
| Higher rate | Rises, by a modest amount per point | Rises, by more than the payment does |
| Longer term | Falls, with diminishing returns | Rises sharply |
| Rate of 0% | Principal divided by `n` | Zero |
The principal scales the payment linearly. Doubling the loan doubles the payment. The rate and the term interact, so their effects are not linear. Stretching the same 20,000 at 7% to 10 years drops the payment to about 232, but total interest rises to about 7,870, roughly double. The term trade-off gets its own chapter. For now, the point is that a lower payment does not mean a cheaper loan.
Gotchas and edge cases
- Rate conventions. Many consumer loans in the US divide the annual rate by 12. Some countries, and some products, define the monthly rate from the effective annual rate instead:
r = (1 + EAR)^(1/12) − 1. The two give slightly different payments. Check how the lender defines its rate. - Payment timing. The formula assumes the first payment comes one full month after the loan starts, and each payment is made at the end of its period. A loan with payments due at the start of each period, such as some leases, needs the payment divided by
(1 + r). - Fees are outside the formula. The formula covers principal and interest only. Origination fees, insurance, and similar charges change what you really pay. They are the subject of a later chapter.
- Variable rates. If the rate resets, the lender recalculates the payment using the current balance, the new rate, and the remaining number of payments. You can reuse
monthly_paymentfor that. Pass the remaining balance and remaining years. - Extra payments. The fixed payment only guarantees payoff at the end of the term. If you pay extra, the balance falls faster and the loan ends early. The scheduled payment does not change unless the lender re-amortizes the loan.
- Interest-only periods. During an interest-only period, the payment is just
balance × rand the balance does not fall. Once principal payments begin, the same formula applies, butnis the shorter remaining term, so the payment jumps.
Common errors
- Using the annual rate as
rwhile countingnin months. - Entering the rate as
7instead of0.07. - Forgetting the zero-rate case, which makes the code fail with a division by zero.
- Comparing two loans only by monthly payment, when they have different terms.
- Rounding the payment before computing total interest, which adds a small error across many payments.
Exercise
A lender offers 15,000 at 6% for 4 years, with monthly payments. State r and n, write the one-line call to the chapter's monthly_payment function, and explain why the first month's interest is 75.00.
Show answer
The monthly rate is r = 0.06 / 12 = 0.005 and the number of payments is n = 4 × 12 = 48. The call is monthly_payment(15000, 0.06, 4), which returns about 352.28. The first month's interest is the full starting balance times the monthly rate: 15,000 × 0.005 = 75.00. The remaining 277.28 of the first payment reduces the principal.
Exercise
Using monthly_payment(20000, 0.07, 5), a borrower pays 396.02 a month. Without recomputing the schedule, explain why the principal part of the payment in month 30 is larger than in month 1, even though the payment is the same.
Show answer
In month 1 the balance is 20,000, so interest is 116.67 and principal is 279.35. By month 30 the balance has fallen, so the interest charge, which is balance × r, is smaller. The payment stays at 396.02, so the principal part, payment minus interest, must be larger.