FA-16471 / Floating-point arithmetic / Open access
Complex logarithm normalizes by the smaller component · case 01
Complex logarithm normalizes by the smaller component.
ROOT CAUSE
Complex logarithm normalizes by the smaller component. The faulty expression is hi=min(a,b); lo=max(a,b).
VERIFIED REPAIR
Apply the contract at this fault site using hi=max(a,b); lo=min(a,b).
Unsuccessful approach: The attempted local correction hi=a; lo=b still violates the explicit regression fixtures.
Case contract
Principal logarithm of nonzero finite complex x+iy, using hypot and atan2; zero returns a pole marker. Inputs 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 'pole'
a=abs(x); b=abs(y)
hi=min(a,b); lo=max(a,b)
ratio=lo/hi
real=math.log(hi)+0.5*math.log1p(ratio*ratio)
imag=math.atan2(y,x)
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('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
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 |
|---|---|---|---|
| unequal components | ['1.6094379124', '0.927295218'] | ['1.6094379124', '0.927295218'] | Passed |
| huge | ['460.86359219', '0.7853981634'] | ['460.86359219', '0.7853981634'] | Passed |
| tiny | ['-460.17044501', '-0.7853981634'] | ['-460.17044501', '-0.7853981634'] | Passed |
| negative real above | arithmetic-error | ['0', '3.1415926536'] | Failed |
| negative real below | arithmetic-error | ['0', '-3.1415926536'] | Failed |
| imaginary axis | arithmetic-error | ['0', '1.5707963268'] | Failed |
| real axis | arithmetic-error | ['0', '0'] | Failed |
| origin | pole | pole | Passed |
| quadrant three | ['0.34657359028', '-2.3561944902'] | ['0.34657359028', '-2.3561944902'] | Passed |
SHA-256 / d01be02dddaefecf1dc52fa9d1cbced5de5994573dbced2e40a32e08d3e3fa67
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 'pole'
a=abs(x); b=abs(y)
hi=a; lo=b
ratio=lo/hi
real=math.log(hi)+0.5*math.log1p(ratio*ratio)
imag=math.atan2(y,x)
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('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
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 |
|---|---|---|---|
| unequal components | ['1.6094379124', '0.927295218'] | ['1.6094379124', '0.927295218'] | Passed |
| huge | ['460.86359219', '0.7853981634'] | ['460.86359219', '0.7853981634'] | Passed |
| tiny | ['-460.17044501', '-0.7853981634'] | ['-460.17044501', '-0.7853981634'] | Passed |
| negative real above | ['0', '3.1415926536'] | ['0', '3.1415926536'] | Passed |
| negative real below | ['0', '-3.1415926536'] | ['0', '-3.1415926536'] | Passed |
| imaginary axis | arithmetic-error | ['0', '1.5707963268'] | Failed |
| real axis | ['0', '0'] | ['0', '0'] | Passed |
| origin | pole | pole | Passed |
| quadrant three | ['0.34657359028', '-2.3561944902'] | ['0.34657359028', '-2.3561944902'] | Passed |
SHA-256 / 791d471ad418df7ff15e6f84f42a15029372adce867988fd3967662194be60ea
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,y):
try:
if x==0 and y==0: return 'pole'
a=abs(x); b=abs(y)
hi=max(a,b); lo=min(a,b)
ratio=lo/hi
real=math.log(hi)+0.5*math.log1p(ratio*ratio)
imag=math.atan2(y,x)
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('unequal components', solve(3.0,4.0), [render(math.log(5)),render(math.atan2(4,3))])
check('huge', solve(N*1e200,1e200), [render(math.log(math.hypot(N*1e200,1e200))),render(math.atan2(1,N))])
check('tiny', solve(N*1e-200,-1e-200), [render(math.log(math.hypot(N*1e-200,1e-200))),render(math.atan2(-1,N))])
check('negative real above', solve(-float(N),0.0), [render(math.log(N)),render(math.pi)])
check('negative real below', solve(-float(N),-0.0), [render(math.log(N)),render(-math.pi)])
check('imaginary axis', solve(0.0,float(N)), [render(math.log(N)),render(math.pi/2)])
check('real axis', solve(float(N),0.0), [render(math.log(N)),"0"])
check('origin', solve(0.0,0.0), "pole")
check('quadrant three', solve(-float(N),-float(N)), [render(math.log(math.hypot(N,N))),render(-3*math.pi/4)])
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 |
|---|---|---|---|
| unequal components | ['1.6094379124', '0.927295218'] | ['1.6094379124', '0.927295218'] | Passed |
| huge | ['460.86359219', '0.7853981634'] | ['460.86359219', '0.7853981634'] | Passed |
| tiny | ['-460.17044501', '-0.7853981634'] | ['-460.17044501', '-0.7853981634'] | Passed |
| negative real above | ['0', '3.1415926536'] | ['0', '3.1415926536'] | Passed |
| negative real below | ['0', '-3.1415926536'] | ['0', '-3.1415926536'] | Passed |
| imaginary axis | ['0', '1.5707963268'] | ['0', '1.5707963268'] | Passed |
| real axis | ['0', '0'] | ['0', '0'] | Passed |
| origin | pole | pole | Passed |
| quadrant three | ['0.34657359028', '-2.3561944902'] | ['0.34657359028', '-2.3561944902'] | Passed |
SHA-256 / 90d110e005a3f3aab59f9617726bd5a7fe057ca8740394bba91ace8bbd714e39
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.683633+00:00.
Case digest / 473e01fad3e1bf6985d80ee5cb350e7161df35f67d06e4940e4db94276b1ca45