FAILURE MAP
← Case archive

FA-16181 / Floating-point arithmetic / Open access

Sigmoid exponentiates the large magnitude of a negative input · case 01

Sigmoid exponentiates the large magnitude of a negative input.

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

ROOT CAUSE

Sigmoid exponentiates the large magnitude of a negative input. The faulty expression is z=math.exp(-x).

VERIFIED REPAIR

Apply the contract at this fault site using z=math.exp(x).

Unsuccessful approach: The attempted local correction z=math.exp(min(-x,700)) still violates the explicit regression fixtures.

Case contract

Evaluate 1/(1+exp(-x)) using a stable branch for negative x. Return a nonnegative probability. 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:
            z=math.exp(-x)
            result=1/(1+z)
        else:
            z=math.exp(-x)
            result=z/(1+z)
        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('negative huge', solve(-1000.0*N), "0")
check('positive huge', solve(1000.0*N), "1")
check('negative tail', solve(-50.0-N), render(math.exp(-50.0-N)))
check('zero', solve(0.0), "0.5")
check('positive moderate', solve(float(N)), render(1/(1+math.exp(-N))))
check('negative moderate', solve(-float(N)), render(1/(1+math.exp(N))))
check('small', solve(N*1e-8), render(1/(1+math.exp(-N*1e-8))))
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
negative hugearithmetic-error0Failed
positive huge11Passed
negative tail17.0954741623e-23Failed
zero0.50.5Passed
positive moderate0.731058578630.73105857863Passed
negative moderate0.731058578630.26894142137Failed
small0.50000000250.5000000025Passed

SHA-256 / 5ede44ccf2ea3f765c3f68ded8aafc42d994e0b7561f68a5bf01388d2b01c5cd

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:
            z=math.exp(-x)
            result=1/(1+z)
        else:
            z=math.exp(min(-x,700))
            result=z/(1+z)
        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('negative huge', solve(-1000.0*N), "0")
check('positive huge', solve(1000.0*N), "1")
check('negative tail', solve(-50.0-N), render(math.exp(-50.0-N)))
check('zero', solve(0.0), "0.5")
check('positive moderate', solve(float(N)), render(1/(1+math.exp(-N))))
check('negative moderate', solve(-float(N)), render(1/(1+math.exp(N))))
check('small', solve(N*1e-8), render(1/(1+math.exp(-N*1e-8))))
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
negative huge10Failed
positive huge11Passed
negative tail17.0954741623e-23Failed
zero0.50.5Passed
positive moderate0.731058578630.73105857863Passed
negative moderate0.731058578630.26894142137Failed
small0.50000000250.5000000025Passed

SHA-256 / c7021a919b653606eaf1f52479863b7b9add2725b64d7d6b5abea003e70ab07a

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:
            z=math.exp(-x)
            result=1/(1+z)
        else:
            z=math.exp(x)
            result=z/(1+z)
        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('negative huge', solve(-1000.0*N), "0")
check('positive huge', solve(1000.0*N), "1")
check('negative tail', solve(-50.0-N), render(math.exp(-50.0-N)))
check('zero', solve(0.0), "0.5")
check('positive moderate', solve(float(N)), render(1/(1+math.exp(-N))))
check('negative moderate', solve(-float(N)), render(1/(1+math.exp(N))))
check('small', solve(N*1e-8), render(1/(1+math.exp(-N*1e-8))))
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
negative huge00Passed
positive huge11Passed
negative tail7.0954741623e-237.0954741623e-23Passed
zero0.50.5Passed
positive moderate0.731058578630.73105857863Passed
negative moderate0.268941421370.26894142137Passed
small0.50000000250.5000000025Passed

SHA-256 / c9a5a17cf9866855ffaceed533977c925032502789c904cb13ea4d0c423043b6

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

Case digest / a3dd8462d95e6dfa5d78643fd225d8ed708b8c3c11109a4047a13f9554a8905d