| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 6848 |
\[\frac{1}{s \cdot \left(e^{\frac{x}{s}} + \left(2 + e^{\frac{-x}{s}}\right)\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 (+ t_0 (+ 2.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 * (t_0 + (2.0f + (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 * (t_0 + (2.0e0 + (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(s * Float32(t_0 + Float32(Float32(2.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 * (t_0 + (single(2.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}{s \cdot \left(t_0 + \left(2 + \frac{1}{t_0}\right)\right)}
\end{array}
Results
Initial program 0.1
Simplified0.1
[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.1 | \[ \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.1 | \[ \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
Taylor expanded in s around 0 11.6
Simplified0.1
[Start]11.6 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + \left(1 + e^{\frac{x}{s}} \cdot \left(1 + \frac{1}{e^{\frac{x}{s}}}\right)\right) \cdot s}
\] |
|---|---|
*-commutative [=>]11.6 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + \color{blue}{s \cdot \left(1 + e^{\frac{x}{s}} \cdot \left(1 + \frac{1}{e^{\frac{x}{s}}}\right)\right)}}
\] |
+-commutative [=>]11.6 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + s \cdot \color{blue}{\left(e^{\frac{x}{s}} \cdot \left(1 + \frac{1}{e^{\frac{x}{s}}}\right) + 1\right)}}
\] |
distribute-lft-in [=>]23.4 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + s \cdot \left(\color{blue}{\left(e^{\frac{x}{s}} \cdot 1 + e^{\frac{x}{s}} \cdot \frac{1}{e^{\frac{x}{s}}}\right)} + 1\right)}
\] |
associate-+l+ [=>]23.4 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + s \cdot \color{blue}{\left(e^{\frac{x}{s}} \cdot 1 + \left(e^{\frac{x}{s}} \cdot \frac{1}{e^{\frac{x}{s}}} + 1\right)\right)}}
\] |
*-rgt-identity [=>]23.4 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + s \cdot \left(\color{blue}{e^{\frac{x}{s}}} + \left(e^{\frac{x}{s}} \cdot \frac{1}{e^{\frac{x}{s}}} + 1\right)\right)}
\] |
rgt-mult-inverse [=>]0.1 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + s \cdot \left(e^{\frac{x}{s}} + \left(\color{blue}{1} + 1\right)\right)}
\] |
metadata-eval [=>]0.1 | \[ \frac{1}{\frac{s}{e^{\frac{x}{s}}} + s \cdot \left(e^{\frac{x}{s}} + \color{blue}{2}\right)}
\] |
Taylor expanded in s around 0 0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 6848 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 6848 |
| Alternative 3 | |
|---|---|
| Error | 1.1 |
| Cost | 6688 |
| Alternative 4 | |
|---|---|
| Error | 1.2 |
| Cost | 6688 |
| Alternative 5 | |
|---|---|
| Error | 1.6 |
| Cost | 6656 |
| Alternative 6 | |
|---|---|
| Error | 0.9 |
| Cost | 3812 |
| Alternative 7 | |
|---|---|
| Error | 1.1 |
| Cost | 3620 |
| Alternative 8 | |
|---|---|
| Error | 1.1 |
| Cost | 3620 |
| Alternative 9 | |
|---|---|
| Error | 4.2 |
| Cost | 3556 |
| Alternative 10 | |
|---|---|
| Error | 1.6 |
| Cost | 3556 |
| Alternative 11 | |
|---|---|
| Error | 4.2 |
| Cost | 3492 |
| Alternative 12 | |
|---|---|
| Error | 6.6 |
| Cost | 941 |
| Alternative 13 | |
|---|---|
| Error | 8.4 |
| Cost | 480 |
| Alternative 14 | |
|---|---|
| Error | 15.4 |
| Cost | 425 |
| Alternative 15 | |
|---|---|
| Error | 15.4 |
| Cost | 425 |
| Alternative 16 | |
|---|---|
| Error | 15.8 |
| Cost | 352 |
| Alternative 17 | |
|---|---|
| Error | 22.7 |
| Cost | 224 |
| Alternative 18 | |
|---|---|
| Error | 23.4 |
| Cost | 96 |
herbie shell --seed 2023017
(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))))))