| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 6880 |
\[\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\frac{1}{\left(1 + t_0\right) \cdot \left(s + \frac{s}{t_0}\right)}
\end{array}
\]
(FPCore (x s) :precision binary32 (/ (exp (/ (- (fabs x)) s)) (* (* s (+ 1.0 (exp (/ (- (fabs x)) s)))) (+ 1.0 (exp (/ (- (fabs x)) s))))))
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x s)))) (/ 1.0 (* (+ s (/ 1.0 (/ t_0 s))) (+ 1.0 t_0)))))
float code(float x, float s) {
return expf((-fabsf(x) / s)) / ((s * (1.0f + expf((-fabsf(x) / s)))) * (1.0f + expf((-fabsf(x) / s))));
}
float code(float x, float s) {
float t_0 = expf((x / s));
return 1.0f / ((s + (1.0f / (t_0 / s))) * (1.0f + t_0));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((-abs(x) / s)) / ((s * (1.0e0 + exp((-abs(x) / s)))) * (1.0e0 + exp((-abs(x) / s))))
end function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((x / s))
code = 1.0e0 / ((s + (1.0e0 / (t_0 / s))) * (1.0e0 + t_0))
end function
function code(x, s) return Float32(exp(Float32(Float32(-abs(x)) / s)) / Float32(Float32(s * Float32(Float32(1.0) + exp(Float32(Float32(-abs(x)) / s)))) * Float32(Float32(1.0) + exp(Float32(Float32(-abs(x)) / s))))) end
function code(x, s) t_0 = exp(Float32(x / s)) return Float32(Float32(1.0) / Float32(Float32(s + Float32(Float32(1.0) / Float32(t_0 / s))) * Float32(Float32(1.0) + t_0))) end
function tmp = code(x, s) tmp = exp((-abs(x) / s)) / ((s * (single(1.0) + exp((-abs(x) / s)))) * (single(1.0) + exp((-abs(x) / s)))); end
function tmp = code(x, s) t_0 = exp((x / s)); tmp = single(1.0) / ((s + (single(1.0) / (t_0 / s))) * (single(1.0) + t_0)); end
\frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\frac{1}{\left(s + \frac{1}{\frac{t_0}{s}}\right) \cdot \left(1 + t_0\right)}
\end{array}
Results
Initial program 0.2
Simplified0.2
[Start]0.2 | \[ \frac{e^{\frac{-\left|x\right|}{s}}}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}
\] |
|---|---|
associate-/l/ [<=]0.2 | \[ \color{blue}{\frac{\frac{e^{\frac{-\left|x\right|}{s}}}{1 + e^{\frac{-\left|x\right|}{s}}}}{s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}}
\] |
*-lft-identity [<=]0.2 | \[ \frac{\color{blue}{1 \cdot \frac{e^{\frac{-\left|x\right|}{s}}}{1 + e^{\frac{-\left|x\right|}{s}}}}}{s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}
\] |
*-lft-identity [<=]0.2 | \[ \frac{1 \cdot \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{1 \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}}}{s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}
\] |
*-commutative [<=]0.2 | \[ \frac{1 \cdot \frac{e^{\frac{-\left|x\right|}{s}}}{\color{blue}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot 1}}}{s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}
\] |
associate-*r/ [=>]0.2 | \[ \frac{\color{blue}{\frac{1 \cdot e^{\frac{-\left|x\right|}{s}}}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot 1}}}{s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}
\] |
associate-/l* [=>]0.2 | \[ \frac{\color{blue}{\frac{1}{\frac{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot 1}{e^{\frac{-\left|x\right|}{s}}}}}}{s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)}
\] |
associate-/l/ [=>]0.2 | \[ \color{blue}{\frac{1}{\left(s \cdot \left(1 + e^{\frac{-\left|x\right|}{s}}\right)\right) \cdot \frac{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot 1}{e^{\frac{-\left|x\right|}{s}}}}}
\] |
Applied egg-rr11.7
Simplified0.2
[Start]11.7 | \[ \frac{1}{s + \left(\frac{s}{e^{\frac{x}{s}}} + e^{\frac{x}{s}} \cdot \left(s + \frac{s}{e^{\frac{x}{s}}}\right)\right)}
\] |
|---|---|
associate-+r+ [=>]11.7 | \[ \frac{1}{\color{blue}{\left(s + \frac{s}{e^{\frac{x}{s}}}\right) + e^{\frac{x}{s}} \cdot \left(s + \frac{s}{e^{\frac{x}{s}}}\right)}}
\] |
distribute-rgt1-in [=>]0.2 | \[ \frac{1}{\color{blue}{\left(e^{\frac{x}{s}} + 1\right) \cdot \left(s + \frac{s}{e^{\frac{x}{s}}}\right)}}
\] |
*-commutative [<=]0.2 | \[ \frac{1}{\color{blue}{\left(s + \frac{s}{e^{\frac{x}{s}}}\right) \cdot \left(e^{\frac{x}{s}} + 1\right)}}
\] |
+-commutative [=>]0.2 | \[ \frac{1}{\left(s + \frac{s}{e^{\frac{x}{s}}}\right) \cdot \color{blue}{\left(1 + e^{\frac{x}{s}}\right)}}
\] |
Applied egg-rr0.6
Applied egg-rr0.2
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 6880 |
| Alternative 2 | |
|---|---|
| Error | 1.2 |
| Cost | 6688 |
| Alternative 3 | |
|---|---|
| Error | 1.7 |
| Cost | 6656 |
| Alternative 4 | |
|---|---|
| Error | 1.4 |
| Cost | 3620 |
| Alternative 5 | |
|---|---|
| Error | 6.6 |
| Cost | 3556 |
| Alternative 6 | |
|---|---|
| Error | 6.3 |
| Cost | 3556 |
| Alternative 7 | |
|---|---|
| Error | 1.4 |
| Cost | 3556 |
| Alternative 8 | |
|---|---|
| Error | 6.8 |
| Cost | 3492 |
| Alternative 9 | |
|---|---|
| Error | 8.1 |
| Cost | 3364 |
| Alternative 10 | |
|---|---|
| Error | 11.9 |
| Cost | 544 |
| Alternative 11 | |
|---|---|
| Error | 22.7 |
| Cost | 288 |
| Alternative 12 | |
|---|---|
| Error | 22.7 |
| Cost | 224 |
| Alternative 13 | |
|---|---|
| Error | 29.2 |
| Cost | 96 |
| Alternative 14 | |
|---|---|
| Error | 23.3 |
| Cost | 96 |
| Alternative 15 | |
|---|---|
| Error | 29.3 |
| Cost | 32 |
herbie shell --seed 2023067
(FPCore (x s)
:name "Logistic distribution"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ (exp (/ (- (fabs x)) s)) (* (* s (+ 1.0 (exp (/ (- (fabs x)) s)))) (+ 1.0 (exp (/ (- (fabs x)) s))))))