Workbench / Household Numbers: the Mathematics Capstone
S10 · B1·10
Compounding, Doubling and the EMI
Stage 10, after chapter 10: savings that compound monthly, computed in closed form; how long they take to double, by logarithm and by the rule of 72; and a loan's EMI from its formula, derived from powers and checked month by month until the balance is exactly zero.
Stage 10: compounding, doubling and the EMI
The brief
What you'll build. Two calculations every household meets: savings growing at a monthly-compounded rate, with the time to double; and the EMI (equated monthly instalment) of a loan, with a schedule showing how much of each payment is interest and how much repays the loan.
Why a real household needs this. A home or vehicle loan is often the biggest financial decision a family makes, and the EMI quoted by a lender is a formula most people take on trust. Knowing where it comes from lets you check it, compare offers, and see why paying a little extra early saves so much interest.
Why now. Chapter 10 gives powers for compounding in one step, , and logarithms for solving for . The EMI formula needs one more idea, the sum of a geometric series, derived below from nothing more than subtraction.
What you'll have at the end. growth.py; your savings projected and their doubling time; your own loan's EMI checked against the lender's, with its schedule.
Theory to own
- Monthly compounding. A yearly rate of 7.2 % compounded monthly grows by a year. Why is that a little more than 1.072? (Chapter: "Growth, in closed form"; exercises, P4.)
- Doubling. Solve for with logarithms. Why is the rule of 72 close? (Chapter: "Solving for an exponent".)
- A geometric sum. Let . Multiply by and subtract: , so . Check it for , .
- The EMI formula. A loan at monthly rate grows to after months if nothing is paid. Each EMI , paid at the end of a month, grows until the end too: the first by , the last by . Paying it off means these match: with . Show that this gives .
Build it
Step 1: by hand. With a calculator, find and use it to compute the EMI of ₹10 lakh at 9 % a year (0.75 % a month) for 5 years. Then work out the first month's interest (0.75 % of ₹10 lakh) and how much of the first EMI repays the loan.
Step 2: the code. Exact fractions for the rate and the balance, so the check at the end is exact:
"""Stage 10: powers at home: savings that compound, how long they take to double, and a loan's EMI."""
from fractions import Fraction as F
import math
def rupees(p):
p = round(p)
return f"₹{p // 100:,}.{p % 100:02d}"
# 1. Savings compounding monthly, in closed form, checked against month-by-month.
P, yearly = 2_00_000_00, F(72, 1000) # ₹2 lakh at 7.2% a year
r = yearly / 12
for years in (5, 10, 20):
closed = P * (1 + r) ** (12 * years)
print(f"₹2 lakh after {years:>2} years: {rupees(closed)}")
print(f"doubles in {math.log(2) / math.log(1 + float(r)) / 12:.2f} years; rule of 72 says {72 / 7.2:.1f}")
# 2. A loan: ₹10 lakh at 9% a year for 5 years, paid monthly.
L, n, r = 10_00_000_00, 60, F(9, 100) / 12
growth = (1 + r) ** n
emi = L * r * growth / (growth - 1) # the EMI formula
print(f"EMI: {rupees(emi)} a month for {n} months; total paid {rupees(emi * n)}, interest {rupees(emi * n - L)}")
bal = F(L)
for month in range(1, n + 1):
interest = bal * r
bal = bal + interest - emi
if month in (1, 2, 30, 60):
print(f" month {month:>2}: interest {rupees(interest):>11}, principal {rupees(emi - interest):>11}, balance {rupees(max(bal, 0)):>14}")
print("balance after the last EMI is exactly zero:", bal == 0)
₹2 lakh after 5 years: ₹286,357.68
₹2 lakh after 10 years: ₹410,003.61
₹2 lakh after 20 years: ₹840,514.81
doubles in 9.66 years; rule of 72 says 10.0
EMI: ₹20,758.36 a month for 60 months; total paid ₹1,245,501.31, interest ₹245,501.31
month 1: interest ₹7,500.00, principal ₹13,258.36, balance ₹986,741.64
month 2: interest ₹7,400.56, principal ₹13,357.79, balance ₹973,383.85
month 30: interest ₹4,292.05, principal ₹16,466.31, balance ₹555,806.63
month 60: interest ₹154.53, principal ₹20,603.83, balance ₹0.00
balance after the last EMI is exactly zero: True
Step 3: read the output. ₹2 lakh at 7.2 % compounded monthly reaches about ₹2.86 lakh in 5 years and ₹8.4 lakh in 20: it doubles every 9.66 years (the rule of 72 says 10; monthly compounding makes it slightly faster). The loan's EMI is ₹20,758.36, and the total interest over five years is ₹2,45,501.31, about a quarter of the loan. The schedule shows the shape of every EMI loan: in month 1, ₹7,500 of the ₹20,758 is interest and only ₹13,258 repays the loan; by month 60 almost all of it is repayment. Running the balance month by month with the formula's EMI ends at exactly zero, which is the formula's proof by computation.
Step 4: your loan. Run it with a loan you have or are considering, and compare with the lender's EMI (banks usually round it to the rupee, so the last instalment differs by a little). Then add a one-time prepayment of ₹50,000 in month 12 and measure how many months, or how much interest, it saves.
Senior and architect lens
- Closed form and simulation, both. The formula is fast and exact; the month-by-month simulation is what the bank's statement shows. Checking one against the other is how financial software is tested.
- Round where the contract says. Real loans round the EMI and each month's interest to the paisa or rupee by stated rules; exact fractions here show the mathematics, and a production system must reproduce the lender's rounding exactly (chapter 7's exercises, S2).
- Front-loaded interest is arithmetic, not a trick. Interest is charged on the outstanding balance, which is highest at the start; that's why early prepayments save the most. Show users the schedule, not just the EMI.
Evidence
growth.pywith your own savings and loan, and its output.- Your hand calculation of the EMI and the first month's split.
- The months or interest saved by the prepayment in Step 4.
Carry forward
Stage 11, after chapter 11, makes the household's numbers honest about precision: estimating a month's spending before adding it up, rounding each kind of figure the right way, units that don't mix (kWh, litres, kilometres), and checking a bill by estimation.