FA-58341 / Loan amortization schedules / Open access
Level payment with final adjustment: monthly periodic rate · case 01
Quoted payments are roughly twelve times the interest a borrower actually owes.
ROOT CAUSE
The annual rate is used as the monthly periodic rate in the annuity formula.
VERIFIED REPAIR
Use bp/120000 as the monthly rate.
Unsuccessful approach: Dividing the basis points by 12 first truncates rates that are not multiples of 12.
Case contract
x = {'principal', 'rate_bp' (annual, monthly rate = bp/120000), 'months', 'round': 'nearest'|'up'}. The exact annuity payment P*r/(1-(1+r)^-n) (P/n at zero rate) is rounded half-up ('nearest') or up to the cent. Monthly interest is round_half_up(balance*bp/120000); months 1..n-1 pay the level payment and month n pays balance + interest. Return {'payment', 'final_payment', 'total_interest'}.
Why this case matters
Amortization engines drive borrower statements, payoff quotes and investor remittances; a misplaced rounding step, boundary or ordering rule compounds across hundreds of periods.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
P = x['principal']
n = x['months']
bp = x['rate_bp']
if bp == 0:
exact = Fraction(P, n)
else:
r = Fraction(bp, 10000)
exact = P * r / (1 - (1 + r) ** -n)
if x['round'] == 'up':
pay = math.ceil(exact)
else:
pay = math.floor(exact + Fraction(1, 2))
bal = P
total_int = 0
last = 0
for k in range(1, n + 1):
q, rem = divmod(bal * bp, 120000)
interest = q + (1 if 2 * rem >= 120000 else 0)
total_int += interest
if k == n:
last = bal + interest
else:
bal = bal + interest - pay
return {'payment': pay, 'final_payment': last, 'total_interest': total_int}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: monthly periodic rate', {'principal': 1000000, 'rate_bp': 13, 'months': 36, 'round': 'up'}, {'payment': 27834, 'final_payment': 27808, 'total_interest': 1998}], ['control 1', {'principal': 7, 'rate_bp': 725, 'months': 360, 'round': 'up'}, {'payment': 1, 'final_payment': -1123, 'total_interest': -771}], ['control 2', {'principal': 999999, 'rate_bp': 0, 'months': 60, 'round': 'nearest'}, {'payment': 16667, 'final_payment': 16646, 'total_interest': 0}], ['control 3', {'principal': 30000000, 'rate_bp': 0, 'months': 36, 'round': 'up'}, {'payment': 833334, 'final_payment': 833310, 'total_interest': 0}], ['control 4', {'principal': 1000000, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333334, 'total_interest': 0}], ['control 5', {'principal': 100000, 'rate_bp': 0, 'months': 360, 'round': 'up'}, {'payment': 278, 'final_payment': 198, 'total_interest': 0}], ['control 6', {'principal': 7, 'rate_bp': 0, 'months': 360, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 500, 'rate_bp': 13, 'months': 3, 'round': 'up'}, {'payment': 167, 'final_payment': 166, 'total_interest': 0}], ['regression: monthly periodic rate, partial-repair probe', {'principal': 2500000, 'rate_bp': 1999, 'months': 3, 'round': 'nearest'}, {'payment': 861250, 'final_payment': 861251, 'total_interest': 83751}], ['control 1', {'principal': 7, 'rate_bp': 0, 'months': 60, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}], ['control 2', {'principal': 999999, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333333, 'total_interest': 0}], ['control 3', {'principal': 999999, 'rate_bp': 0, 'months': 36, 'round': 'nearest'}, {'payment': 27778, 'final_payment': 27769, 'total_interest': 0}], ['control 4', {'principal': 500, 'rate_bp': 13, 'months': 12, 'round': 'nearest'}, {'payment': 42, 'final_payment': 38, 'total_interest': 0}], ['control 5', {'principal': 30000000, 'rate_bp': 0, 'months': 7, 'round': 'nearest'}, {'payment': 4285714, 'final_payment': 4285716, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 2500000, 'rate_bp': 13, 'months': 1, 'round': 'nearest'}, {'payment': 2500271, 'final_payment': 2500271, 'total_interest': 271}], ['control 1', {'principal': 999999, 'rate_bp': 0, 'months': 12, 'round': 'nearest'}, {'payment': 83333, 'final_payment': 83336, 'total_interest': 0}], ['control 2', {'principal': 12345, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 1029, 'final_payment': 1026, 'total_interest': 0}], ['control 3', {'principal': 1000000, 'rate_bp': 0, 'months': 360, 'round': 'up'}, {'payment': 2778, 'final_payment': 2698, 'total_interest': 0}], ['control 4', {'principal': 500, 'rate_bp': 0, 'months': 7, 'round': 'nearest'}, {'payment': 71, 'final_payment': 74, 'total_interest': 0}], ['control 5', {'principal': 999999, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 83334, 'final_payment': 83325, 'total_interest': 0}], ['control 6', {'principal': 7, 'rate_bp': 0, 'months': 3, 'round': 'up'}, {'payment': 3, 'final_payment': 1, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 1000000, 'rate_bp': 13, 'months': 60, 'round': 'up'}, {'payment': 16722, 'final_payment': 16710, 'total_interest': 3308}], ['control 1', {'principal': 7, 'rate_bp': 13, 'months': 12, 'round': 'up'}, {'payment': 1, 'final_payment': -4, 'total_interest': 0}], ['control 2', {'principal': 7, 'rate_bp': 725, 'months': 7, 'round': 'up'}, {'payment': 2, 'final_payment': -5, 'total_interest': 0}], ['control 3', {'principal': 30000000, 'rate_bp': 0, 'months': 360, 'round': 'nearest'}, {'payment': 83333, 'final_payment': 83453, 'total_interest': 0}], ['control 4', {'principal': 1000000, 'rate_bp': 0, 'months': 60, 'round': 'up'}, {'payment': 16667, 'final_payment': 16647, 'total_interest': 0}], ['control 5', {'principal': 30000000, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 2500000, 'final_payment': 2500000, 'total_interest': 0}], ['control 6', {'principal': 100000, 'rate_bp': 0, 'months': 12, 'round': 'nearest'}, {'payment': 8333, 'final_payment': 8337, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 30000000, 'rate_bp': 499, 'months': 2, 'round': 'nearest'}, {'payment': 15093627, 'final_payment': 15093627, 'total_interest': 187254}], ['control 1', {'principal': 999999, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333333, 'total_interest': 0}], ['control 2', {'principal': 500, 'rate_bp': 0, 'months': 2, 'round': 'up'}, {'payment': 250, 'final_payment': 250, 'total_interest': 0}], ['control 3', {'principal': 7, 'rate_bp': 600, 'months': 360, 'round': 'up'}, {'payment': 1, 'final_payment': -876, 'total_interest': -524}], ['control 4', {'principal': 7, 'rate_bp': 600, 'months': 60, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}], ['control 5', {'principal': 500, 'rate_bp': 13, 'months': 360, 'round': 'up'}, {'payment': 2, 'final_payment': -218, 'total_interest': 0}], ['control 6', {'principal': 500, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 42, 'final_payment': 38, 'total_interest': 0}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: monthly periodic rate | {'final_payment': 6178, 'payment': 28451, 'total_interest': 1963} | {'final_payment': 27808, 'payment': 27834, 'total_interest': 1998} | Failed |
| control 1 | {'final_payment': -1123, 'payment': 1, 'total_interest': -771} | {'final_payment': -1123, 'payment': 1, 'total_interest': -771} | Passed |
| control 2 | {'final_payment': 16646, 'payment': 16667, 'total_interest': 0} | {'final_payment': 16646, 'payment': 16667, 'total_interest': 0} | Passed |
| control 3 | {'final_payment': 833310, 'payment': 833334, 'total_interest': 0} | {'final_payment': 833310, 'payment': 833334, 'total_interest': 0} | Passed |
| control 4 | {'final_payment': 333334, 'payment': 333333, 'total_interest': 0} | {'final_payment': 333334, 'payment': 333333, 'total_interest': 0} | Passed |
| control 5 | {'final_payment': 198, 'payment': 278, 'total_interest': 0} | {'final_payment': 198, 'payment': 278, 'total_interest': 0} | Passed |
| control 6 | {'final_payment': 7, 'payment': 0, 'total_interest': 0} | {'final_payment': 7, 'payment': 0, 'total_interest': 0} | Passed |
SHA-256 / bee2027f5141cd972d1fb0f08c7f01b576435ee6bcd0c1a5b547225db72824bf
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
P = x['principal']
n = x['months']
bp = x['rate_bp']
if bp == 0:
exact = Fraction(P, n)
else:
r = Fraction(bp // 12, 10000)
exact = P * r / (1 - (1 + r) ** -n)
if x['round'] == 'up':
pay = math.ceil(exact)
else:
pay = math.floor(exact + Fraction(1, 2))
bal = P
total_int = 0
last = 0
for k in range(1, n + 1):
q, rem = divmod(bal * bp, 120000)
interest = q + (1 if 2 * rem >= 120000 else 0)
total_int += interest
if k == n:
last = bal + interest
else:
bal = bal + interest - pay
return {'payment': pay, 'final_payment': last, 'total_interest': total_int}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: monthly periodic rate', {'principal': 1000000, 'rate_bp': 13, 'months': 36, 'round': 'up'}, {'payment': 27834, 'final_payment': 27808, 'total_interest': 1998}], ['control 1', {'principal': 7, 'rate_bp': 725, 'months': 360, 'round': 'up'}, {'payment': 1, 'final_payment': -1123, 'total_interest': -771}], ['control 2', {'principal': 999999, 'rate_bp': 0, 'months': 60, 'round': 'nearest'}, {'payment': 16667, 'final_payment': 16646, 'total_interest': 0}], ['control 3', {'principal': 30000000, 'rate_bp': 0, 'months': 36, 'round': 'up'}, {'payment': 833334, 'final_payment': 833310, 'total_interest': 0}], ['control 4', {'principal': 1000000, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333334, 'total_interest': 0}], ['control 5', {'principal': 100000, 'rate_bp': 0, 'months': 360, 'round': 'up'}, {'payment': 278, 'final_payment': 198, 'total_interest': 0}], ['control 6', {'principal': 7, 'rate_bp': 0, 'months': 360, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 500, 'rate_bp': 13, 'months': 3, 'round': 'up'}, {'payment': 167, 'final_payment': 166, 'total_interest': 0}], ['regression: monthly periodic rate, partial-repair probe', {'principal': 2500000, 'rate_bp': 1999, 'months': 3, 'round': 'nearest'}, {'payment': 861250, 'final_payment': 861251, 'total_interest': 83751}], ['control 1', {'principal': 7, 'rate_bp': 0, 'months': 60, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}], ['control 2', {'principal': 999999, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333333, 'total_interest': 0}], ['control 3', {'principal': 999999, 'rate_bp': 0, 'months': 36, 'round': 'nearest'}, {'payment': 27778, 'final_payment': 27769, 'total_interest': 0}], ['control 4', {'principal': 500, 'rate_bp': 13, 'months': 12, 'round': 'nearest'}, {'payment': 42, 'final_payment': 38, 'total_interest': 0}], ['control 5', {'principal': 30000000, 'rate_bp': 0, 'months': 7, 'round': 'nearest'}, {'payment': 4285714, 'final_payment': 4285716, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 2500000, 'rate_bp': 13, 'months': 1, 'round': 'nearest'}, {'payment': 2500271, 'final_payment': 2500271, 'total_interest': 271}], ['control 1', {'principal': 999999, 'rate_bp': 0, 'months': 12, 'round': 'nearest'}, {'payment': 83333, 'final_payment': 83336, 'total_interest': 0}], ['control 2', {'principal': 12345, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 1029, 'final_payment': 1026, 'total_interest': 0}], ['control 3', {'principal': 1000000, 'rate_bp': 0, 'months': 360, 'round': 'up'}, {'payment': 2778, 'final_payment': 2698, 'total_interest': 0}], ['control 4', {'principal': 500, 'rate_bp': 0, 'months': 7, 'round': 'nearest'}, {'payment': 71, 'final_payment': 74, 'total_interest': 0}], ['control 5', {'principal': 999999, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 83334, 'final_payment': 83325, 'total_interest': 0}], ['control 6', {'principal': 7, 'rate_bp': 0, 'months': 3, 'round': 'up'}, {'payment': 3, 'final_payment': 1, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 1000000, 'rate_bp': 13, 'months': 60, 'round': 'up'}, {'payment': 16722, 'final_payment': 16710, 'total_interest': 3308}], ['control 1', {'principal': 7, 'rate_bp': 13, 'months': 12, 'round': 'up'}, {'payment': 1, 'final_payment': -4, 'total_interest': 0}], ['control 2', {'principal': 7, 'rate_bp': 725, 'months': 7, 'round': 'up'}, {'payment': 2, 'final_payment': -5, 'total_interest': 0}], ['control 3', {'principal': 30000000, 'rate_bp': 0, 'months': 360, 'round': 'nearest'}, {'payment': 83333, 'final_payment': 83453, 'total_interest': 0}], ['control 4', {'principal': 1000000, 'rate_bp': 0, 'months': 60, 'round': 'up'}, {'payment': 16667, 'final_payment': 16647, 'total_interest': 0}], ['control 5', {'principal': 30000000, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 2500000, 'final_payment': 2500000, 'total_interest': 0}], ['control 6', {'principal': 100000, 'rate_bp': 0, 'months': 12, 'round': 'nearest'}, {'payment': 8333, 'final_payment': 8337, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 30000000, 'rate_bp': 499, 'months': 2, 'round': 'nearest'}, {'payment': 15093627, 'final_payment': 15093627, 'total_interest': 187254}], ['control 1', {'principal': 999999, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333333, 'total_interest': 0}], ['control 2', {'principal': 500, 'rate_bp': 0, 'months': 2, 'round': 'up'}, {'payment': 250, 'final_payment': 250, 'total_interest': 0}], ['control 3', {'principal': 7, 'rate_bp': 600, 'months': 360, 'round': 'up'}, {'payment': 1, 'final_payment': -876, 'total_interest': -524}], ['control 4', {'principal': 7, 'rate_bp': 600, 'months': 60, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}], ['control 5', {'principal': 500, 'rate_bp': 13, 'months': 360, 'round': 'up'}, {'payment': 2, 'final_payment': -218, 'total_interest': 0}], ['control 6', {'principal': 500, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 42, 'final_payment': 38, 'total_interest': 0}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: monthly periodic rate | {'final_payment': 27948, 'payment': 27830, 'total_interest': 1998} | {'final_payment': 27808, 'payment': 27834, 'total_interest': 1998} | Failed |
| control 1 | {'final_payment': -1123, 'payment': 1, 'total_interest': -771} | {'final_payment': -1123, 'payment': 1, 'total_interest': -771} | Passed |
| control 2 | {'final_payment': 16646, 'payment': 16667, 'total_interest': 0} | {'final_payment': 16646, 'payment': 16667, 'total_interest': 0} | Passed |
| control 3 | {'final_payment': 833310, 'payment': 833334, 'total_interest': 0} | {'final_payment': 833310, 'payment': 833334, 'total_interest': 0} | Passed |
| control 4 | {'final_payment': 333334, 'payment': 333333, 'total_interest': 0} | {'final_payment': 333334, 'payment': 333333, 'total_interest': 0} | Passed |
| control 5 | {'final_payment': 198, 'payment': 278, 'total_interest': 0} | {'final_payment': 198, 'payment': 278, 'total_interest': 0} | Passed |
| control 6 | {'final_payment': 7, 'payment': 0, 'total_interest': 0} | {'final_payment': 7, 'payment': 0, 'total_interest': 0} | Passed |
SHA-256 / 819de9f2f09dec0e343ec63158c3f3771de7bddebbd49f132d44fd70714e1339
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
P = x['principal']
n = x['months']
bp = x['rate_bp']
if bp == 0:
exact = Fraction(P, n)
else:
r = Fraction(bp, 120000)
exact = P * r / (1 - (1 + r) ** -n)
if x['round'] == 'up':
pay = math.ceil(exact)
else:
pay = math.floor(exact + Fraction(1, 2))
bal = P
total_int = 0
last = 0
for k in range(1, n + 1):
q, rem = divmod(bal * bp, 120000)
interest = q + (1 if 2 * rem >= 120000 else 0)
total_int += interest
if k == n:
last = bal + interest
else:
bal = bal + interest - pay
return {'payment': pay, 'final_payment': last, 'total_interest': total_int}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: monthly periodic rate', {'principal': 1000000, 'rate_bp': 13, 'months': 36, 'round': 'up'}, {'payment': 27834, 'final_payment': 27808, 'total_interest': 1998}], ['control 1', {'principal': 7, 'rate_bp': 725, 'months': 360, 'round': 'up'}, {'payment': 1, 'final_payment': -1123, 'total_interest': -771}], ['control 2', {'principal': 999999, 'rate_bp': 0, 'months': 60, 'round': 'nearest'}, {'payment': 16667, 'final_payment': 16646, 'total_interest': 0}], ['control 3', {'principal': 30000000, 'rate_bp': 0, 'months': 36, 'round': 'up'}, {'payment': 833334, 'final_payment': 833310, 'total_interest': 0}], ['control 4', {'principal': 1000000, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333334, 'total_interest': 0}], ['control 5', {'principal': 100000, 'rate_bp': 0, 'months': 360, 'round': 'up'}, {'payment': 278, 'final_payment': 198, 'total_interest': 0}], ['control 6', {'principal': 7, 'rate_bp': 0, 'months': 360, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 500, 'rate_bp': 13, 'months': 3, 'round': 'up'}, {'payment': 167, 'final_payment': 166, 'total_interest': 0}], ['regression: monthly periodic rate, partial-repair probe', {'principal': 2500000, 'rate_bp': 1999, 'months': 3, 'round': 'nearest'}, {'payment': 861250, 'final_payment': 861251, 'total_interest': 83751}], ['control 1', {'principal': 7, 'rate_bp': 0, 'months': 60, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}], ['control 2', {'principal': 999999, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333333, 'total_interest': 0}], ['control 3', {'principal': 999999, 'rate_bp': 0, 'months': 36, 'round': 'nearest'}, {'payment': 27778, 'final_payment': 27769, 'total_interest': 0}], ['control 4', {'principal': 500, 'rate_bp': 13, 'months': 12, 'round': 'nearest'}, {'payment': 42, 'final_payment': 38, 'total_interest': 0}], ['control 5', {'principal': 30000000, 'rate_bp': 0, 'months': 7, 'round': 'nearest'}, {'payment': 4285714, 'final_payment': 4285716, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 2500000, 'rate_bp': 13, 'months': 1, 'round': 'nearest'}, {'payment': 2500271, 'final_payment': 2500271, 'total_interest': 271}], ['control 1', {'principal': 999999, 'rate_bp': 0, 'months': 12, 'round': 'nearest'}, {'payment': 83333, 'final_payment': 83336, 'total_interest': 0}], ['control 2', {'principal': 12345, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 1029, 'final_payment': 1026, 'total_interest': 0}], ['control 3', {'principal': 1000000, 'rate_bp': 0, 'months': 360, 'round': 'up'}, {'payment': 2778, 'final_payment': 2698, 'total_interest': 0}], ['control 4', {'principal': 500, 'rate_bp': 0, 'months': 7, 'round': 'nearest'}, {'payment': 71, 'final_payment': 74, 'total_interest': 0}], ['control 5', {'principal': 999999, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 83334, 'final_payment': 83325, 'total_interest': 0}], ['control 6', {'principal': 7, 'rate_bp': 0, 'months': 3, 'round': 'up'}, {'payment': 3, 'final_payment': 1, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 1000000, 'rate_bp': 13, 'months': 60, 'round': 'up'}, {'payment': 16722, 'final_payment': 16710, 'total_interest': 3308}], ['control 1', {'principal': 7, 'rate_bp': 13, 'months': 12, 'round': 'up'}, {'payment': 1, 'final_payment': -4, 'total_interest': 0}], ['control 2', {'principal': 7, 'rate_bp': 725, 'months': 7, 'round': 'up'}, {'payment': 2, 'final_payment': -5, 'total_interest': 0}], ['control 3', {'principal': 30000000, 'rate_bp': 0, 'months': 360, 'round': 'nearest'}, {'payment': 83333, 'final_payment': 83453, 'total_interest': 0}], ['control 4', {'principal': 1000000, 'rate_bp': 0, 'months': 60, 'round': 'up'}, {'payment': 16667, 'final_payment': 16647, 'total_interest': 0}], ['control 5', {'principal': 30000000, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 2500000, 'final_payment': 2500000, 'total_interest': 0}], ['control 6', {'principal': 100000, 'rate_bp': 0, 'months': 12, 'round': 'nearest'}, {'payment': 8333, 'final_payment': 8337, 'total_interest': 0}]], [['regression: monthly periodic rate', {'principal': 30000000, 'rate_bp': 499, 'months': 2, 'round': 'nearest'}, {'payment': 15093627, 'final_payment': 15093627, 'total_interest': 187254}], ['control 1', {'principal': 999999, 'rate_bp': 0, 'months': 3, 'round': 'nearest'}, {'payment': 333333, 'final_payment': 333333, 'total_interest': 0}], ['control 2', {'principal': 500, 'rate_bp': 0, 'months': 2, 'round': 'up'}, {'payment': 250, 'final_payment': 250, 'total_interest': 0}], ['control 3', {'principal': 7, 'rate_bp': 600, 'months': 360, 'round': 'up'}, {'payment': 1, 'final_payment': -876, 'total_interest': -524}], ['control 4', {'principal': 7, 'rate_bp': 600, 'months': 60, 'round': 'nearest'}, {'payment': 0, 'final_payment': 7, 'total_interest': 0}], ['control 5', {'principal': 500, 'rate_bp': 13, 'months': 360, 'round': 'up'}, {'payment': 2, 'final_payment': -218, 'total_interest': 0}], ['control 6', {'principal': 500, 'rate_bp': 0, 'months': 12, 'round': 'up'}, {'payment': 42, 'final_payment': 38, 'total_interest': 0}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + type(exc).__name__
check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: monthly periodic rate | {'final_payment': 27808, 'payment': 27834, 'total_interest': 1998} | {'final_payment': 27808, 'payment': 27834, 'total_interest': 1998} | Passed |
| control 1 | {'final_payment': -1123, 'payment': 1, 'total_interest': -771} | {'final_payment': -1123, 'payment': 1, 'total_interest': -771} | Passed |
| control 2 | {'final_payment': 16646, 'payment': 16667, 'total_interest': 0} | {'final_payment': 16646, 'payment': 16667, 'total_interest': 0} | Passed |
| control 3 | {'final_payment': 833310, 'payment': 833334, 'total_interest': 0} | {'final_payment': 833310, 'payment': 833334, 'total_interest': 0} | Passed |
| control 4 | {'final_payment': 333334, 'payment': 333333, 'total_interest': 0} | {'final_payment': 333334, 'payment': 333333, 'total_interest': 0} | Passed |
| control 5 | {'final_payment': 198, 'payment': 278, 'total_interest': 0} | {'final_payment': 198, 'payment': 278, 'total_interest': 0} | Passed |
| control 6 | {'final_payment': 7, 'payment': 0, 'total_interest': 0} | {'final_payment': 7, 'payment': 0, 'total_interest': 0} | Passed |
SHA-256 / ac5663a4f0928ae6d0f8849e0e699a3b6bc8179f0daec868a1ffe3dd5df6b27c
Verification & scope
A deterministic bounded teaching model with stipulated toy lending rules stated in the contract; money is integer cents and rates are basis points; it makes no claim of conformance to any regulation, servicing standard or product. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:46:25.786067+00:00.
Case digest / bb38031508a2cff696a6087669ea6485ad411fe8a01adbccd6da473b557f2438