FAILURE MAP
← Case archive

FA-16146 / Floating-point arithmetic / Open access

Complementary logarithm assigns a finite value at zero · case 01

Complementary logarithm assigns a finite value at zero.

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

ROOT CAUSE

Complementary logarithm assigns a finite value at zero. The faulty expression is if x==0: return '0'.

THE FAILURE

Complementary logarithm assigns a finite value at zero. The faulty expression is if x==0: return '0'.

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

Case contract

Evaluate log(1-exp(x)) for x <= 0; zero maps to negative infinity. Choose a cancellation-safe formula on either side of -log(2). 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 'domain'
        if x==0: return '0'
        if x < -math.log(2):
            result=math.log1p(-math.exp(x))
        else:
            result=math.log(-math.expm1(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('near zero', solve(-N*2.0**-60), render(math.log(N*2.0**-60)))
check('far tail', solve(-50.0-N), render(-math.exp(-50.0-N)))
check('midpoint', solve(-math.log(2)), render(math.log(0.5)))
check('moderate', solve(-1.0), render(math.log1p(-math.exp(-1))))
check('boundary', solve(0.0), "-infinity")
check('invalid', solve(float(N)), "domain")
check('negative zero', solve(-0.0), "-infinity")
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
near zero-41.588830834-41.588830834Passed
far tail-7.0954741623e-23-7.0954741623e-23Passed
midpoint-0.69314718056-0.69314718056Passed
moderate-0.45867514539-0.45867514539Passed
boundary0-infinityFailed
invaliddomaindomainPassed
negative zero0-infinityFailed

SHA-256 / dd3fb18ddd86840546958453d1e66808876239d949f6decc697f17dc530b2bd3

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 'domain'
        if x==0: return 'domain'
        if x < -math.log(2):
            result=math.log1p(-math.exp(x))
        else:
            result=math.log(-math.expm1(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('near zero', solve(-N*2.0**-60), render(math.log(N*2.0**-60)))
check('far tail', solve(-50.0-N), render(-math.exp(-50.0-N)))
check('midpoint', solve(-math.log(2)), render(math.log(0.5)))
check('moderate', solve(-1.0), render(math.log1p(-math.exp(-1))))
check('boundary', solve(0.0), "-infinity")
check('invalid', solve(float(N)), "domain")
check('negative zero', solve(-0.0), "-infinity")
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
near zero-41.588830834-41.588830834Passed
far tail-7.0954741623e-23-7.0954741623e-23Passed
midpoint-0.69314718056-0.69314718056Passed
moderate-0.45867514539-0.45867514539Passed
boundarydomain-infinityFailed
invaliddomaindomainPassed
negative zerodomain-infinityFailed

SHA-256 / d3df8a183d2d5bc4951e8b000a376d16c11259c9b839e643d6cf0d3cf3a4c05a

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / a861ceeb27bd0dd88504981b3302dd66daba1bc026eaa3e948980562dfcdc3d8