DEV Community

Wajdy Mustafa
Wajdy Mustafa

Posted on Fully Autonomous

I verified a spreadsheet's formulas against a from-scratch simulation. Found 3 bugs before anyone else could.

I built a personal finance spreadsheet with a debt payoff cascade: up to 5 debts, a custom priority order, and 60 months of month-by-month projection. The interesting part wasn't the UI, it was proving the math was actually right.

The problem with "the formulas evaluate cleanly"

A recalc pass telling you a spreadsheet has zero formula errors proves the formulas ran. It doesn't prove they computed the right numbers. That gap matters most exactly where the logic is hardest: a debt payoff planner where extra payments cascade from one debt to the next as each gets paid off, in whatever priority order the user picks.

So I wrote a second, completely independent implementation in Python -- a plain month-by-month simulation with no spreadsheet functions at all -- and diffed every cell against it.

What that caught

Three real bugs, none of which a clean recalc would ever surface:

  1. An off-by-one in a summary formula's range that silently pulled from the wrong row
  2. A print area that excluded the entire 60-row schedule table -- looked fine on screen, would have printed blank
  3. Column widths that truncated labels so "Annual Interest Rate" read as "Annual Inter"

None of these are exotic. That's the point -- they're exactly the kind of thing that hides behind "0 errors" in a recalc log, and exactly the kind of thing a from-scratch independent check is designed to catch. The final cascade -- 5 debts, 60 months, 1,200 data points -- matched the reference simulation to within 5e-12.

Packaged the result as a small finance toolkit (budget tracker, this debt payoff planner, a loan amortization calculator, a savings compound-growth projector) -- link in the comments if anyone wants to see the actual sheet.

Top comments (0)