FAILURE MAP
← Case archive

FA-14911 / Numerics / Open access

Quadratic surd period: period endpoint retention · case 01

The exact quadratic surd period result violates the stated contract at period endpoint retention.

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

ROOT CAUSE

The period endpoint retention step uses out[:-1] instead of out.

VERIFIED REPAIR

Use out at the period endpoint retention step.

Unsuccessful approach: The partial repair out[1:] still violates the period endpoint retention invariant.

Case contract

Input positive nonsquare D; return [floor(sqrt(D)), repeating continued fraction coefficients]. Bounds: 2<=D<=99.

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):
    D=x
    a0=math.isqrt(D);m=0;d=1;a=a0;out=[]
    for _ in range(100):
     m=d*a-m
     top=D-m*m
     if d==0:return None
     d=top//d
     if d==0:return None
     a=(a0+m)//d
     out.append(a)
     if a==2*a0:break
    return [a0,out[:-1]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(2, [1, [2]]), (99, [9, [1, 18]]), (3, [1, [1, 2]]), (5, [2, [4]]), (6, [2, [2, 4]]), (7, [2, [1, 1, 1, 4]]), (8, [2, [1, 4]]), (10, [3, [6]])], [(3, [1, [1, 2]]), (6, [2, [2, 4]]), (2, [1, [2]]), (99, [9, [1, 18]]), (22, [4, [1, 2, 4, 2, 1, 8]]), (23, [4, [1, 3, 1, 8]]), (24, [4, [1, 8]]), (26, [5, [10]])], [(5, [2, [4]]), (10, [3, [6]]), (2, [1, [2]]), (99, [9, [1, 18]]), (41, [6, [2, 2, 12]]), (42, [6, [2, 12]]), (43, [6, [1, 1, 3, 1, 5, 1, 3, 1, 1, 12]]), (44, [6, [1, 1, 1, 2, 1, 1, 1, 12]])], [(6, [2, [2, 4]]), (13, [3, [1, 1, 1, 1, 6]]), (2, [1, [2]]), (99, [9, [1, 18]]), (59, [7, [1, 2, 7, 2, 1, 14]]), (60, [7, [1, 2, 1, 14]]), (61, [7, [1, 4, 3, 1, 2, 2, 1, 3, 4, 1, 14]]), (62, [7, [1, 6, 1, 14]])], [(7, [2, [1, 1, 1, 4]]), (17, [4, [8]]), (2, [1, [2]]), (99, [9, [1, 18]]), (77, [8, [1, 3, 2, 3, 1, 16]]), (78, [8, [1, 4, 1, 16]]), (79, [8, [1, 7, 1, 16]]), (80, [8, [1, 16]])]]
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, [2]]Failed
explicit oracle 1[9, [1]][9, [1, 18]]Failed
explicit oracle 2[1, [1]][1, [1, 2]]Failed
explicit oracle 3[2, []][2, [4]]Failed
explicit oracle 4[2, [2]][2, [2, 4]]Failed
explicit oracle 5[2, [1, 1, 1]][2, [1, 1, 1, 4]]Failed
explicit oracle 6[2, [1]][2, [1, 4]]Failed
explicit oracle 7[3, []][3, [6]]Failed

