| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 12992 |
\[\sqrt{1 + e^{x}}
\]
(FPCore (x) :precision binary64 (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))
(FPCore (x) :precision binary64 (sqrt (+ 2.0 (expm1 x))))
double code(double x) {
return sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
}
double code(double x) {
return sqrt((2.0 + expm1(x)));
}
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.sqrt((2.0 + Math.expm1(x)));
}
def code(x): return math.sqrt(((math.exp((2.0 * x)) - 1.0) / (math.exp(x) - 1.0)))
def code(x): return math.sqrt((2.0 + math.expm1(x)))
function code(x) return sqrt(Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0))) end
function code(x) return sqrt(Float64(2.0 + expm1(x))) 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[Sqrt[N[(2.0 + N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\sqrt{2 + \mathsf{expm1}\left(x\right)}
Results
Initial program 35.7%
Simplified99.9%
[Start]35.7 | \[ \sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\] |
|---|---|
*-commutative [=>]35.7 | \[ \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}}
\] |
exp-lft-sqr [=>]36.1 | \[ \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}}
\] |
difference-of-sqr-1 [=>]36.7 | \[ \sqrt{\frac{\color{blue}{\left(e^{x} + 1\right) \cdot \left(e^{x} - 1\right)}}{e^{x} - 1}}
\] |
associate-/l* [=>]36.7 | \[ \sqrt{\color{blue}{\frac{e^{x} + 1}{\frac{e^{x} - 1}{e^{x} - 1}}}}
\] |
*-inverses [=>]99.9 | \[ \sqrt{\frac{e^{x} + 1}{\color{blue}{1}}}
\] |
/-rgt-identity [=>]99.9 | \[ \sqrt{\color{blue}{e^{x} + 1}}
\] |
+-commutative [=>]99.9 | \[ \sqrt{\color{blue}{1 + e^{x}}}
\] |
Applied egg-rr99.9%
[Start]99.9 | \[ \sqrt{1 + e^{x}}
\] |
|---|---|
expm1-log1p-u [=>]98.9 | \[ \sqrt{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(1 + e^{x}\right)\right)}}
\] |
expm1-udef [=>]98.9 | \[ \sqrt{\color{blue}{e^{\mathsf{log1p}\left(1 + e^{x}\right)} - 1}}
\] |
log1p-udef [=>]99.9 | \[ \sqrt{e^{\color{blue}{\log \left(1 + \left(1 + e^{x}\right)\right)}} - 1}
\] |
add-exp-log [<=]99.9 | \[ \sqrt{\color{blue}{\left(1 + \left(1 + e^{x}\right)\right)} - 1}
\] |
Simplified99.9%
[Start]99.9 | \[ \sqrt{\left(1 + \left(1 + e^{x}\right)\right) - 1}
\] |
|---|---|
associate-+r+ [=>]99.9 | \[ \sqrt{\color{blue}{\left(\left(1 + 1\right) + e^{x}\right)} - 1}
\] |
metadata-eval [=>]99.9 | \[ \sqrt{\left(\color{blue}{2} + e^{x}\right) - 1}
\] |
associate--l+ [=>]99.9 | \[ \sqrt{\color{blue}{2 + \left(e^{x} - 1\right)}}
\] |
expm1-def [=>]99.9 | \[ \sqrt{2 + \color{blue}{\mathsf{expm1}\left(x\right)}}
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 99.9% |
| Cost | 12992 |
| Alternative 2 | |
|---|---|
| Accuracy | 72.3% |
| Cost | 6464 |
herbie shell --seed 2023141
(FPCore (x)
:name "sqrtexp (problem 3.4.4)"
:precision binary64
(sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))