| Alternative 1 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 26624.00 |
\[0.002777777777777778 \cdot {x}^{6} + \left(\mathsf{fma}\left(0.08333333333333333, {x}^{4}, 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right) + x \cdot x\right)
\]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x) :precision binary64 (fma 0.002777777777777778 (pow x 6.0) (fma x x (fma 0.08333333333333333 (pow x 4.0) (* 4.96031746031746e-5 (pow x 8.0))))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
return fma(0.002777777777777778, pow(x, 6.0), fma(x, x, fma(0.08333333333333333, pow(x, 4.0), (4.96031746031746e-5 * pow(x, 8.0)))));
}
function code(x) return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) end
function code(x) return fma(0.002777777777777778, (x ^ 6.0), fma(x, x, fma(0.08333333333333333, (x ^ 4.0), Float64(4.96031746031746e-5 * (x ^ 8.0))))) end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision] + N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision] + N[(4.96031746031746e-5 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, \mathsf{fma}\left(0.08333333333333333, {x}^{4}, 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)\right)
| Original | 53.1% |
|---|---|
| Target | 99.9% |
| Herbie | 99.0% |
Initial program 53.1%
Simplified53.1%
[Start]53.1 | \[ \left(e^{x} - 2\right) + e^{-x}
\] |
|---|---|
associate-+l- [=>]53.1 | \[ \color{blue}{e^{x} - \left(2 - e^{-x}\right)}
\] |
sub-neg [=>]53.1 | \[ \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)}
\] |
+-commutative [=>]53.1 | \[ \color{blue}{\left(-\left(2 - e^{-x}\right)\right) + e^{x}}
\] |
neg-sub0 [=>]53.1 | \[ \color{blue}{\left(0 - \left(2 - e^{-x}\right)\right)} + e^{x}
\] |
associate-+l- [=>]53.1 | \[ \color{blue}{0 - \left(\left(2 - e^{-x}\right) - e^{x}\right)}
\] |
associate--l- [=>]53.1 | \[ 0 - \color{blue}{\left(2 - \left(e^{-x} + e^{x}\right)\right)}
\] |
+-commutative [=>]53.1 | \[ 0 - \left(2 - \color{blue}{\left(e^{x} + e^{-x}\right)}\right)
\] |
associate--r+ [=>]53.1 | \[ 0 - \color{blue}{\left(\left(2 - e^{x}\right) - e^{-x}\right)}
\] |
associate--r- [=>]53.1 | \[ \color{blue}{\left(0 - \left(2 - e^{x}\right)\right) + e^{-x}}
\] |
neg-sub0 [<=]53.1 | \[ \color{blue}{\left(-\left(2 - e^{x}\right)\right)} + e^{-x}
\] |
+-commutative [<=]53.1 | \[ \color{blue}{e^{-x} + \left(-\left(2 - e^{x}\right)\right)}
\] |
sub-neg [<=]53.1 | \[ \color{blue}{e^{-x} - \left(2 - e^{x}\right)}
\] |
Taylor expanded in x around 0 99.0%
Simplified99.0%
[Start]99.0 | \[ 0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)
\] |
|---|---|
fma-def [=>]99.0 | \[ \color{blue}{\mathsf{fma}\left(0.002777777777777778, {x}^{6}, {x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)}
\] |
unpow2 [=>]99.0 | \[ \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \color{blue}{x \cdot x} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)
\] |
fma-def [=>]99.0 | \[ \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \color{blue}{\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)}\right)
\] |
fma-def [=>]99.0 | \[ \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)}\right)\right)
\] |
Final simplification99.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 26624.00 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 13632.00 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 13184.00 |
| Alternative 4 | |
|---|---|
| Accuracy | 98.7% |
| Cost | 6912.00 |
| Alternative 5 | |
|---|---|
| Accuracy | 98.1% |
| Cost | 192.00 |
| Alternative 6 | |
|---|---|
| Accuracy | 5.9% |
| Cost | 128.00 |
herbie shell --seed 2023096
(FPCore (x)
:name "exp2 (problem 3.3.7)"
:precision binary64
:herbie-target
(* 4.0 (pow (sinh (/ x 2.0)) 2.0))
(+ (- (exp x) 2.0) (exp (- x))))