FAILURE MAP
← Case archive

FA-16326 / Floating-point arithmetic / Open access

Relative logarithm uses an inaccurate non-log1p branch · case 01

Relative logarithm uses an inaccurate non-log1p branch.

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

ROOT CAUSE

Relative logarithm uses an inaccurate non-log1p branch. The faulty expression is result=math.log(1+x)/x.

THE FAILURE

Relative logarithm uses an inaccurate non-log1p branch. The faulty expression is result=math.log(1+x)/x.

Unsuccessful approach: The attempted local correction result=math.log(1+abs(x))/abs(x) 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 '1'
        if abs(x)<1e-8:
            result=1-x/2+x*x/3
        else:
            result=math.log(1+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.999999950580.99999995Failed

SHA-256 / 333175b2e96e5e002516970fab113964f6f8c992fb31426a09a3f787731444c8

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 '1'
        if abs(x)<1e-8:
            result=1-x/2+x*x/3
        else:
            result=math.log(1+abs(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('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 normal0.942264285251.068251141Failed
domaindomaindomainPassed
transition0.999999950580.99999995Failed

SHA-256 / 0cb83a3ab60314b36e3ef6d3a1e0e2f1c1e32e701c671c4fe9683f84379c6167

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

Case digest / 93fea2c19930a358569733022f8889e34280a27a3e6421ebc479e9d4fbf61380