FAILURE MAP
← Case archive

FA-16201 / Floating-point arithmetic / Open access

Sigmoid sends large inputs to the overflowing branch · case 01

Sigmoid sends large inputs to the overflowing branch.

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

ROOT CAUSE

Sigmoid sends large inputs to the overflowing branch. The faulty expression is if x<0:.

VERIFIED REPAIR

Apply the contract at this fault site using if x>=0:.

Unsuccessful approach: The attempted local correction if x==0: 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 hugearithmetic-error1Failed
negative tail7.0954741623e-237.0954741623e-23Passed
zero0.50.5Passed
positive moderate0.731058578630.73105857863Passed
negative moderate0.268941421370.26894142137Passed
small0.50000000250.5000000025Passed

SHA-256 / 01ad00eab777c725b8a1a944ad238b7934f053f996d74d22317ba0cec2bfff3a

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(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 hugearithmetic-error1Failed
negative tail7.0954741623e-237.0954741623e-23Passed
zero0.50.5Passed
positive moderate0.731058578630.73105857863Passed
negative moderate0.268941421370.26894142137Passed
small0.50000000250.5000000025Passed

SHA-256 / 0b48b8db009bf90732b4d2556491666a481953749d978ebfff55968846cb6c7a

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

Case digest / 065f3c959d62d3b7e6705833e62466326b346cb77be04722d30d9ef22caef526