FA-16431 / Floating-point arithmetic / Open access
Complex square root overflows while forming the radius · case 01
Complex square root overflows while forming the radius.
ROOT CAUSE
Complex square root overflows while forming the radius. The faulty expression is r=math.sqrt(x*x+y*y).
THE FAILURE
Complex square root overflows while forming the radius. The faulty expression is r=math.sqrt(x*x+y*y).
Unsuccessful approach: The attempted local correction r=math.sqrt(min(x*x+y*y,1e308)) still violates the explicit regression fixtures.
Case contract
Principal complex square root for finite components, using stable branch reconstruction and preserving the imaginary signed-zero side of the negative real branch cut. Fixtures keep hypot finite. 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,y):
try:
if x==0 and y==0: return ['0',render(y)]
r=math.sqrt(x*x+y*y)
t=math.sqrt(r/2+abs(x)/2)
if x>=0:
real=t
imag=y/(2*t)
else:
imag=math.copysign(t,y)
real=abs(y)/(2*t)
return [render(real),render(imag)]
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('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
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 |
|---|---|---|---|
| positive axis | ['1', '0'] | ['1', '0'] | Passed |
| negative axis above | ['0', '1'] | ['0', '1'] | Passed |
| negative axis below | ['0', '-1'] | ['0', '-1'] | Passed |
| upper quadrant | ['2', '1'] | ['2', '1'] | Passed |
| lower quadrant | ['2', '-1'] | ['2', '-1'] | Passed |
| negative real quadrant | ['1', '2'] | ['1', '2'] | Passed |
| huge axis | ['+infinity', '0'] | ['1e+154', '0'] | Failed |
| tiny imaginary | ['2', '2.5e-201'] | ['2', '2.5e-201'] | Passed |
| origin above | ['0', '0'] | ['0', '0'] | Passed |
| origin below | ['0', '-0'] | ['0', '-0'] | Passed |
SHA-256 / 13ad1416d875d225dfc3463c78a956e296f4432da82af1c402cbf36d7988405e
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,y):
try:
if x==0 and y==0: return ['0',render(y)]
r=math.sqrt(min(x*x+y*y,1e308))
t=math.sqrt(r/2+abs(x)/2)
if x>=0:
real=t
imag=y/(2*t)
else:
imag=math.copysign(t,y)
real=abs(y)/(2*t)
return [render(real),render(imag)]
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('positive axis', solve(float(N*N),0.0), [render(float(N)),"0"])
check('negative axis above', solve(-float(N*N),0.0), ["0",render(float(N))])
check('negative axis below', solve(-float(N*N),-0.0), ["0",render(-float(N))])
check('upper quadrant', solve(3.0,4.0), ["2","1"])
check('lower quadrant', solve(3.0,-4.0), ["2","-1"])
check('negative real quadrant', solve(-3.0,4.0), ["1","2"])
check('huge axis', solve(1e308,0.0), ["1e+154","0"])
check('tiny imaginary', solve(4.0,N*1e-200), ["2",render(N*1e-200/4)])
check('origin above', solve(0.0,0.0), ["0","0"])
check('origin below', solve(0.0,-0.0), ["0","-0"])
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 |
|---|---|---|---|
| positive axis | ['1', '0'] | ['1', '0'] | Passed |
| negative axis above | ['0', '1'] | ['0', '1'] | Passed |
| negative axis below | ['0', '-1'] | ['0', '-1'] | Passed |
| upper quadrant | ['2', '1'] | ['2', '1'] | Passed |
| lower quadrant | ['2', '-1'] | ['2', '-1'] | Passed |
| negative real quadrant | ['1', '2'] | ['1', '2'] | Passed |
| huge axis | ['7.0710678119e+153', '0'] | ['1e+154', '0'] | Failed |
| tiny imaginary | ['2', '2.5e-201'] | ['2', '2.5e-201'] | Passed |
| origin above | ['0', '0'] | ['0', '0'] | Passed |
| origin below | ['0', '-0'] | ['0', '-0'] | Passed |
SHA-256 / f42268af6468fd1da2f653a260b36cf537a1c907b6874f27f370a0c92e155d93
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 10 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:36.686385+00:00.
Case digest / c9990b06b99ef557a6317e2a6be766508bcd9bd7e1523bc80238cb5bc2ab6c47