FAILURE MAP
← Case archive

FA-62896 / Insurance premium rating / Open access

Deductible credit interpolation: Interpolation weight uses the upper deductible as denominator · case 01

Deductibles between tabulated rows get credits that do not lie on the segment.

Verified by executionVariant 1 · 10 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The interpolation fraction divides by d1 instead of the segment width.

VERIFIED REPAIR

Divide the offset by d1-d0.

Unsuccessful approach: Measuring from the upper end reverses the interpolation direction.

Case contract

Input premium, deductible and table [[deductible, credit per mille]] ascending (credits may be negative surcharges). Deductibles at or below the first row take its credit, at or above the last row take the last credit (no extrapolation), otherwise interpolate linearly. Credit cents = floor(prem*c/1000+1/2). Negative deductible or empty table -> 'invalid'. Return [credit, premium-credit].

Why this case matters

Premium rating engines apply ordered tabular rules where one misplaced boundary or step silently misprices policies.

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):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-1][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/d1
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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 fixtureActualExpectedOutcome
base deductible[-393, 262117][0, 261724]Failed
interpolated low segment[5772, 326211][11543, 320440]Failed
interpolated upper segment[20230, 96115][23939, 92406]Failed
beyond largest tabulated deductible[67985, 254219][67985, 254219]Passed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest row[-631, 211089][-631, 211089]Passed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[10324, 83873][13376, 80821]Failed

SHA-256 / 85bdc05b6a3c2e19bce512f22a80384239c5c2b873c962cd809be651f2e4692e

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):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-1][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d1-d)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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 fixtureActualExpectedOutcome
base deductible[-785, 262509][0, 261724]Failed
interpolated low segment[8708, 323275][11543, 320440]Failed
interpolated upper segment[17131, 99214][23939, 92406]Failed
beyond largest tabulated deductible[67985, 254219][67985, 254219]Passed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest row[-631, 211089][-631, 211089]Passed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[5746, 88451][13376, 80821]Failed

