| Alternative 1 | |
|---|---|
| Error | 9.9 |
| Cost | 196 |
\[\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq 50:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;0\\
\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 | 196 |
| Alternative 2 | |
|---|---|
| Error | 20.6 |
| Cost | 32 |
herbie shell --seed 2022338
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))