Workbench / Household Numbers: the Mathematics Capstone
S12 · B1·12
The Year in One Summary
Stage 12, the last, after chapter 12: the household's whole year in one summary, bringing together the ledger, recurring payments, shares, rates, signed balances, growth, the EMI and estimates from stages 1 to 11, with every figure labelled exact, rounded, estimated or approximate, and the loan rate recovered by trapping it between two numbers.
Stage 12: the year in one summary
The brief
What you'll build. One page that summarises the household's year: income, spending, the closing and lowest balances, the share of income spent, the busiest month, an estimate to check the total, the interest rate hidden in the loan's EMI, and where the savings will be in ten years. Every figure carries a label saying what kind of number it is.
Why a real household needs this. A year's summary is what decisions are made from: whether to prepay a loan, raise savings, change a recurring payment. A summary that mixes exact sums, rounded shares, rough estimates and approximations without saying which is which invites the wrong kind of trust in some numbers and too little in others.
Why now. Chapter 12 distinguishes numbers that can be written exactly (whole paise, fractions) from numbers that can only be approximated (an interest rate found by halving, a float computed from a power). It's the right moment to look back over the whole capstone and label each number honestly.
What you'll have at the end. year.py; your own year in one summary; and a short note on which figures you'd act on and how much each could be off.
Theory to own
- Exact. Sums of whole paise are exact (chapter 3): no rounding can creep in. Which of the summary's figures are of this kind?
- Rounded. A percentage share is exact as a fraction and rounded only for display (chapters 6, 7, 11). Why should no later calculation use the displayed value?
- Estimated. A one-figure estimate is deliberately rough (chapter 11). What is it for, if the exact total is right next to it?
- Approximate. The loan rate solves an equation with no closed-form solution, so it's trapped between two numbers by halving (chapter 12), like . Why does the bracket sit just above 9 %, not at 9 %? (Hint: the EMI was rounded to the paisa.)
Build it
Step 1: by hand. Gather your year: monthly income and spending, the recurring payments from stage 5, the loan from stage 10, the savings from stage 10. Before running anything, estimate the year's spending to one significant figure and write it down.
Step 2: the code. Everything in paise until display; each figure labelled:
"""Stage 12: the household's year in one summary, every figure labelled exact, rounded, estimated or approximate."""
from fractions import Fraction as F
import math
def rs(p): # paise -> rupees text, Indian grouping
p = round(p); sign = "-" if p < 0 else ""; p = abs(p)
r, s = divmod(p, 100); t = str(r); head, tail = t[:-3], t[-3:]
groups = []
while len(head) > 2:
groups.insert(0, head[-2:]); head = head[:-2]
return f"{sign}₹{','.join(([head] if head else []) + groups + [tail])}.{s:02d}"
salary = 85_000_00
monthly_out = [24_000_00, 15_200_00, 2_215_00, 4_000_00, 20_758_36] # rent, food, power, transport, EMI
quarterly_fees, half_yearly_insurance = 18_500_00, 12_400_00 # stage 5's recurring payments
balance, lowest, rows = 12_500_00, 12_500_00, []
for month in range(1, 13):
out = sum(monthly_out)
out += quarterly_fees if month % 3 == 1 else 0
out += half_yearly_insurance if month % 6 == 2 else 0
balance += salary - out
lowest = min(lowest, balance)
rows.append(out)
spent = sum(rows)
summary = [
("income for the year", rs(12 * salary), "exact: whole paise added"),
("spending for the year", rs(spent), "exact"),
("closing balance", rs(balance), "exact"),
("lowest balance in the year", rs(lowest), "exact"),
("share of income spent", f"{float(F(spent, 12 * salary)) * 100:.1f}%", "rounded for display"),
("busiest month's spending", rs(max(rows)), "exact"),
("one-figure estimate of spending", rs(sum(round(x, -(len(str(x)) - 1)) for x in rows)), "estimated"),
]
# The EMI's rate is found by halving (chapter 12): a real number known only to a tolerance.
P, emi, n = 10_00_000, 20_758.36, 60
lo, hi = 0.0, 1.0
while hi - lo > 1e-9:
mid = (lo + hi) / 2
r = mid / 12; g = (1 + r) ** n
lo, hi = (mid, hi) if P * r * g / (g - 1) < emi else (lo, mid)
summary.append(("loan rate implied by the EMI", f"{lo * 100:.7f}% to {hi * 100:.7f}%", "approximate: bracketed by bisection"))
summary.append(("savings of ₹2 lakh after 10 years at 7.2%", rs(2_00_000_00 * (1 + 0.072 / 12) ** 120), "rounded: a float, then to the paisa"))
for what, value, kind in summary:
print(f"{what:<42} {value:>22} {kind}")
income for the year ₹10,20,000.00 exact: whole paise added
spending for the year ₹8,92,880.32 exact
closing balance ₹1,39,619.68 exact
lowest balance in the year ₹12,500.00 exact
share of income spent 87.5% rounded for display
busiest month's spending ₹84,673.36 exact
one-figure estimate of spending ₹9,00,000.00 estimated
loan rate implied by the EMI 9.0000098% to 9.0000099% approximate: bracketed by bisection
savings of ₹2 lakh after 10 years at 7.2% ₹4,10,003.61 rounded: a float, then to the paisa
Step 3: read the output. The year's income (₹10,20,000.00), spending (₹8,92,880.32) and closing balance (₹1,39,619.68) are exact: sums of whole paise. In this example the balance never dips below its opening ₹12,500, because the salary covers even the busiest month (₹84,673.36, when quarterly fees fall due). The share spent, 87.5 %, is rounded for display. The one-figure estimate, ₹9 lakh, is within 1 % of the exact total: a check, not a figure to plan with. The loan rate is approximate: trapped between 9.0000098 % and 9.0000099 %, slightly above the 9 % the loan was taken at because its EMI was rounded up to the paisa. And the savings projection is a float rounded to the paisa, exact to well within a paisa but not an exact sum.
Step 4: your year, and a decision. Run it with your own numbers. Then choose one decision the summary supports (prepay the loan, raise the monthly saving, move a payment date) and write which figures it rests on and what kind each is.
Senior and architect lens
- Label the kind of every number. Financial and analytical reports mix exact, rounded, estimated and modelled figures; saying which is which is part of the number, like its unit.
- Compute from exact sources, display at the edge. The summary computes from paise and fractions, and rounds only when printing; every earlier stage followed the same rule, which is why the numbers agree with each other.
- Approximations need brackets. A value found by search (a rate, a break-even point) should be reported with its bracket or tolerance, so readers know how far to trust the last digits.
Evidence
year.pywith your own year, and its output.- Your Step 1 estimate next to the exact total.
- Your decision note from Step 4.
Carry forward
This is the last stage of the Household Numbers capstone. Its tools (the ledger, the splitter, the schedule, the rate and growth calculators, the checks) together use every chapter of Book 1, and they're yours to keep running month by month: re-run the summary each January and compare the year with the one before.