FAILURE MAP
← Case archive

FA-16736 / Floating-point arithmetic / Open access

Repeated quadratic root loses the factor of two · case 01

Repeated quadratic root loses the factor of two.

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

ROOT CAUSE

Repeated quadratic root loses the factor of two. The faulty expression is if d==0: return [render(-b/a)].

VERIFIED REPAIR

Apply the contract at this fault site using if d==0: return [render(-b/(2*a))].

Unsuccessful approach: The attempted local correction if d==0: return [render(b/(2*a))] still violates the explicit regression fixtures.

Case contract

Real roots of a*x*x+b*x+c=0 for finite coefficients with bounded discriminant products. Use sign-aware q to avoid subtractive cancellation and c/q for the complementary root. Return sorted rendered roots, repeated root once, or explicit degenerate/no-real markers. Finite results are rendered to eleven significant decimal digits; modeled domain violations and arithmetic errors are explicit strings.

Why this case matters

An offline floating representation model isolates a reproducible arithmetic fault.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(a,b,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/a)]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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
large positive b['-1e+16', '-1e-16']['-1e+16', '-1e-16']Passed
large negative b['1e-16', '1e+16']['1e-16', '1e+16']Passed
normal roots['1', '2']['1', '2']Passed
repeated['2']['1']Failed
linear['1']['1']Passed
no realno-realno-realPassed
allallallPassed
inconsistentnonenonePassed
zero constant['0', '1']['0', '1']Passed

SHA-256 / cb9c2c6217138a3c1b4e69b81966fbea240678047bc877204434647342c0ef3c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(a,b,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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
large positive b['-1e+16', '-1e-16']['-1e+16', '-1e-16']Passed
large negative b['1e-16', '1e+16']['1e-16', '1e+16']Passed
normal roots['1', '2']['1', '2']Passed
repeated['-1']['1']Failed
linear['1']['1']Passed
no realno-realno-realPassed
allallallPassed
inconsistentnonenonePassed
zero constant['0', '1']['0', '1']Passed

SHA-256 / 080b4cf5a331bc28bb2f224d00adc44dca64d6001c6bbc00b7ecfb166a6bbb2c

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import struct
def render(x):
    if math.isnan(x): return 'nan'
    if math.isinf(x): return '-infinity' if x<0 else '+infinity'
    return format(x,'.11g')

N = 1
observations = []
def solve(a,b,c):
    try:
        if a==0:
            return [render(-c/b)] if b!=0 else ('all' if c==0 else 'none')
        d=b*b-4*a*c
        if d<0: return 'no-real'
        if d==0: return [render(-b/(2*a))]
        s=math.sqrt(d)
        q=-0.5*(b+math.copysign(s,b))
        r1=q/a
        r2=c/q
        return [render(v) for v in sorted([r1,r2])]
    except (ValueError, OverflowError, ZeroDivisionError, TypeError):
        return "arithmetic-error"
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('large positive b', solve(1.0,1e16*N,1.0), [render(-1e16*N),render(-1/(1e16*N))])
check('large negative b', solve(1.0,-1e16*N,1.0), [render(1/(1e16*N)),render(1e16*N)])
check('normal roots', solve(1.0,-3.0,2.0), ["1","2"])
check('repeated', solve(1.0,-2.0*N,float(N*N)), [render(float(N))])
check('linear', solve(0.0,2.0,-2.0*N), [render(float(N))])
check('no real', solve(1.0,0.0,float(N)), "no-real")
check('all', solve(0.0,0.0,0.0), "all")
check('inconsistent', solve(0.0,0.0,float(N)), "none")
check('zero constant', solve(1.0,-float(N),0.0), ["0",render(float(N))])
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
large positive b['-1e+16', '-1e-16']['-1e+16', '-1e-16']Passed
large negative b['1e-16', '1e+16']['1e-16', '1e+16']Passed
normal roots['1', '2']['1', '2']Passed
repeated['1']['1']Passed
linear['1']['1']Passed
no realno-realno-realPassed
allallallPassed
inconsistentnonenonePassed
zero constant['0', '1']['0', '1']Passed

SHA-256 / c821538eaac37cd1b9ec3c4973814f85efffa66e5c2360a75d333aa28d2ff975

Verification & scope

Controlled binary64 or explicitly stipulated miniature format; no hardware exception flags or platform floating environment are modeled. 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:39.388556+00:00.

Case digest / ef8f8188d15bbee7a8b7e53e8dfafc2a8f1db00e7e96b26b41d7e3a4daae9532