FAILURE MAP
← Case archive

FA-16286 / Floating-point arithmetic / Open access

Exponential relative increment subtracts rounded unity · case 01

Exponential relative increment subtracts rounded unity.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Exponential relative increment subtracts rounded unity. The faulty expression is result=(math.exp(x)-1)/x.

VERIFIED REPAIR

Apply the contract at this fault site using result=1+x/2+x*x/6.

Unsuccessful approach: The attempted local correction result=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=(math.exp(x)-1)/x
        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 fixtureActualExpectedOutcome
zero11Passed
negative zero11Passed
tiny1.00000008271.0000000005Failed
negative tiny0.999999971720.9999999995Failed
moderate1.71828182851.7182818285Passed
negative0.632120558830.63212055883Passed
transition1.000000051.00000005Passed

SHA-256 / 8efb31955496314db0382037980ad1b089e8b535a554a12299d5b372a440b091

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.0
        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 fixtureActualExpectedOutcome
zero11Passed
negative zero11Passed
tiny11.0000000005Failed
negative tiny10.9999999995Failed
moderate1.71828182851.7182818285Passed
negative0.632120558830.63212055883Passed
transition1.000000051.00000005Passed

SHA-256 / 11083dc4ddb67bdbb1b037755ef7f3abbabdbbe1d7a3958328e6a5b810861bff

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 fixtureActualExpectedOutcome
zero11Passed
negative zero11Passed
tiny1.00000000051.0000000005Passed
negative tiny0.99999999950.9999999995Passed
moderate1.71828182851.7182818285Passed
negative0.632120558830.63212055883Passed
transition1.000000051.00000005Passed

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:34.746228+00:00.

Case digest / 994e2779fede949a190b3ac55f19957aace8ce8f8986cd8b91017a85807cef44