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.
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| negative huge | arithmetic-error | 0 | Failed |
| positive huge | arithmetic-error | 1 | Failed |
| negative tail | 7.0954741623e-23 | 7.0954741623e-23 | Passed |
| zero | 0.5 | 0.5 | Passed |
| positive moderate | 0.73105857863 | 0.73105857863 | Passed |
| negative moderate | 0.26894142137 | 0.26894142137 | Passed |
| small | 0.5000000025 | 0.5000000025 | Passed |
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| negative huge | 0 | 0 | Passed |
| positive huge | arithmetic-error | 1 | Failed |
| negative tail | 7.0954741623e-23 | 7.0954741623e-23 | Passed |
| zero | 0.5 | 0.5 | Passed |
| positive moderate | 0.73105857863 | 0.73105857863 | Passed |
| negative moderate | 0.26894142137 | 0.26894142137 | Passed |
| small | 0.5000000025 | 0.5000000025 | Passed |
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| negative huge | 0 | 0 | Passed |
| positive huge | 1 | 1 | Passed |
| negative tail | 7.0954741623e-23 | 7.0954741623e-23 | Passed |
| zero | 0.5 | 0.5 | Passed |
| positive moderate | 0.73105857863 | 0.73105857863 | Passed |
| negative moderate | 0.26894142137 | 0.26894142137 | Passed |
| small | 0.5000000025 | 0.5000000025 | Passed |
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