| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13184 |
\[{\left(\frac{1}{1 + e^{x}}\right)}^{-0.5}
\]

(FPCore (x) :precision binary64 (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))
(FPCore (x) :precision binary64 (pow (/ 1.0 (+ 1.0 (exp x))) -0.5))
double code(double x) {
return sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
}
double code(double x) {
return pow((1.0 / (1.0 + exp(x))), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(((exp((2.0d0 * x)) - 1.0d0) / (exp(x) - 1.0d0)))
end function
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (1.0d0 + exp(x))) ** (-0.5d0)
end function
public static double code(double x) {
return Math.sqrt(((Math.exp((2.0 * x)) - 1.0) / (Math.exp(x) - 1.0)));
}
public static double code(double x) {
return Math.pow((1.0 / (1.0 + Math.exp(x))), -0.5);
}
def code(x): return math.sqrt(((math.exp((2.0 * x)) - 1.0) / (math.exp(x) - 1.0)))
def code(x): return math.pow((1.0 / (1.0 + math.exp(x))), -0.5)
function code(x) return sqrt(Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0))) end
function code(x) return Float64(1.0 / Float64(1.0 + exp(x))) ^ -0.5 end
function tmp = code(x) tmp = sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0))); end
function tmp = code(x) tmp = (1.0 / (1.0 + exp(x))) ^ -0.5; end
code[x_] := N[Sqrt[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Power[N[(1.0 / N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
{\left(\frac{1}{1 + e^{x}}\right)}^{-0.5}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 3.9%
Simplified100.0%
[Start]3.9% | \[ \sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\] |
|---|---|
*-commutative [=>]3.9% | \[ \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}}
\] |
exp-lft-sqr [=>]4.4% | \[ \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}}
\] |
difference-of-sqr-1 [=>]4.7% | \[ \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}}
\] |
associate-/l* [=>]4.7% | \[ \sqrt{\color{blue}{\frac{e^{x} + 1}{\frac{e^{x} - 1}{e^{x} - 1}}}}
\] |
*-inverses [=>]100.0% | \[ \sqrt{\frac{e^{x} + 1}{\color{blue}{1}}}
\] |
/-rgt-identity [=>]100.0% | \[ \sqrt{\color{blue}{e^{x} + 1}}
\] |
+-commutative [=>]100.0% | \[ \sqrt{\color{blue}{1 + e^{x}}}
\] |
Applied egg-rr100.0%
[Start]100.0% | \[ \sqrt{1 + e^{x}}
\] |
|---|---|
pow1/2 [=>]100.0% | \[ \color{blue}{{\left(1 + e^{x}\right)}^{0.5}}
\] |
+-commutative [=>]100.0% | \[ {\color{blue}{\left(e^{x} + 1\right)}}^{0.5}
\] |
flip-+ [=>]4.4% | \[ {\color{blue}{\left(\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} - 1}\right)}}^{0.5}
\] |
metadata-eval [=>]4.4% | \[ {\left(\frac{e^{x} \cdot e^{x} - \color{blue}{1}}{e^{x} - 1}\right)}^{0.5}
\] |
prod-exp [=>]3.9% | \[ {\left(\frac{\color{blue}{e^{x + x}} - 1}{e^{x} - 1}\right)}^{0.5}
\] |
expm1-udef [<=]5.4% | \[ {\left(\frac{\color{blue}{\mathsf{expm1}\left(x + x\right)}}{e^{x} - 1}\right)}^{0.5}
\] |
expm1-udef [<=]68.3% | \[ {\left(\frac{\mathsf{expm1}\left(x + x\right)}{\color{blue}{\mathsf{expm1}\left(x\right)}}\right)}^{0.5}
\] |
clear-num [=>]68.3% | \[ {\color{blue}{\left(\frac{1}{\frac{\mathsf{expm1}\left(x\right)}{\mathsf{expm1}\left(x + x\right)}}\right)}}^{0.5}
\] |
inv-pow [=>]68.3% | \[ {\color{blue}{\left({\left(\frac{\mathsf{expm1}\left(x\right)}{\mathsf{expm1}\left(x + x\right)}\right)}^{-1}\right)}}^{0.5}
\] |
metadata-eval [<=]68.3% | \[ {\left({\left(\frac{\mathsf{expm1}\left(x\right)}{\mathsf{expm1}\left(x + x\right)}\right)}^{\color{blue}{\left(-1\right)}}\right)}^{0.5}
\] |
pow-pow [=>]68.4% | \[ \color{blue}{{\left(\frac{\mathsf{expm1}\left(x\right)}{\mathsf{expm1}\left(x + x\right)}\right)}^{\left(\left(-1\right) \cdot 0.5\right)}}
\] |
clear-num [=>]68.4% | \[ {\color{blue}{\left(\frac{1}{\frac{\mathsf{expm1}\left(x + x\right)}{\mathsf{expm1}\left(x\right)}}\right)}}^{\left(\left(-1\right) \cdot 0.5\right)}
\] |
expm1-udef [=>]5.5% | \[ {\left(\frac{1}{\frac{\color{blue}{e^{x + x} - 1}}{\mathsf{expm1}\left(x\right)}}\right)}^{\left(\left(-1\right) \cdot 0.5\right)}
\] |
prod-exp [<=]5.4% | \[ {\left(\frac{1}{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{\mathsf{expm1}\left(x\right)}}\right)}^{\left(\left(-1\right) \cdot 0.5\right)}
\] |
metadata-eval [<=]5.4% | \[ {\left(\frac{1}{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{\mathsf{expm1}\left(x\right)}}\right)}^{\left(\left(-1\right) \cdot 0.5\right)}
\] |
expm1-udef [=>]4.4% | \[ {\left(\frac{1}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}}\right)}^{\left(\left(-1\right) \cdot 0.5\right)}
\] |
flip-+ [<=]100.0% | \[ {\left(\frac{1}{\color{blue}{e^{x} + 1}}\right)}^{\left(\left(-1\right) \cdot 0.5\right)}
\] |
+-commutative [<=]100.0% | \[ {\left(\frac{1}{\color{blue}{1 + e^{x}}}\right)}^{\left(\left(-1\right) \cdot 0.5\right)}
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 13184 |
| Alternative 2 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 12992 |
| Alternative 3 | |
|---|---|
| Accuracy | 91.0% |
| Cost | 7812 |
| Alternative 4 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 7040 |
| Alternative 5 | |
|---|---|
| Accuracy | 83.3% |
| Cost | 6916 |
| Alternative 6 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 6852 |
| Alternative 7 | |
|---|---|
| Accuracy | 67.8% |
| Cost | 6592 |
| Alternative 8 | |
|---|---|
| Accuracy | 66.9% |
| Cost | 6464 |
herbie shell --seed 2023272
(FPCore (x)
:name "sqrtexp (problem 3.4.4)"
:precision binary64
(sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))