FAILURE MAP
← Case archive

FA-16996 / Floating-point arithmetic / Open access

Exponential divided difference divides by an unsigned separation · case 01

Exponential divided difference divides by an unsigned separation.

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

ROOT CAUSE

Exponential divided difference divides by an unsigned separation. The faulty expression is ratio=math.expm1(d)/abs(d).

VERIFIED REPAIR

Apply the contract at this fault site using ratio=math.expm1(d)/d.

Unsuccessful approach: The attempted local correction ratio=abs(math.expm1(d))/d still violates the explicit regression fixtures.

Case contract

Evaluate (exp(b)-exp(a))/(b-a) with continuous value exp(a) when a=b. Fixture exponents are bounded; use expm1 for close endpoints. 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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/abs(d)
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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
coincident2.71828182852.7182818285Passed
near endpoints11Passed
shifted near2.71828182852.7182818285Passed
forward1.71828182851.7182818285Passed
reverse-1.71828182851.7182818285Failed
negative interval0.632120558830.63212055883Passed
separated1.17520119361.1752011936Passed

SHA-256 / e897f8c42a671a9108d507eb2ed9ad1565e24c665ab98275b1891a28419bb614

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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=abs(math.expm1(d))/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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
coincident2.71828182852.7182818285Passed
near endpoints11Passed
shifted near2.71828182852.7182818285Passed
forward1.71828182851.7182818285Passed
reverse-1.71828182851.7182818285Failed
negative interval0.632120558830.63212055883Passed
separated1.17520119361.1752011936Passed

SHA-256 / e2e14fbb0be42c4aec3a186027e70a46a5c573347ca3a87e0223f19015ade737

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(a,b):
    try:
        if a==b: return render(math.exp(a))
        d=b-a
        if abs(d)<1e-8:
            ratio=1+d/2+d*d/6
        else:
            ratio=math.expm1(d)/d
        result=math.exp(a)*ratio
        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('coincident', solve(float(N),float(N)), render(math.exp(N)))
check('near endpoints', solve(0.0,N*2.0**-60), "1")
check('shifted near', solve(1.0,1.0+N*2.0**-50), render(math.exp(1)*(1+N*2.0**-50/2)))
check('forward', solve(0.0,float(N)), render(math.expm1(N)/N))
check('reverse', solve(float(N),0.0), render(math.expm1(N)/N))
check('negative interval', solve(-float(N),0.0), render(-math.expm1(-N)/N))
check('separated', solve(-1.0,1.0), render((math.exp(1)-math.exp(-1))/2))
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
coincident2.71828182852.7182818285Passed
near endpoints11Passed
shifted near2.71828182852.7182818285Passed
forward1.71828182851.7182818285Passed
reverse1.71828182851.7182818285Passed
negative interval0.632120558830.63212055883Passed
separated1.17520119361.1752011936Passed

SHA-256 / d0aa9a6aaee7990745f7de88a4a7e7cc71bf1a0d09d5984b2b42c6414c39b116

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

Case digest / 55c60512f9629f982a4a0b20f6bace036b3a88670150c2b9946db17d3572f2d6