| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 3456 |
\[\frac{1}{e^{\frac{-x}{s}} + 1}
\]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s) :precision binary32 (exp (- (log1p (exp (/ (- x) s))))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
float code(float x, float s) {
return expf(-log1pf(expf((-x / s))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function code(x, s) return exp(Float32(-log1p(exp(Float32(Float32(-x) / s))))) end
\frac{1}{1 + e^{\frac{-x}{s}}}
e^{-\mathsf{log1p}\left(e^{\frac{-x}{s}}\right)}
Results
Initial program 0.1
Applied egg-rr0.1
Applied egg-rr0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 3456 |
| Alternative 2 | |
|---|---|
| Error | 1.4 |
| Cost | 516 |
| Alternative 3 | |
|---|---|
| Error | 9.9 |
| Cost | 196 |
| Alternative 4 | |
|---|---|
| Error | 20.7 |
| Cost | 32 |

herbie shell --seed 2022228
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))