FA-16301 / Floating-point arithmetic / Open access
Exponential relative increment loses accuracy above its series switch · case 01
Exponential relative increment loses accuracy above its series switch.
ROOT CAUSE
Exponential relative increment loses accuracy above its series switch. The faulty expression is result=(math.exp(x)-1)/x.
VERIFIED REPAIR
Apply the contract at this fault site using result=math.expm1(x)/x.
Unsuccessful approach: The attempted local correction result=(math.exp(x)-1)/x if abs(x)>1e-8 else 1.0 still violates the explicit regression fixtures.
Case contract
Evaluate expm1(x)/x with continuous value one at zero. Inputs are finite and have magnitude at most five. 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 '1'
if abs(x)<1e-8:
result=1+x/2+x*x/6
else:
result=(math.exp(x)-1)/x
return render(result)
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('zero', solve(0.0), "1")
check('negative zero', solve(-0.0), "1")
check('tiny', solve(N*1e-9), render(1+N*1e-9/2))
check('negative tiny', solve(-N*1e-9), render(1-N*1e-9/2))
check('moderate', solve(float(N)), render(math.expm1(N)/N))
check('negative', solve(-float(N)), render(math.expm1(-N)/(-N)))
check('transition', solve(1e-7), render(math.expm1(1e-7)/1e-7))
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 |
|---|---|---|---|
| zero | 1 | 1 | Passed |
| negative zero | 1 | 1 | Passed |
| tiny | 1.0000000005 | 1.0000000005 | Passed |
| negative tiny | 0.9999999995 | 0.9999999995 | Passed |
| moderate | 1.7182818285 | 1.7182818285 | Passed |
| negative | 0.63212055883 | 0.63212055883 | Passed |
| transition | 1.0000000494 | 1.00000005 | Failed |
SHA-256 / 56c49db02e3fc667e7b027b30b657a1f404c95e7166df071c132a49b1862b579
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 '1'
if abs(x)<1e-8:
result=1+x/2+x*x/6
else:
result=(math.exp(x)-1)/x if abs(x)>1e-8 else 1.0
return render(result)
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('zero', solve(0.0), "1")
check('negative zero', solve(-0.0), "1")
check('tiny', solve(N*1e-9), render(1+N*1e-9/2))
check('negative tiny', solve(-N*1e-9), render(1-N*1e-9/2))
check('moderate', solve(float(N)), render(math.expm1(N)/N))
check('negative', solve(-float(N)), render(math.expm1(-N)/(-N)))
check('transition', solve(1e-7), render(math.expm1(1e-7)/1e-7))
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 |
|---|---|---|---|
| zero | 1 | 1 | Passed |
| negative zero | 1 | 1 | Passed |
| tiny | 1.0000000005 | 1.0000000005 | Passed |
| negative tiny | 0.9999999995 | 0.9999999995 | Passed |
| moderate | 1.7182818285 | 1.7182818285 | Passed |
| negative | 0.63212055883 | 0.63212055883 | Passed |
| transition | 1.0000000494 | 1.00000005 | Failed |
SHA-256 / 20fb2cdee80e1b30bde44ba432da7fb161b6e9527580a6157f78658772755a67
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):
try:
if x==0: return '1'
if abs(x)<1e-8:
result=1+x/2+x*x/6
else:
result=math.expm1(x)/x
return render(result)
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('zero', solve(0.0), "1")
check('negative zero', solve(-0.0), "1")
check('tiny', solve(N*1e-9), render(1+N*1e-9/2))
check('negative tiny', solve(-N*1e-9), render(1-N*1e-9/2))
check('moderate', solve(float(N)), render(math.expm1(N)/N))
check('negative', solve(-float(N)), render(math.expm1(-N)/(-N)))
check('transition', solve(1e-7), render(math.expm1(1e-7)/1e-7))
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 |
|---|---|---|---|
| zero | 1 | 1 | Passed |
| negative zero | 1 | 1 | Passed |
| tiny | 1.0000000005 | 1.0000000005 | Passed |
| negative tiny | 0.9999999995 | 0.9999999995 | Passed |
| moderate | 1.7182818285 | 1.7182818285 | Passed |
| negative | 0.63212055883 | 0.63212055883 | Passed |
| transition | 1.00000005 | 1.00000005 | Passed |
SHA-256 / 9dce028cca6c4133e78c46150381171f6ee740fae281905cee6ddfff09fdbb34
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:35.003344+00:00.
Case digest / 48b51820a6d442073893d2d645166a215e9bda1e8a3ff950ae2e240f66cb7281