FAILURE MAP
← Case archive

FA-14906 / Numerics / Open access

Quadratic surd period: period closing criterion · case 01

The exact quadratic surd period result violates the stated contract at period closing criterion.

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

ROOT CAUSE

The period closing criterion step uses a==a0 instead of a==2*a0.

VERIFIED REPAIR

Use a==2*a0 at the period closing criterion step.

Unsuccessful approach: The partial repair d==a0 still violates the period closing criterion 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==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]]), (5, [2, [4]]), (99, [9, [1, 18]]), (3, [1, [1, 2]]), (6, [2, [2, 4]]), (7, [2, [1, 1, 1, 4]]), (8, [2, [1, 4]]), (10, [3, [6]])], [(3, [1, [1, 2]]), (8, [2, [1, 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]]), (12, [3, [2, 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]]), (15, [3, [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]]), (19, [4, [2, 1, 3, 1, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]][1, [2]]Failed
explicit oracle 1[2, [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]][2, [4]]Failed
explicit oracle 2[9, [1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18]][9, [1, 18]]Failed
explicit oracle 3[1, [1]][1, [1, 2]]Failed
explicit oracle 4[2, [2]][2, [2, 4]]Failed
explicit oracle 5[2, [1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 4]][2, [1, 1, 1, 4]]Failed
explicit oracle 6[2, [1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4]][2, [1, 4]]Failed
explicit oracle 7[3, [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]][3, [6]]Failed

SHA-256 / 219ece28509e0467912b7c1be9d21cc2f11d490c5ec41e0b9e324fed674fe5c8

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 d==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]]), (5, [2, [4]]), (99, [9, [1, 18]]), (3, [1, [1, 2]]), (6, [2, [2, 4]]), (7, [2, [1, 1, 1, 4]]), (8, [2, [1, 4]]), (10, [3, [6]])], [(3, [1, [1, 2]]), (8, [2, [1, 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]]), (12, [3, [2, 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]]), (15, [3, [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]]), (19, [4, [2, 1, 3, 1, 2, 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[2, [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]][2, [4]]Failed
explicit oracle 2[9, [1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18]][9, [1, 18]]Failed
explicit oracle 3[1, [1, 2]][1, [1, 2]]Passed
explicit oracle 4[2, [2]][2, [2, 4]]Failed
explicit oracle 5[2, [1, 1]][2, [1, 1, 1, 4]]Failed
explicit oracle 6[2, [1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4]][2, [1, 4]]Failed
explicit oracle 7[3, [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]][3, [6]]Failed

SHA-256 / d05ab14cf88cec997fd4dc2c12ad46d6762fac258baffcc41ae9b0fc6aff0178

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]]), (5, [2, [4]]), (99, [9, [1, 18]]), (3, [1, [1, 2]]), (6, [2, [2, 4]]), (7, [2, [1, 1, 1, 4]]), (8, [2, [1, 4]]), (10, [3, [6]])], [(3, [1, [1, 2]]), (8, [2, [1, 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]]), (12, [3, [2, 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]]), (15, [3, [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]]), (19, [4, [2, 1, 3, 1, 2, 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[2, [4]][2, [4]]Passed
explicit oracle 2[9, [1, 18]][9, [1, 18]]Passed
explicit oracle 3[1, [1, 2]][1, [1, 2]]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 / 61cc280af6a2519950a861b6eda56b20244d4929f1490e90c898fefea1fef196

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

Case digest / fd644d6f09a6c64317551de598eb5bd64190088f434552c6234beecc0d3c9500