FA-17216 / Floating-point arithmetic / Open access
Scaled square root applies the full exponent to its root · case 01
Scaled square root applies the full exponent to its root.
ROOT CAUSE
Scaled square root applies the full exponent to its root. The faulty expression is return render(math.ldexp(root,e)).
THE FAILURE
Scaled square root applies the full exponent to its root. The faulty expression is return render(math.ldexp(root,e)).
Unsuccessful approach: The attempted local correction return render(math.ldexp(root,-q)) still violates the explicit regression fixtures.
Case contract
Nonnegative square root of finite binary64 x via exponent normalization. Negative input returns domain; negative zero is preserved. 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<0: return 'domain'
if x==0: return render(x)
m,e=math.frexp(x)
q,r=divmod(e,2)
root=math.sqrt(math.ldexp(m,r))
return render(math.ldexp(root,e))
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('square', solve(float(N*N)), render(float(N)))
check('normal', solve(float(N)), render(math.sqrt(N)))
check('huge', solve(1e300), "1e+150")
check('tiny', solve(1e-300), "1e-150")
check('odd exponent', solve(2.0), render(math.sqrt(2)))
check('positive root zero', solve(0.0), "0")
check('negative domain', solve(-float(N)), "domain")
check('negative zero', solve(-0.0), "-0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-537)))
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 |
|---|---|---|---|
| square | 2 | 1 | Failed |
| normal | 2 | 1 | Failed |
| huge | 1.6366953039e+300 | 1e+150 | Failed |
| tiny | 1.2219745454e-300 | 1e-150 | Failed |
| odd exponent | 2.8284271247 | 1.4142135624 | Failed |
| positive root zero | 0 | 0 | Passed |
| negative domain | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
| subnormal | 9.8813129168e-324 | 2.2227587495e-162 | Failed |
SHA-256 / f506676e46b4c060f7aa61e44dff3f008e3f7e352d206723a440c4e222bfa8e5
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<0: return 'domain'
if x==0: return render(x)
m,e=math.frexp(x)
q,r=divmod(e,2)
root=math.sqrt(math.ldexp(m,r))
return render(math.ldexp(root,-q))
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('square', solve(float(N*N)), render(float(N)))
check('normal', solve(float(N)), render(math.sqrt(N)))
check('huge', solve(1e300), "1e+150")
check('tiny', solve(1e-300), "1e-150")
check('odd exponent', solve(2.0), render(math.sqrt(2)))
check('positive root zero', solve(0.0), "0")
check('negative domain', solve(-float(N)), "domain")
check('negative zero', solve(-0.0), "-0")
check('subnormal', solve(math.ldexp(1.0,-1074)), render(math.ldexp(1.0,-537)))
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 |
|---|---|---|---|
| square | 1 | 1 | Passed |
| normal | 1 | 1 | Passed |
| huge | 1.4932217896e-150 | 1e+150 | Failed |
| tiny | 6.6969287949e+149 | 1e-150 | Failed |
| odd exponent | 0.35355339059 | 1.4142135624 | Failed |
| positive root zero | 0 | 0 | Passed |
| negative domain | domain | domain | Passed |
| negative zero | -0 | -0 | Passed |
| subnormal | 4.4989137945e+161 | 2.2227587495e-162 | Failed |
SHA-256 / c42faf4c793b79cfc83c53033be2c769abd1cf7272f174195321381044887d49
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 9 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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:44.363901+00:00.
Case digest / f33ea239f7dc6168260f239fdadfab662c08bf2c13bccd2147374d2ce7e4873d