SHA-256 / 402fa10cc9d7594d38fab91ad7b16581421ae0519b83ee61acde1cc3fa47f65b

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):
    D=x
    a0=math.isqrt(D);m=0;d=1;a=a0;out=[]
    for _ in range(100):
     m=d*a-m
     top=D-m*m
     if d==0:return None
     d=top//d
     if d==0:return None
     a=(a0+m)//d
     out.append(a)
     if a==2*a0:break
    return [a0,out[1:]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(2, [1, [2]]), (99, [9, [1, 18]]), (3, [1, [1, 2]]), (5, [2, [4]]), (6, [2, [2, 4]]), (7, [2, [1, 1, 1, 4]]), (8, [2, [1, 4]]), (10, [3, [6]])], [(3, [1, [1, 2]]), (6, [2, [2, 4]]), (2, [1, [2]]), (99, [9, [1, 18]]), (22, [4, [1, 2, 4, 2, 1, 8]]), (23, [4, [1, 3, 1, 8]]), (24, [4, [1, 8]]), (26, [5, [10]])], [(5, [2, [4]]), (10, [3, [6]]), (2, [1, [2]]), (99, [9, [1, 18]]), (41, [6, [2, 2, 12]]), (42, [6, [2, 12]]), (43, [6, [1, 1, 3, 1, 5, 1, 3, 1, 1, 12]]), (44, [6, [1, 1, 1, 2, 1, 1, 1, 12]])], [(6, [2, [2, 4]]), (13, [3, [1, 1, 1, 1, 6]]), (2, [1, [2]]), (99, [9, [1, 18]]), (59, [7, [1, 2, 7, 2, 1, 14]]), (60, [7, [1, 2, 1, 14]]), (61, [7, [1, 4, 3, 1, 2, 2, 1, 3, 4, 1, 14]]), (62, [7, [1, 6, 1, 14]])], [(7, [2, [1, 1, 1, 4]]), (17, [4, [8]]), (2, [1, [2]]), (99, [9, [1, 18]]), (77, [8, [1, 3, 2, 3, 1, 16]]), (78, [8, [1, 4, 1, 16]]), (79, [8, [1, 7, 1, 16]]), (80, [8, [1, 16]])]]
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, [2]]Failed
explicit oracle 1[9, [18]][9, [1, 18]]Failed
explicit oracle 2[1, [2]][1, [1, 2]]Failed
explicit oracle 3[2, []][2, [4]]Failed
explicit oracle 4[2, [4]][2, [2, 4]]Failed
explicit oracle 5[2, [1, 1, 4]][2, [1, 1, 1, 4]]Failed
explicit oracle 6[2, [4]][2, [1, 4]]Failed
explicit oracle 7[3, []][3, [6]]Failed

SHA-256 / 744ab2f0250aa0462b82cf6a0bbae11e6d7daf4bcf2651f16d6a274a9c46568c

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):
    D=x
    a0=math.isqrt(D);m=0;d=1;a=a0;out=[]
    for _ in range(100):
     m=d*a-m
     top=D-m*m
     if d==0:return None
     d=top//d
     if d==0:return None
     a=(a0+m)//d
     out.append(a)
     if a==2*a0:break
    return [a0,out]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(2, [1, [2]]), (99, [9, [1, 18]]), (3, [1, [1, 2]]), (5, [2, [4]]), (6, [2, [2, 4]]), (7, [2, [1, 1, 1, 4]]), (8, [2, [1, 4]]), (10, [3, [6]])], [(3, [1, [1, 2]]), (6, [2, [2, 4]]), (2, [1, [2]]), (99, [9, [1, 18]]), (22, [4, [1, 2, 4, 2, 1, 8]]), (23, [4, [1, 3, 1, 8]]), (24, [4, [1, 8]]), (26, [5, [10]])], [(5, [2, [4]]), (10, [3, [6]]), (2, [1, [2]]), (99, [9, [1, 18]]), (41, [6, [2, 2, 12]]), (42, [6, [2, 12]]), (43, [6, [1, 1, 3, 1, 5, 1, 3, 1, 1, 12]]), (44, [6, [1, 1, 1, 2, 1, 1, 1, 12]])], [(6, [2, [2, 4]]), (13, [3, [1, 1, 1, 1, 6]]), (2, [1, [2]]), (99, [9, [1, 18]]), (59, [7, [1, 2, 7, 2, 1, 14]]), (60, [7, [1, 2, 1, 14]]), (61, [7, [1, 4, 3, 1, 2, 2, 1, 3, 4, 1, 14]]), (62, [7, [1, 6, 1, 14]])], [(7, [2, [1, 1, 1, 4]]), (17, [4, [8]]), (2, [1, [2]]), (99, [9, [1, 18]]), (77, [8, [1, 3, 2, 3, 1, 16]]), (78, [8, [1, 4, 1, 16]]), (79, [8, [1, 7, 1, 16]]), (80, [8, [1, 16]])]]
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, [2]][1, [2]]Passed
explicit oracle 1[9, [1, 18]][9, [1, 18]]Passed
explicit oracle 2[1, [1, 2]][1, [1, 2]]Passed
explicit oracle 3[2, [4]][2, [4]]Passed
explicit oracle 4[2, [2, 4]][2, [2, 4]]Passed
explicit oracle 5[2, [1, 1, 1, 4]][2, [1, 1, 1, 4]]Passed
explicit oracle 6[2, [1, 4]][2, [1, 4]]Passed
explicit oracle 7[3, [6]][3, [6]]Passed

SHA-256 / 83ca08275b9c175379965ebae12bf146913834f36b514af1e4fdf87ec7791750

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:21.607658+00:00.

Case digest / 2380243deef126746eaecc4163d8eda2f658671d5b6993aafbfb7df3da21eee9