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