FA-16466 / Floating-point arithmetic / Open access
Complex logarithm squares components before scaling · case 01
Complex logarithm squares components before scaling.
ROOT CAUSE
Complex logarithm squares components before scaling. The faulty expression is real=0.5*math.log(x*x+y*y).
THE FAILURE
Complex logarithm squares components before scaling. The faulty expression is real=0.5*math.log(x*x+y*y).
Unsuccessful approach: The attempted local correction real=0.5*math.log(max(x*x+y*y,1e-300)) 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=max(a,b); lo=min(a,b)
ratio=lo/hi
real=0.5*math.log(x*x+y*y)
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 | ['+infinity', '0.7853981634'] | ['460.86359219', '0.7853981634'] | Failed |
| tiny | arithmetic-error | ['-460.17044501', '-0.7853981634'] | Failed |
| 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 / 0f3dd936436d00f4b4ff2024ce1ecdafa91d3097509c7d28560148003b49fe0d
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=max(a,b); lo=min(a,b)
ratio=lo/hi
real=0.5*math.log(max(x*x+y*y,1e-300))
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 | ['+infinity', '0.7853981634'] | ['460.86359219', '0.7853981634'] | Failed |
| tiny | ['-345.38776395', '-0.7853981634'] | ['-460.17044501', '-0.7853981634'] | Failed |
| 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 / 42f8e86ec686fd3d2ad631d8c5c8815ae1614c9659c6b2524d9d43fc6a5f3625
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:36.734838+00:00.
Case digest / 232be7a1b312e799ca6a17d41f2298d38be93ca12072fec0e3bf12639af331fd