FA-16106 / Floating-point arithmetic / Open access
Subtracting one erases a tiny square-root increment · case 01
Subtracting one erases a tiny square-root increment.
ROOT CAUSE
Subtracting one erases a tiny square-root increment. The faulty expression is result=math.sqrt(1+x)-1.
VERIFIED REPAIR
Apply the contract at this fault site using result=x/(math.sqrt(1+x)+1).
Unsuccessful approach: The attempted local correction result=math.sqrt(1+x)-1 if abs(x)>1e-20 else x/2 still violates the explicit regression fixtures.
Case contract
Evaluate sqrt(1+x)-1 stably for finite x >= -1. 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(x):
try:
if x < -1: return 'domain'
if x == -1: return '-1'
if x == 0: return render(x)
result=math.sqrt(1+x)-1
return render(result)
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('tiny positive', solve(N*2.0**-60), render(N*2.0**-61))
check('tiny negative', solve(-N*2.0**-60), render(-N*2.0**-61))
check('normal', solve(3.0), "1")
check('endpoint', solve(-1.0), "-1")
check('domain', solve(-2.0), "domain")
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('large', solve(1e300), render(1e150))
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| tiny positive | 0 | 4.3368086899e-19 | Failed |
| tiny negative | 0 | -4.3368086899e-19 | Failed |
| normal | 1 | 1 | Passed |
| endpoint | -1 | -1 | Passed |
| domain | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
| positive zero | 0 | 0 | Passed |
| large | 1e+150 | 1e+150 | Passed |
SHA-256 / 1d85a41eec0cc0882d9341b7eef6d1a4e1a7fb347f766f5bc2813ff5dcec7dc3
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(x):
try:
if x < -1: return 'domain'
if x == -1: return '-1'
if x == 0: return render(x)
result=math.sqrt(1+x)-1 if abs(x)>1e-20 else x/2
return render(result)
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('tiny positive', solve(N*2.0**-60), render(N*2.0**-61))
check('tiny negative', solve(-N*2.0**-60), render(-N*2.0**-61))
check('normal', solve(3.0), "1")
check('endpoint', solve(-1.0), "-1")
check('domain', solve(-2.0), "domain")
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('large', solve(1e300), render(1e150))
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| tiny positive | 0 | 4.3368086899e-19 | Failed |
| tiny negative | 0 | -4.3368086899e-19 | Failed |
| normal | 1 | 1 | Passed |
| endpoint | -1 | -1 | Passed |
| domain | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
| positive zero | 0 | 0 | Passed |
| large | 1e+150 | 1e+150 | Passed |
SHA-256 / a70077d56bd3b1997d530d1e3e93db0a3b57d05ac25529345f92a4efefc89b02
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(x):
try:
if x < -1: return 'domain'
if x == -1: return '-1'
if x == 0: return render(x)
result=x/(math.sqrt(1+x)+1)
return render(result)
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('tiny positive', solve(N*2.0**-60), render(N*2.0**-61))
check('tiny negative', solve(-N*2.0**-60), render(-N*2.0**-61))
check('normal', solve(3.0), "1")
check('endpoint', solve(-1.0), "-1")
check('domain', solve(-2.0), "domain")
check('negative zero', solve(-0.0), "-0")
check('positive zero', solve(0.0), "0")
check('large', solve(1e300), render(1e150))
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| tiny positive | 4.3368086899e-19 | 4.3368086899e-19 | Passed |
| tiny negative | -4.3368086899e-19 | -4.3368086899e-19 | Passed |
| normal | 1 | 1 | Passed |
| endpoint | -1 | -1 | Passed |
| domain | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
| positive zero | 0 | 0 | Passed |
| large | 1e+150 | 1e+150 | Passed |
SHA-256 / b8a95528e63549f4f6ce109bdd8a9d3b31dfad76fa72cd3670fdbcd994108370
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:33.345443+00:00.
Case digest / 1902279e64dcb8d9d399764b8d03028747c8d90eb89571ff45728087e23446ee