FAILURE MAP
← Case archive

FA-16306 / Floating-point arithmetic / Open access

Relative logarithm assigns zero to a removable singularity · case 01

Relative logarithm assigns zero to a removable singularity.

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

ROOT CAUSE

Relative logarithm assigns zero to a removable singularity. The faulty expression is if x==0: return '0'.

VERIFIED REPAIR

Apply the contract at this fault site using if x==0: return '1'.

Unsuccessful approach: The attempted local correction if x==0: return 'arithmetic-error' still violates the explicit regression fixtures.

Case contract

Evaluate log1p(x)/x on x>-1 with continuous value one at zero. 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<=-1: return 'domain'
        if x==0: return '0'
        if abs(x)<1e-8:
            result=1-x/2+x*x/3
        else:
            result=math.log1p(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('tiny', solve(N*1e-10), render(1-N*1e-10/2))
check('negative tiny', solve(-N*1e-10), render(1+N*1e-10/2))
check('normal', solve(float(N)), render(math.log1p(N)/N))
check('negative normal', solve(-0.125*N), render(math.log1p(-0.125*N)/(-0.125*N)))
check('domain', solve(-1.0), "domain")
check('transition', solve(1e-7), render(math.log1p(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
zero01Failed
tiny0.999999999950.99999999995Passed
negative tiny1.00000000011.0000000001Passed
normal0.693147180560.69314718056Passed
negative normal1.0682511411.068251141Passed
domaindomaindomainPassed
transition0.999999950.99999995Passed

SHA-256 / d3835df4101b542294a2c81fc0e8fc65eca31faf053b59c6413afacc106fccff

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<=-1: return 'domain'
        if x==0: return 'arithmetic-error'
        if abs(x)<1e-8:
            result=1-x/2+x*x/3
        else:
            result=math.log1p(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('tiny', solve(N*1e-10), render(1-N*1e-10/2))
check('negative tiny', solve(-N*1e-10), render(1+N*1e-10/2))
check('normal', solve(float(N)), render(math.log1p(N)/N))
check('negative normal', solve(-0.125*N), render(math.log1p(-0.125*N)/(-0.125*N)))
check('domain', solve(-1.0), "domain")
check('transition', solve(1e-7), render(math.log1p(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
zeroarithmetic-error1Failed
tiny0.999999999950.99999999995Passed
negative tiny1.00000000011.0000000001Passed
normal0.693147180560.69314718056Passed
negative normal1.0682511411.068251141Passed
domaindomaindomainPassed
transition0.999999950.99999995Passed

SHA-256 / 227ae431e4618c73be268bed02e3161fe8756888a0090dbc3d5b0a98e9cf0b86

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<=-1: return 'domain'
        if x==0: return '1'
        if abs(x)<1e-8:
            result=1-x/2+x*x/3
        else:
            result=math.log1p(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('tiny', solve(N*1e-10), render(1-N*1e-10/2))
check('negative tiny', solve(-N*1e-10), render(1+N*1e-10/2))
check('normal', solve(float(N)), render(math.log1p(N)/N))
check('negative normal', solve(-0.125*N), render(math.log1p(-0.125*N)/(-0.125*N)))
check('domain', solve(-1.0), "domain")
check('transition', solve(1e-7), render(math.log1p(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
tiny0.999999999950.99999999995Passed
negative tiny1.00000000011.0000000001Passed
normal0.693147180560.69314718056Passed
negative normal1.0682511411.068251141Passed
domaindomaindomainPassed
transition0.999999950.99999995Passed

SHA-256 / 8cdf294e4d867d3fece3560f491c51db6f01b504f8845db06852eaa3c46a0a40

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

Case digest / 7fc89279a384c8551c1770e4e34af9be5b40b53642dafb02c0b9cebb2722e330