| Alternative 1 | |
|---|---|
| Error | 0.19% |
| Cost | 3456 |
\[\frac{1}{1 + e^{\frac{-x}{s}}}
\]
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
(FPCore (x s) :precision binary32 (/ 1.0 (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 1.0f / 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 Float32(Float32(1.0) / exp(log1p(exp(Float32(Float32(-x) / s))))) end
\frac{1}{1 + e^{\frac{-x}{s}}}
\frac{1}{e^{\mathsf{log1p}\left(e^{\frac{-x}{s}}\right)}}
Results
Initial program 0.19
Applied egg-rr0.21
Applied egg-rr0.2
Simplified0.21
[Start]0.2 | \[ \frac{1}{\frac{1}{e^{-\mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}}
\] |
|---|---|
rec-exp [=>]0.21 | \[ \frac{1}{\color{blue}{e^{-\left(-\mathsf{log1p}\left(e^{-\frac{x}{s}}\right)\right)}}}
\] |
remove-double-neg [=>]0.21 | \[ \frac{1}{e^{\color{blue}{\mathsf{log1p}\left(e^{-\frac{x}{s}}\right)}}}
\] |
distribute-neg-frac [=>]0.21 | \[ \frac{1}{e^{\mathsf{log1p}\left(e^{\color{blue}{\frac{-x}{s}}}\right)}}
\] |
Final simplification0.21
| Alternative 1 | |
|---|---|
| Error | 0.19% |
| Cost | 3456 |
| Alternative 2 | |
|---|---|
| Error | 9.84% |
| Cost | 708 |
| Alternative 3 | |
|---|---|
| Error | 35.86% |
| Cost | 516 |
| Alternative 4 | |
|---|---|
| Error | 9.67% |
| Cost | 516 |
| Alternative 5 | |
|---|---|
| Error | 38.41% |
| Cost | 452 |
| Alternative 6 | |
|---|---|
| Error | 39.64% |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Error | 37.94% |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Error | 50.85% |
| Cost | 388 |
| Alternative 9 | |
|---|---|
| Error | 52.25% |
| Cost | 356 |
| Alternative 10 | |
|---|---|
| Error | 53.6% |
| Cost | 164 |
| Alternative 11 | |
|---|---|
| Error | 64.82% |
| Cost | 32 |
herbie shell --seed 2023102
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))