| Alternative 1 | |
|---|---|
| Error | 9.9 |
| Cost | 3428 |
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.4999999552572828 \cdot 10^{-35}:\\
\;\;\;\;\frac{e^{\frac{x}{s}}}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\frac{1}{1 + e^{\frac{-x}{s}}}
\frac{1}{1 + e^{\frac{-x}{s}}}
Results
Initial program 0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 9.9 |
| Cost | 3428 |
| Alternative 2 | |
|---|---|
| Error | 12.0 |
| Cost | 292 |
| Alternative 3 | |
|---|---|
| Error | 16.6 |
| Cost | 260 |
| Alternative 4 | |
|---|---|
| Error | 17.0 |
| Cost | 196 |
| Alternative 5 | |
|---|---|
| Error | 20.6 |
| Cost | 32 |
herbie shell --seed 2023064
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))