SHA-256 / 63477373da929791ab7df1919edd177deed6eb72d6cfcba59ee9d97bb569346c

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):
    tab=x['table']; d=x['deductible']; prem=x['premium']
    if d<0 or not tab: return 'invalid'
    if d<=tab[0][0]: c=Fraction(tab[0][1])
    elif d>=tab[-1][0]: c=Fraction(tab[-1][1])
    else:
        i=0
        while tab[i+1][0]<d: i+=1
        d0,c0=tab[i]; d1,c1=tab[i+1]
        c=c0+Fraction(c1-c0)*(d-d0)/(d1-d0)
    credit=math.floor(prem*c/1000+Fraction(1,2))
    return [credit, prem-credit]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['base deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 50000, 'premium': 261724}, [0, 261724]], ['interpolated low segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 78500, 'premium': 331983}, [11543, 320440]], ['interpolated upper segment', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 481000, 'premium': 116345}, [23939, 92406]], ['beyond largest tabulated deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 751000, 'premium': 322204}, [67985, 254219]], ['exact largest deductible', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 500000, 'premium': 393848}, [83102, 310746]], ['zero deductible uses lowest row', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 0, 'premium': 210458}, [-631, 211089]], ['deductible below table surcharged', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 10000, 'premium': 199242}, [-598, 199840]], ['negative deductible rejected', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': -100, 'premium': 226782}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 25000, 'premium': 22500}, [-67, 22567]], ['interior knot', {'table': [[25000, -3], [50000, 0], [100000, 61], [250000, 142], [500000, 211]], 'deductible': 250000, 'premium': 94197}, [13376, 80821]]], [['base deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 50000, 'premium': 199101}, [0, 199101]], ['interpolated low segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 86000, 'premium': 159529}, [7121, 152408]], ['interpolated upper segment', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 369000, 'premium': 114198}, [20141, 94057]], ['beyond largest tabulated deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 752000, 'premium': 110216}, [23366, 86850]], ['exact largest deductible', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 500000, 'premium': 313269}, [66413, 246856]], ['zero deductible uses lowest row', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 0, 'premium': 174100}, [-870, 174970]], ['deductible below table surcharged', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 10000, 'premium': 243190}, [-1216, 244406]], ['negative deductible rejected', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': -100, 'premium': 214814}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 25000, 'premium': 23500}, [-117, 23617]], ['interior knot', {'table': [[25000, -5], [50000, 0], [100000, 62], [250000, 144], [500000, 212]], 'deductible': 250000, 'premium': 349563}, [50337, 299226]]], [['base deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 50000, 'premium': 263025}, [0, 263025]], ['interpolated low segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 55000, 'premium': 117616}, [741, 116875]], ['interpolated upper segment', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 315000, 'premium': 209271}, [34199, 175072]], ['beyond largest tabulated deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 753000, 'premium': 115225}, [24543, 90682]], ['exact largest deductible', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 500000, 'premium': 322765}, [68749, 254016]], ['zero deductible uses lowest row', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 0, 'premium': 297017}, [-2079, 299096]], ['deductible below table surcharged', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 10000, 'premium': 263626}, [-1845, 265471]], ['negative deductible rejected', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': -100, 'premium': 120680}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 25000, 'premium': 24500}, [-171, 24671]], ['interior knot', {'table': [[25000, -7], [50000, 0], [100000, 63], [250000, 146], [500000, 213]], 'deductible': 250000, 'premium': 301911}, [44079, 257832]]], [['base deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 50000, 'premium': 340242}, [0, 340242]], ['interpolated low segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 96500, 'premium': 240169}, [14295, 225874]], ['interpolated upper segment', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 339000, 'premium': 148801}, [25519, 123282]], ['beyond largest tabulated deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 754000, 'premium': 216687}, [46371, 170316]], ['exact largest deductible', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 500000, 'premium': 388433}, [83125, 305308]], ['zero deductible uses lowest row', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 0, 'premium': 394112}, [-3547, 397659]], ['deductible below table surcharged', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 10000, 'premium': 145337}, [-1308, 146645]], ['negative deductible rejected', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': -100, 'premium': 335212}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 25000, 'premium': 25500}, [-229, 25729]], ['interior knot', {'table': [[25000, -9], [50000, 0], [100000, 64], [250000, 148], [500000, 214]], 'deductible': 250000, 'premium': 128496}, [19017, 109479]]], [['base deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 50000, 'premium': 113213}, [0, 113213]], ['interpolated low segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 56500, 'premium': 364381}, [3079, 361302]], ['interpolated upper segment', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 374000, 'premium': 322937}, [58852, 264085]], ['beyond largest tabulated deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 755000, 'premium': 161418}, [34705, 126713]], ['exact largest deductible', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 500000, 'premium': 386131}, [83018, 303113]], ['zero deductible uses lowest row', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 0, 'premium': 264667}, [-2911, 267578]], ['deductible below table surcharged', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 10000, 'premium': 141161}, [-1553, 142714]], ['negative deductible rejected', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': -100, 'premium': 190310}, 'invalid'], ['surcharge tie rounds toward positive', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 25000, 'premium': 26500}, [-291, 26791]], ['interior knot', {'table': [[25000, -11], [50000, 0], [100000, 65], [250000, 150], [500000, 215]], 'deductible': 250000, 'premium': 86734}, [13010, 73724]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), 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 fixtureActualExpectedOutcome
base deductible[0, 261724][0, 261724]Passed
interpolated low segment[11543, 320440][11543, 320440]Passed
interpolated upper segment[23939, 92406][23939, 92406]Passed
beyond largest tabulated deductible[67985, 254219][67985, 254219]Passed
exact largest deductible[83102, 310746][83102, 310746]Passed
zero deductible uses lowest row[-631, 211089][-631, 211089]Passed
deductible below table surcharged[-598, 199840][-598, 199840]Passed
negative deductible rejectedinvalidinvalidPassed
surcharge tie rounds toward positive[-67, 22567][-67, 22567]Passed
interior knot[13376, 80821][13376, 80821]Passed

SHA-256 / d8143b057c5f753e8c81b5267b7a28222a7c5667173b46f4a298c6600336effb

Verification & scope

A deterministic bounded teaching model of a stipulated toy rating contract. Amounts are integer cents and factors exact rationals; it makes no claim of conformance with any filed rating plan, bureau manual or jurisdiction. 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:47:08.999969+00:00.

Case digest / 772a7d1612b39468bc3e20f2ce947e36ed33a19b9a95dd2d4a210e19861e3f58