Sub topic 11
Checking that the circular solution is consistent
A circular debt schedule always shows a number. Excel will not warn you if that number is stale, half-converged, or wrong because a repayment limit is active. This chapter covers how to test a circular solution, so you can tell a converged answer from one that only looks plausible.
I assume you can build a debt schedule with a cash sweep, have enabled iterative calculation, and have a circuit-breaker switch. I also assume you know IF, MIN, MAX, AVERAGE and ABS.
What "consistent" means
The loop is: interest depends on the closing balance, the closing balance depends on repayment, and repayment depends on interest. A solution is consistent when every cell in that loop agrees with the others at the same time.
Formally, the converged interest is a fixed point. If you feed it back through the formulas, you get the same value out. A schedule can fail this test in three ways:
- The iteration stopped early, so the cells come from different passes.
- The workbook has iteration switched off or set differently from what you expect, so cells hold old values.
- The loop is converged but the model is in a state the formulas were never meant to handle, such as a cash shortfall.
The checks below target each of these.
Check 1: the fixed-point residual
The residual is the gap between the interest in the cell and the interest the formula would produce from the closing balance in the sheet:
residual = Interest - Rate * AVERAGE(Debt_Open, Debt_Close)At a true solution the residual is zero. Excel stops iterating when the largest change between passes falls below the Maximum Change setting (default 0.001), so the residual is never exactly zero. It is small, because each pass shrinks the error.
How fast it shrinks depends on the rate. With average-balance interest and no active limits, one pass multiplies the interest error by rate / 2. At 8% that is 0.04, so an error of 1 becomes 0.04, then 0.0016, then 0.000064. Even at a 20% rate the factor is 0.1. For a normal interest rate the loop converges within a handful of passes. If the residual stays large after 100 iterations, suspect something other than the rate. A limit flipping on and off between passes is a common cause.
Choose the residual tolerance relative to the model's units. If you model in millions, a tolerance of 0.0001 means about 100 currency units.
Check 2: accounting identities
The residual checks only the interest equation. You also need the identities that hold the rest of the schedule together:
- Roll-forward:
Debt_Close = Debt_Open - Repayment(plus any drawdowns in your model). - Cash use:
Repayment + Interest <= CFADS. Cash flow available for debt service must cover interest and the sweep together. When it does not, you have a shortfall, and a revolver should draw. - Bounds: the closing balance is at least zero and a revolver stays at or below its limit.
- Balance sheet: if you have a full three-statement model, the balance sheet balances and cash ties to the cash flow statement. A circular loop that is only half-converged often shows up here first, because interest in the income statement differs from interest in the cash flow statement by a few units.
Check 3: compare breaker on and off
Flip the circuit-breaker to 0 and record the result. With the breaker off, interest uses the opening balance. Flip it back to 1.
For the running example (opening 500, CFADS 100, rate 8%):
| Breaker | Interest | Repayment | Closing balance |
|---|---|---|---|
| 0 (opening balance) | 40.0 | 60.0 | 440.0 |
| 1 (average balance) | 37.5 | 62.5 | 437.5 |
The two results should be close, and the average-balance interest should be lower, since the debt falls during the period. If the breaker-on result is far from the breaker-off result, or higher when debt is being repaid, something is wrong. A difference of a few percent of interest is normal. A difference of several multiples is not.
This test also confirms the breaker works. Check that setting it to 0 turns every check green, because with the loop open the residual test no longer applies and the opening-balance version has its own simple formula.
Check 4: the algebraic cross-check
When no limits are active, the loop has a closed-form answer:
interest = rate * (2 * opening - cfads) / 2 / (1 - rate / 2)You can put this formula in a spare cell and compare it with the iterated interest. For the example it gives 0.08 * 900 / 2 / 0.96 = 37.5, which matches.
Use this check with care, because the formula assumes repayment equals CFADS - Interest exactly. Once MIN or MAX limits bind, the formula is wrong and a mismatch does not mean the iteration is wrong. Treat the cross-check as valid only when 0 < CFADS - Interest < Debt_Open. The next script shows both situations.
Running the checks in code
This script reproduces the iteration with the repayment limits from the spine's Repayment formula, then runs the residual, identity, bound and algebraic checks on three cases.
def solve(opening, cfads, rate, tol=1e-9, max_iter=100):
interest = 0.0
for _ in range(max_iter):
repayment = min(opening, max(0.0, cfads - interest))
closing = opening - repayment
new_interest = rate * (opening + closing) / 2
if abs(new_interest - interest) < tol:
return new_interest, repayment, closing
interest = new_interest
raise RuntimeError("did not converge")
def run_checks(opening, cfads, rate, interest, repayment, closing, tol=1e-6):
return {
"interest residual": abs(interest - rate * (opening + closing) / 2) < tol,
"roll-forward": abs(closing - (opening - repayment)) < tol,
"closing not negative": closing >= -tol,
"cash used <= cash available": repayment + interest <= cfads + tol,
}
def algebraic_interest(opening, cfads, rate):
return rate * (2 * opening - cfads) / 2 / (1 - rate / 2)
cases = {
"base": (500.0, 100.0, 0.08),
"paid_off": (50.0, 100.0, 0.08),
"shortfall": (500.0, 10.0, 0.08),
}
for name, (opening, cfads, rate) in cases.items():
interest, repayment, closing = solve(opening, cfads, rate)
results = run_checks(opening, cfads, rate, interest, repayment, closing)
failed = [k for k, ok in results.items() if not ok]
gap = abs(interest - algebraic_interest(opening, cfads, rate))
print(f"{name:<10} interest={interest:.4f} repayment={repayment:.4f} "
f"closing={closing:.4f} ok={all(results.values())} "
f"failed={failed} algebra_gap={gap:.4f}")Expected output:
base interest=37.5000 repayment=62.5000 closing=437.5000 ok=True failed=[] algebra_gap=0.0000
paid_off interest=2.0000 repayment=50.0000 closing=0.0000 ok=True failed=[] algebra_gap=2.0000
shortfall interest=40.0000 repayment=0.0000 closing=500.0000 ok=False failed=['cash used <= cash available'] algebra_gap=1.2500Three things to read from this:
- In
paid_off, the debt is fully repaid, so theMINlimit binds. The iteration is correct (interest of 2.0 on an average balance of 25), but the algebraic formula gives 0, a gap of 2.0. The gap is a limit of the formula, not a modelling error. - In
shortfall, interest of 40 exceeds the 10 of cash available. The loop converges and every loop check passes, but the cash-use check fails. The fix is a funding source such as a revolver, not a change to the loop. - In
base, every check passes and the algebraic formula agrees.
Putting the checks in the workbook
Build one cell per check, then one master check that rolls them up. The master check must handle errors, because an error inside the loop makes every dependent check an error too.
Tol: 0.0001
Check_Residual: =ABS(Interest - Rate*AVERAGE(Debt_Open, Debt_Close))
Check_Roll: =ABS(Debt_Close - (Debt_Open - Repayment))
Check_Cash: =MAX(0, Repayment + Interest - CFADS)
Check_Master: =IFERROR(IF(AND(Check_Residual<Tol, Check_Roll<Tol, Check_Cash<Tol, Debt_Close>=-Tol), 0, 1), 1)Check_Master returns 1 when any check fails and also when any check is an error. Show it on the front sheet in a visible place. Add a conditional format that turns it red. A check nobody sees does not protect anyone.
Common errors in checking
- Tolerance too loose or too tight. A tolerance of 0.01 on a model in millions hides a 10,000 error. A tolerance of 1e-12 fails on normal floating-point noise. Pick a tolerance from the model's units and say what it is.
- Checking only the final period. A loop in period 3 can fail while period 10 looks fine. Test the residual in every period, and have the master check use
SUMorMAXacross the row. - Trusting convergence alone. Iteration can converge to a state that breaks an identity, such as a negative balance. Always add the roll-forward and bounds checks.
- Treating the algebraic gap as a bug. When limits bind, the closed form no longer applies. Use it as a cross-check only in the unconstrained region.
- Leaving the breaker at 0. The model then gives opening-balance results that pass every check. Add a flag that shows when
Circ_Switchis not 1 and the model is meant to be circular.
Summary of the checks
| Check | What it catches | Valid when |
|---|---|---|
| Interest residual | Half-converged or stale loop | Always |
| Roll-forward | Broken balance wiring | Always |
| Cash use and bounds | Shortfalls, negative balances | Always |
| Breaker on vs off | Wrong sign or scale of the average-balance effect | Always, read as a rough comparison |
| Algebraic cross-check | Wrong interest formula | Only when no limits bind |
| Master check with `IFERROR` | Errors stuck in the loop | Always |
Exercise
A model in thousands has opening debt 2,000, CFADS 300 and a rate of 10%, with no limits binding. Using the closed-form formula, what are the interest and closing balance? Then state whether an iterated interest of 95.5 passes a residual check with tolerance 0.001.
Show answer
Interest = 0.10 (22000 - 300) / 2 / (1 - 0.05) = 0.10 3700 / 2 / 0.95 = 185 / 0.95 = 194.7368 (rounded). Closing balance = 2000 - 300 + 194.7368 = 1894.7368. Check: 0.10 (2000 + 1894.7368) / 2 = 194.7368, so the formula is consistent. An iterated interest of 95.5 fails: with the closing balance implied by 95.5 (2000 - 300 + 95.5 = 1795.5), the formula gives 0.10 * 3795.5 / 2 = 189.775, a residual of about 94.3, far above 0.001.
Exercise
Your master check reads 0 with the breaker at 1, but the interest figure is 3 times the breaker-off figure for a debt that is being repaid. Which check from this chapter would have flagged this, and what does it suggest?
Show answer
The breaker on/off comparison. Average-balance interest on a falling balance should be slightly lower than opening-balance interest. A figure 3 times higher points to a wiring error, such as interest referencing the wrong row, a sign error in the closing balance, or an average taken over the wrong cells. The residual check can still pass because the loop is self-consistent even if it is built from the wrong formula.