FAILURE MAP
← Case archive

FA-14746 / Numerics / Open access

Bernstein to power basis: complement expansion degree · case 01

The exact bernstein to power basis result violates the stated contract at complement expansion degree.

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

ROOT CAUSE

The complement expansion degree step uses range(n-i) instead of range(n-i+1).

VERIFIED REPAIR

Use range(n-i+1) at the complement expansion degree step.

Unsuccessful approach: The partial repair range(i+1) still violates the complement expansion degree invariant.

Case contract

Input Bernstein coefficients b0..bn as integers; return exact ascending power coefficients of sum bi*choose(n,i)*t^i*(1-t)^(n-i).

Why this case matters

Exact discrete arithmetic with observable algorithmic state; no floating point approximation is used.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    b=x;n=len(b)-1;r=[0]*(n+1)
    for i in range(n+1):
     for j in range(n-i):
      k=i+j
      if k<0 or k>n:return None
      r[k]+=b[i]*(math.comb(n,i)) * (math.comb(n-i,j)*(-1)**j if j<=n-i else 0)
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-1], [-1]), ([-1, -1], [-1, 0]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([0], [0]), ([1], [1]), ([2], [2]), ([-1, 0], [-1, 1]), ([-1, 1], [-1, 2])], [([1], [1]), ([-1, 2], [-1, 3]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([2, 0], [2, -2]), ([2, 1], [2, -1]), ([2, 2], [2, 0]), ([-1, -1, -1], [-1, 0, 0])], [([2], [2]), ([0, 1], [0, 1]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([-1, 2, 1], [-1, 6, -4]), ([-1, 2, 2], [-1, 6, -3]), ([0, -1, -1], [0, -2, 1]), ([0, -1, 0], [0, -2, 2])], [([-1, 0], [-1, 1]), ([1, 0], [1, -1]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([0, 2, 2], [0, 4, -2]), ([1, -1, -1], [1, -4, 2]), ([1, -1, 0], [1, -4, 3]), ([1, -1, 1], [1, -4, 4])], [([-1, 1], [-1, 2]), ([2, -1], [2, -3]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([2, -1, -1], [2, -6, 3]), ([2, -1, 0], [2, -6, 4]), ([2, -1, 1], [2, -6, 5]), ([2, -1, 2], [2, -6, 6])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, 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
explicit oracle 0[0][-1]Failed
explicit oracle 1[-1, 0][-1, 0]Passed
explicit oracle 2[2, 0, 0, 0, 0][2, 0, 0, 0, 0]Passed
explicit oracle 3[0][0]Passed
explicit oracle 4[0][1]Failed
explicit oracle 5[0][2]Failed
explicit oracle 6[-1, 0][-1, 1]Failed
explicit oracle 7[-1, 0][-1, 2]Failed

SHA-256 / 20d45164812cd75d7f33eb0e9f6eeeaae9bdfffd9a1683c6b9d0a847ce576305

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    b=x;n=len(b)-1;r=[0]*(n+1)
    for i in range(n+1):
     for j in range(i+1):
      k=i+j
      if k<0 or k>n:return None
      r[k]+=b[i]*(math.comb(n,i)) * (math.comb(n-i,j)*(-1)**j if j<=n-i else 0)
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-1], [-1]), ([-1, -1], [-1, 0]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([0], [0]), ([1], [1]), ([2], [2]), ([-1, 0], [-1, 1]), ([-1, 1], [-1, 2])], [([1], [1]), ([-1, 2], [-1, 3]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([2, 0], [2, -2]), ([2, 1], [2, -1]), ([2, 2], [2, 0]), ([-1, -1, -1], [-1, 0, 0])], [([2], [2]), ([0, 1], [0, 1]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([-1, 2, 1], [-1, 6, -4]), ([-1, 2, 2], [-1, 6, -3]), ([0, -1, -1], [0, -2, 1]), ([0, -1, 0], [0, -2, 2])], [([-1, 0], [-1, 1]), ([1, 0], [1, -1]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([0, 2, 2], [0, 4, -2]), ([1, -1, -1], [1, -4, 2]), ([1, -1, 0], [1, -4, 3]), ([1, -1, 1], [1, -4, 4])], [([-1, 1], [-1, 2]), ([2, -1], [2, -3]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([2, -1, -1], [2, -6, 3]), ([2, -1, 0], [2, -6, 4]), ([2, -1, 1], [2, -6, 5]), ([2, -1, 2], [2, -6, 6])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, 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
explicit oracle 0[-1][-1]Passed
explicit oracle 1None[-1, 0]Failed
explicit oracle 2None[2, 0, 0, 0, 0]Failed
explicit oracle 3[0][0]Passed
explicit oracle 4[1][1]Passed
explicit oracle 5[2][2]Passed
explicit oracle 6None[-1, 1]Failed
explicit oracle 7None[-1, 2]Failed

SHA-256 / 4f83c10da2adde3d09baab1951eeb7840d3a85330189afe67e77a0fb52a22b40

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import itertools
from fractions import Fraction
N = 1
observations = []
def solve(x):
    b=x;n=len(b)-1;r=[0]*(n+1)
    for i in range(n+1):
     for j in range(n-i+1):
      k=i+j
      if k<0 or k>n:return None
      r[k]+=b[i]*(math.comb(n,i)) * (math.comb(n-i,j)*(-1)**j if j<=n-i else 0)
    return r
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([-1], [-1]), ([-1, -1], [-1, 0]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([0], [0]), ([1], [1]), ([2], [2]), ([-1, 0], [-1, 1]), ([-1, 1], [-1, 2])], [([1], [1]), ([-1, 2], [-1, 3]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([2, 0], [2, -2]), ([2, 1], [2, -1]), ([2, 2], [2, 0]), ([-1, -1, -1], [-1, 0, 0])], [([2], [2]), ([0, 1], [0, 1]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([-1, 2, 1], [-1, 6, -4]), ([-1, 2, 2], [-1, 6, -3]), ([0, -1, -1], [0, -2, 1]), ([0, -1, 0], [0, -2, 2])], [([-1, 0], [-1, 1]), ([1, 0], [1, -1]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([0, 2, 2], [0, 4, -2]), ([1, -1, -1], [1, -4, 2]), ([1, -1, 0], [1, -4, 3]), ([1, -1, 1], [1, -4, 4])], [([-1, 1], [-1, 2]), ([2, -1], [2, -3]), ([-1], [-1]), ([2, 2, 2, 2, 2], [2, 0, 0, 0, 0]), ([2, -1, -1], [2, -6, 3]), ([2, -1, 0], [2, -6, 4]), ([2, -1, 1], [2, -6, 5]), ([2, -1, 2], [2, -6, 6])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("explicit oracle %d" % i, 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
explicit oracle 0[-1][-1]Passed
explicit oracle 1[-1, 0][-1, 0]Passed
explicit oracle 2[2, 0, 0, 0, 0][2, 0, 0, 0, 0]Passed
explicit oracle 3[0][0]Passed
explicit oracle 4[1][1]Passed
explicit oracle 5[2][2]Passed
explicit oracle 6[-1, 1][-1, 1]Passed
explicit oracle 7[-1, 2][-1, 2]Passed

SHA-256 / b50df77618c618455ea9f4d7ee9bc8850293d5c170e171fc0191b7b5fb2a271a

Verification & scope

A deterministic bounded teaching model. Inputs are restricted to the explicit contract; this is not a production algebra library. 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:39:19.875026+00:00.

Case digest / 4efe5bbbbb4da2f92ee63ee2ad1f5c2553b891e6867c95f6bbb13f10f40bb263