| Alternative 1 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 13184 |
\[\mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right)
\]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x) :precision binary64 (fma x x (* (pow x 4.0) (+ (* x (* x 0.002777777777777778)) 0.08333333333333333))))
double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
return fma(x, x, (pow(x, 4.0) * ((x * (x * 0.002777777777777778)) + 0.08333333333333333)));
}
function code(x) return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) end
function code(x) return fma(x, x, Float64((x ^ 4.0) * Float64(Float64(x * Float64(x * 0.002777777777777778)) + 0.08333333333333333))) end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x * x + N[(N[Power[x, 4.0], $MachinePrecision] * N[(N[(x * N[(x * 0.002777777777777778), $MachinePrecision]), $MachinePrecision] + 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(x, x, {x}^{4} \cdot \left(x \cdot \left(x \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)
| Original | 53.4% |
|---|---|
| Target | 99.9% |
| Herbie | 99.0% |
Initial program 53.4%
Taylor expanded in x around 0 99.0%
Simplified99.0%
[Start]99.0 | \[ 0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
|---|---|
+-commutative [=>]99.0 | \[ \color{blue}{\left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right) + 0.002777777777777778 \cdot {x}^{6}}
\] |
associate-+l+ [=>]99.0 | \[ \color{blue}{{x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}\right)}
\] |
unpow2 [=>]99.0 | \[ \color{blue}{x \cdot x} + \left(0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}\right)
\] |
fma-def [=>]99.0 | \[ \color{blue}{\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}\right)}
\] |
fma-def [=>]99.0 | \[ \mathsf{fma}\left(x, x, \color{blue}{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, 0.002777777777777778 \cdot {x}^{6}\right)}\right)
\] |
Applied egg-rr99.0%
[Start]99.0 | \[ \mathsf{fma}\left(x, x, \mathsf{fma}\left(0.08333333333333333, {x}^{4}, 0.002777777777777778 \cdot {x}^{6}\right)\right)
\] |
|---|---|
fma-udef [=>]99.0 | \[ \mathsf{fma}\left(x, x, \color{blue}{0.08333333333333333 \cdot {x}^{4} + 0.002777777777777778 \cdot {x}^{6}}\right)
\] |
Taylor expanded in x around 0 99.0%
Simplified99.0%
[Start]99.0 | \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{6} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
|---|---|
metadata-eval [<=]99.0 | \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{\color{blue}{\left(2 \cdot 3\right)}} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
pow-sqr [<=]99.0 | \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \color{blue}{\left({x}^{3} \cdot {x}^{3}\right)} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
cube-mult [=>]99.0 | \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \left({x}^{3} \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right) + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
associate-*r* [=>]99.0 | \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \color{blue}{\left(\left({x}^{3} \cdot x\right) \cdot \left(x \cdot x\right)\right)} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
pow-plus [=>]99.0 | \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \left(\color{blue}{{x}^{\left(3 + 1\right)}} \cdot \left(x \cdot x\right)\right) + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
metadata-eval [=>]99.0 | \[ \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot \left({x}^{\color{blue}{4}} \cdot \left(x \cdot x\right)\right) + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
associate-*l* [<=]99.0 | \[ \mathsf{fma}\left(x, x, \color{blue}{\left(0.002777777777777778 \cdot {x}^{4}\right) \cdot \left(x \cdot x\right)} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
*-commutative [=>]99.0 | \[ \mathsf{fma}\left(x, x, \color{blue}{\left({x}^{4} \cdot 0.002777777777777778\right)} \cdot \left(x \cdot x\right) + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
associate-*r* [<=]99.0 | \[ \mathsf{fma}\left(x, x, \color{blue}{{x}^{4} \cdot \left(0.002777777777777778 \cdot \left(x \cdot x\right)\right)} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
*-commutative [<=]99.0 | \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot 0.002777777777777778\right)} + 0.08333333333333333 \cdot {x}^{4}\right)
\] |
*-commutative [=>]99.0 | \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.002777777777777778\right) + \color{blue}{{x}^{4} \cdot 0.08333333333333333}\right)
\] |
distribute-lft-out [=>]99.0 | \[ \mathsf{fma}\left(x, x, \color{blue}{{x}^{4} \cdot \left(\left(x \cdot x\right) \cdot 0.002777777777777778 + 0.08333333333333333\right)}\right)
\] |
associate-*l* [=>]99.0 | \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \left(\color{blue}{x \cdot \left(x \cdot 0.002777777777777778\right)} + 0.08333333333333333\right)\right)
\] |
fma-def [=>]99.0 | \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right)}\right)
\] |
Applied egg-rr99.0%
[Start]99.0 | \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right)\right)
\] |
|---|---|
fma-udef [=>]99.0 | \[ \mathsf{fma}\left(x, x, {x}^{4} \cdot \color{blue}{\left(x \cdot \left(x \cdot 0.002777777777777778\right) + 0.08333333333333333\right)}\right)
\] |
Final simplification99.0%
| Alternative 1 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 13184 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 6912 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 192 |
| Alternative 4 | |
|---|---|
| Accuracy | 51.0% |
| Cost | 64 |
herbie shell --seed 2023152
(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))))