| Alternative 1 | |
|---|---|
| Error | 1.2 |
| Cost | 6688 |
\[\frac{1}{s \cdot \left(3 + e^{\frac{\left|x\right|}{s}}\right)}
\]
(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 (/ s t_0)) (+ 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 + (s / t_0)) * (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 + (s / t_0)) * (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(s / t_0)) * 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 + (s / t_0)) * (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{s}{t_0}\right) \cdot \left(1 + t_0\right)}
\end{array}
Results
Initial program 0.1
Simplified0.2
[Start]0.1 | \[ \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.1 | \[ \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.1 | \[ \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.1 | \[ \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.1 | \[ \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.1 | \[ \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.6
Simplified0.1
[Start]11.6 | \[ \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.6 | \[ \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)}}
\] |
*-lft-identity [<=]11.6 | \[ \frac{1}{\color{blue}{1 \cdot \left(s + \frac{s}{e^{\frac{x}{s}}}\right)} + e^{\frac{x}{s}} \cdot \left(s + \frac{s}{e^{\frac{x}{s}}}\right)}
\] |
distribute-rgt-in [<=]0.1 | \[ \frac{1}{\color{blue}{\left(s + \frac{s}{e^{\frac{x}{s}}}\right) \cdot \left(1 + e^{\frac{x}{s}}\right)}}
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 1.2 |
| Cost | 6688 |
| Alternative 2 | |
|---|---|
| Error | 1.8 |
| Cost | 6656 |
| Alternative 3 | |
|---|---|
| Error | 1.3 |
| Cost | 3684 |
| Alternative 4 | |
|---|---|
| Error | 1.3 |
| Cost | 3652 |
| Alternative 5 | |
|---|---|
| Error | 2.6 |
| Cost | 3556 |
| Alternative 6 | |
|---|---|
| Error | 3.0 |
| Cost | 3492 |
| Alternative 7 | |
|---|---|
| Error | 5.1 |
| Cost | 3428 |
| Alternative 8 | |
|---|---|
| Error | 6.9 |
| Cost | 813 |
| Alternative 9 | |
|---|---|
| Error | 11.4 |
| Cost | 544 |
| Alternative 10 | |
|---|---|
| Error | 11.4 |
| Cost | 544 |
| Alternative 11 | |
|---|---|
| Error | 11.4 |
| Cost | 416 |
| Alternative 12 | |
|---|---|
| Error | 12.1 |
| Cost | 361 |
| Alternative 13 | |
|---|---|
| Error | 23.4 |
| Cost | 96 |
herbie shell --seed 2023057
(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))))))