FA-17286 / Floating-point arithmetic / Open access
Complex exponential uses cosine for its imaginary projection · case 01
Complex exponential uses cosine for its imaginary projection.
ROOT CAUSE
Complex exponential uses cosine for its imaginary projection. The faulty expression is imag=math.ldexp(scale*c,k).
VERIFIED REPAIR
Apply the contract at this fault site using imag=math.ldexp(scale*s,k).
Unsuccessful approach: The attempted local correction imag=math.ldexp(scale*abs(s),k) still violates the explicit regression fixtures.
Case contract
Compute exp(x+iy) for finite components using binary exponent splitting. Fixtures keep each final component finite or zero, including cases where exp(x) alone overflows. Return two rendered components; exact trigonometric zeros are 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,y):
try:
k=math.floor(x/math.log(2))
f=x-k*math.log(2)
scale=math.exp(f)
c=math.cos(y); s=math.sin(y)
real=math.ldexp(scale*c,k)
imag=math.ldexp(scale*c,k)
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('overflowing common factor', solve(710.0,math.pi/4), [render(math.exp(710-math.log(2))*(2*math.cos(math.pi/4))),render(math.exp(710-math.log(2))*(2*math.sin(math.pi/4)))])
check('negative real projection', solve(float(N),2.0), [render(math.exp(N)*math.cos(2)),render(math.exp(N)*math.sin(2))])
check('ordinary', solve(float(N),0.25), [render(math.exp(N)*math.cos(0.25)),render(math.exp(N)*math.sin(0.25))])
check('negative phase', solve(float(N),-0.25), [render(math.exp(N)*math.cos(-0.25)),render(math.exp(N)*math.sin(-0.25))])
check('negative real', solve(-float(N),0.25), [render(math.exp(-N)*math.cos(0.25)),render(math.exp(-N)*math.sin(0.25))])
check('negative zero phase', solve(float(N),-0.0), [render(math.exp(N)),"-0"])
check('zero', solve(0.0,0.0), ["1","0"])
check('tiny common factor', solve(-744.0,0.25), [render(math.exp(-744)*math.cos(0.25)),render(math.exp(-744)*math.sin(0.25))])
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 |
|---|---|---|---|
| overflowing common factor | ['1.5796728483e+308', '1.5796728483e+308'] | ['1.5796728483e+308', '1.5796728483e+308'] | Passed |
| negative real projection | ['-1.1312043838', '-1.1312043838'] | ['-1.1312043838', '2.471726672'] | Failed |
| ordinary | ['2.6337770293', '2.6337770293'] | ['2.6337770293', '0.67251368673'] | Failed |
| negative phase | ['2.6337770293', '2.6337770293'] | ['2.6337770293', '-0.67251368673'] | Failed |
| negative real | ['0.35644296024', '0.35644296024'] | ['0.35644296024', '0.091014830274'] | Failed |
| negative zero phase | ['2.7182818285', '2.7182818285'] | ['2.7182818285', '-0'] | Failed |
| zero | ['1', '1'] | ['1', '0'] | Failed |
| tiny common factor | ['9.8813129168e-324', '9.8813129168e-324'] | ['9.8813129168e-324', '0'] | Failed |
SHA-256 / bbb7c0cb73b7963dd4127253eb1eccaa01f13144c6a46d090fc26ec9b99848e3
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:
k=math.floor(x/math.log(2))
f=x-k*math.log(2)
scale=math.exp(f)
c=math.cos(y); s=math.sin(y)
real=math.ldexp(scale*c,k)
imag=math.ldexp(scale*abs(s),k)
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('overflowing common factor', solve(710.0,math.pi/4), [render(math.exp(710-math.log(2))*(2*math.cos(math.pi/4))),render(math.exp(710-math.log(2))*(2*math.sin(math.pi/4)))])
check('negative real projection', solve(float(N),2.0), [render(math.exp(N)*math.cos(2)),render(math.exp(N)*math.sin(2))])
check('ordinary', solve(float(N),0.25), [render(math.exp(N)*math.cos(0.25)),render(math.exp(N)*math.sin(0.25))])
check('negative phase', solve(float(N),-0.25), [render(math.exp(N)*math.cos(-0.25)),render(math.exp(N)*math.sin(-0.25))])
check('negative real', solve(-float(N),0.25), [render(math.exp(-N)*math.cos(0.25)),render(math.exp(-N)*math.sin(0.25))])
check('negative zero phase', solve(float(N),-0.0), [render(math.exp(N)),"-0"])
check('zero', solve(0.0,0.0), ["1","0"])
check('tiny common factor', solve(-744.0,0.25), [render(math.exp(-744)*math.cos(0.25)),render(math.exp(-744)*math.sin(0.25))])
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 |
|---|---|---|---|
| overflowing common factor | ['1.5796728483e+308', '1.5796728483e+308'] | ['1.5796728483e+308', '1.5796728483e+308'] | Passed |
| negative real projection | ['-1.1312043838', '2.471726672'] | ['-1.1312043838', '2.471726672'] | Passed |
| ordinary | ['2.6337770293', '0.67251368673'] | ['2.6337770293', '0.67251368673'] | Passed |
| negative phase | ['2.6337770293', '0.67251368673'] | ['2.6337770293', '-0.67251368673'] | Failed |
| negative real | ['0.35644296024', '0.091014830274'] | ['0.35644296024', '0.091014830274'] | Passed |
| negative zero phase | ['2.7182818285', '0'] | ['2.7182818285', '-0'] | Failed |
| zero | ['1', '0'] | ['1', '0'] | Passed |
| tiny common factor | ['9.8813129168e-324', '0'] | ['9.8813129168e-324', '0'] | Passed |
SHA-256 / ffb9826490b6831b8f1f895b2875ae8eb4214445e0e6edcd6c4e6322eefba99c
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:
k=math.floor(x/math.log(2))
f=x-k*math.log(2)
scale=math.exp(f)
c=math.cos(y); s=math.sin(y)
real=math.ldexp(scale*c,k)
imag=math.ldexp(scale*s,k)
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('overflowing common factor', solve(710.0,math.pi/4), [render(math.exp(710-math.log(2))*(2*math.cos(math.pi/4))),render(math.exp(710-math.log(2))*(2*math.sin(math.pi/4)))])
check('negative real projection', solve(float(N),2.0), [render(math.exp(N)*math.cos(2)),render(math.exp(N)*math.sin(2))])
check('ordinary', solve(float(N),0.25), [render(math.exp(N)*math.cos(0.25)),render(math.exp(N)*math.sin(0.25))])
check('negative phase', solve(float(N),-0.25), [render(math.exp(N)*math.cos(-0.25)),render(math.exp(N)*math.sin(-0.25))])
check('negative real', solve(-float(N),0.25), [render(math.exp(-N)*math.cos(0.25)),render(math.exp(-N)*math.sin(0.25))])
check('negative zero phase', solve(float(N),-0.0), [render(math.exp(N)),"-0"])
check('zero', solve(0.0,0.0), ["1","0"])
check('tiny common factor', solve(-744.0,0.25), [render(math.exp(-744)*math.cos(0.25)),render(math.exp(-744)*math.sin(0.25))])
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 |
|---|---|---|---|
| overflowing common factor | ['1.5796728483e+308', '1.5796728483e+308'] | ['1.5796728483e+308', '1.5796728483e+308'] | Passed |
| negative real projection | ['-1.1312043838', '2.471726672'] | ['-1.1312043838', '2.471726672'] | Passed |
| ordinary | ['2.6337770293', '0.67251368673'] | ['2.6337770293', '0.67251368673'] | Passed |
| negative phase | ['2.6337770293', '-0.67251368673'] | ['2.6337770293', '-0.67251368673'] | Passed |
| negative real | ['0.35644296024', '0.091014830274'] | ['0.35644296024', '0.091014830274'] | Passed |
| negative zero phase | ['2.7182818285', '-0'] | ['2.7182818285', '-0'] | Passed |
| zero | ['1', '0'] | ['1', '0'] | Passed |
| tiny common factor | ['9.8813129168e-324', '0'] | ['9.8813129168e-324', '0'] | Passed |
SHA-256 / 89198c78290ab9a83ddcd2c3e75088ee557eeb226ffc27747f970eb6f8bb402b
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.815389+00:00.
Case digest / 637b6542f7730ecf26e3df46da4d6ad152e6b4306e79e04f9d489fe98ac85707