FAILURE MAP
← Case archive

FA-16291 / Floating-point arithmetic / Open access

Exponential relative increment divides by unsigned magnitude · case 01

Exponential relative increment divides by unsigned magnitude.

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

ROOT CAUSE

Exponential relative increment divides by unsigned magnitude. The faulty expression is result=math.expm1(x)/abs(x).

VERIFIED REPAIR

Apply the contract at this fault site using result=math.expm1(x)/x.

Unsuccessful approach: The attempted local correction result=abs(math.expm1(x))/x 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.expm1(x)/abs(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
negative-0.632120558830.63212055883Failed
transition1.000000051.00000005Passed

SHA-256 / 559bd285cb53998aa25cc447a163438dca88574146d003378c8c69b1b23c61d7

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=abs(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
negative-0.632120558830.63212055883Failed
transition1.000000051.00000005Passed

SHA-256 / 9d9928b806e3e668d7b55cb89037af0ad1bcd3dcffe7c509f6e9992092e9c259

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

Case digest / ccaa3548c100fa9d4a7def00fe7b9010b2a313981654b7c5af6d97c3b5dc25d4