| Alternative 1 | |
|---|---|
| Error | 0.19% |
| 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.19
Applied egg-rr0.24
Applied egg-rr0.14
Simplified0.14
[Start]0.14 | \[ e^{-\mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}
\] |
|---|---|
*-rgt-identity [<=]0.14 | \[ e^{-\color{blue}{\mathsf{log1p}\left(e^{-\frac{x}{s}}\right) \cdot 1}}
\] |
*-rgt-identity [=>]0.14 | \[ e^{-\color{blue}{\mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}
\] |
distribute-neg-frac [=>]0.14 | \[ e^{-\mathsf{log1p}\left(e^{\color{blue}{\frac{-x}{s}}}\right)}
\] |
Final simplification0.14
| Alternative 1 | |
|---|---|
| Error | 0.19% |
| Cost | 3456 |
| Alternative 2 | |
|---|---|
| Error | 36.15% |
| Cost | 708 |
| Alternative 3 | |
|---|---|
| Error | 37.26% |
| Cost | 644 |
| Alternative 4 | |
|---|---|
| Error | 41.56% |
| Cost | 452 |
| Alternative 5 | |
|---|---|
| Error | 39.13% |
| Cost | 452 |
| Alternative 6 | |
|---|---|
| Error | 37.12% |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Error | 37.12% |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Error | 50.52% |
| Cost | 388 |
| Alternative 9 | |
|---|---|
| Error | 51.99% |
| Cost | 356 |
| Alternative 10 | |
|---|---|
| Error | 53.55% |
| Cost | 196 |
| Alternative 11 | |
|---|---|
| Error | 64.63% |
| Cost | 32 |
herbie shell --seed 2023121
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))