9.7 Remaining Loan Balance
With loans, it is often desirable to determine what the remaining loan balance will be after some number of years. For example, if you purchase a home and plan to sell it in five years, you might want to know how much of the loan balance you will have paid off and how much you have to pay from the sale.
# Ch 9.7 - the remaining balance on a loan. The trick: ask how much loan the
# payments you have LEFT could pay off, using the same formula again.
def payout_value(d, r, k, N):
i = r / k
return d * (1 - (1 + i) ** (-N * k)) / i
def payment(P0, r, k, N):
i = r / k
return P0 * i / (1 - (1 + i) ** (-N * k))
LOAN, APR, K, YEARS = 180000, 0.04, 12, 30 # the book's couple
SOLD_AFTER = 5 # TRY IT: 1, 10, 20, 29 - when do they own half the house?
# TRY IT: APR = 0.07. The same house, a very different amount of equity.
d = payment(LOAN, APR, K, YEARS)
print(f"step 1 - what is the payment on ${LOAN:,} at {100 * APR:g}% for {YEARS} years?")
print(f" ${d:,.2f} a month")
print(f" (the book rounds r/k to 0.00333 and gets $858.93; keeping full")
print(f" precision gives ${d:,.2f} - the book's own rounding warning in action)\n")
left = YEARS - SOLD_AFTER
balance = payout_value(d, APR, K, left)
print(f"step 2 - after {SOLD_AFTER} years there are {left} years of payments left.")
print(f" How big a loan would ${d:,.2f} a month pay off in {left} years?")
print(f" P0 = ${balance:,.2f} <- that is what they still owe\n")
paid = d * K * SOLD_AFTER
print(f" paid to the bank so far : ${paid:,.2f}")
print(f" loan actually paid down : ${LOAN - balance:,.2f}")
print(f" so interest : ${paid - (LOAN - balance):,.2f}"
f" ({100 * (paid - (LOAN - balance)) / paid:.0f}% of everything they paid)\n")
running, i = LOAN, APR / K
for _ in range(SOLD_AFTER * K):
running = running * (1 + i) - d
print(f"cross-check by simulating {SOLD_AFTER * K} payments one at a time: "
f"${running:,.2f}")
print("The formula and the month-by-month simulation agree, as they must.\n")
print("years paid still owed equity built share of payments that was interest")
for y in range(0, YEARS + 1, 5):
owed = payout_value(d, APR, K, YEARS - y) if y < YEARS else 0.0
handed = d * K * y
equity = LOAN - owed
share = f"{100 * (handed - equity) / handed:.0f}%" if handed else "-"
print(f"{y:>10} {owed:>10,.0f} {equity:>12,.0f} {share:>35}")
To determine the remaining loan balance after some number of years, we first need to know the loan payments, if we don’t already know them. Remember that only a portion of your loan payments go towards the loan balance; a portion is going to go towards interest. For example, if your payments were $1,000 a month, after a year you will not have paid off $12,000 of the loan balance.
To determine the remaining loan balance, we can think “how much loan will these loan payments be able to pay off in the remaining time on the loan?”
Often times answering remaining balance questions requires two steps:
- Calculating the monthly payments on the loan
- Calculating the remaining loan balance based on the remaining time on the loan
Adapted from Math in Society by David Lippman, hosted on LibreTexts (math.libretexts.org) and licensed under CC BY-SA 3.0. Changes were made. License: CC-BY-SA-3.0.