| Alternative 1 | |
|---|---|
| Accuracy | 33.1% |
| Cost | 1380 |
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
(FPCore (x y z) :precision binary64 (+ x (fma z y (fma z x y))))
double code(double x, double y, double z) {
return (x + y) * (z + 1.0);
}
double code(double x, double y, double z) {
return x + fma(z, y, fma(z, x, y));
}
function code(x, y, z) return Float64(Float64(x + y) * Float64(z + 1.0)) end
function code(x, y, z) return Float64(x + fma(z, y, fma(z, x, y))) end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(z * y + N[(z * x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x + y\right) \cdot \left(z + 1\right)
x + \mathsf{fma}\left(z, y, \mathsf{fma}\left(z, x, y\right)\right)
Initial program 100.0%
Applied egg-rr100.0%
[Start]100.0 | \[ \left(x + y\right) \cdot \left(z + 1\right)
\] |
|---|---|
distribute-rgt-in [=>]100.0 | \[ \color{blue}{z \cdot \left(x + y\right) + 1 \cdot \left(x + y\right)}
\] |
*-un-lft-identity [<=]100.0 | \[ z \cdot \left(x + y\right) + \color{blue}{\left(x + y\right)}
\] |
+-commutative [=>]100.0 | \[ z \cdot \left(x + y\right) + \color{blue}{\left(y + x\right)}
\] |
associate-+r+ [=>]100.0 | \[ \color{blue}{\left(z \cdot \left(x + y\right) + y\right) + x}
\] |
+-commutative [=>]100.0 | \[ \color{blue}{\left(y + z \cdot \left(x + y\right)\right)} + x
\] |
*-commutative [=>]100.0 | \[ \left(y + \color{blue}{\left(x + y\right) \cdot z}\right) + x
\] |
Applied egg-rr29.6%
[Start]100.0 | \[ \left(y + \left(x + y\right) \cdot z\right) + x
\] |
|---|---|
flip-+ [=>]59.4 | \[ \color{blue}{\frac{y \cdot y - \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)}{y - \left(x + y\right) \cdot z}} + x
\] |
flip-- [=>]32.7 | \[ \frac{\color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right) \cdot \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}{y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)}}}{y - \left(x + y\right) \cdot z} + x
\] |
associate-/l/ [=>]29.6 | \[ \color{blue}{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right) \cdot \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}} + x
\] |
pow2 [=>]29.6 | \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - \color{blue}{{\left(\left(x + y\right) \cdot z\right)}^{2}} \cdot \left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)} + x
\] |
pow2 [=>]29.6 | \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot \color{blue}{{\left(\left(x + y\right) \cdot z\right)}^{2}}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(y \cdot y + \left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)\right)} + x
\] |
+-commutative [=>]29.6 | \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \color{blue}{\left(\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right) + y \cdot y\right)}} + x
\] |
pow2 [=>]29.6 | \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left(\color{blue}{{\left(\left(x + y\right) \cdot z\right)}^{2}} + y \cdot y\right)} + x
\] |
Applied egg-rr100.0%
[Start]29.6 | \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\left(y - \left(x + y\right) \cdot z\right) \cdot \left({\left(\left(x + y\right) \cdot z\right)}^{2} + y \cdot y\right)} + x
\] |
|---|---|
*-commutative [=>]29.6 | \[ \frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\color{blue}{\left({\left(\left(x + y\right) \cdot z\right)}^{2} + y \cdot y\right) \cdot \left(y - \left(x + y\right) \cdot z\right)}} + x
\] |
associate-/r* [=>]32.7 | \[ \color{blue}{\frac{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{{\left(\left(x + y\right) \cdot z\right)}^{2} + y \cdot y}}{y - \left(x + y\right) \cdot z}} + x
\] |
+-commutative [=>]32.7 | \[ \frac{\frac{\left(y \cdot y\right) \cdot \left(y \cdot y\right) - {\left(\left(x + y\right) \cdot z\right)}^{2} \cdot {\left(\left(x + y\right) \cdot z\right)}^{2}}{\color{blue}{y \cdot y + {\left(\left(x + y\right) \cdot z\right)}^{2}}}}{y - \left(x + y\right) \cdot z} + x
\] |
flip-- [<=]59.4 | \[ \frac{\color{blue}{y \cdot y - {\left(\left(x + y\right) \cdot z\right)}^{2}}}{y - \left(x + y\right) \cdot z} + x
\] |
unpow2 [=>]59.4 | \[ \frac{y \cdot y - \color{blue}{\left(\left(x + y\right) \cdot z\right) \cdot \left(\left(x + y\right) \cdot z\right)}}{y - \left(x + y\right) \cdot z} + x
\] |
flip-+ [<=]100.0 | \[ \color{blue}{\left(y + \left(x + y\right) \cdot z\right)} + x
\] |
+-commutative [=>]100.0 | \[ \color{blue}{\left(\left(x + y\right) \cdot z + y\right)} + x
\] |
*-commutative [=>]100.0 | \[ \left(\color{blue}{z \cdot \left(x + y\right)} + y\right) + x
\] |
+-commutative [=>]100.0 | \[ \left(z \cdot \color{blue}{\left(y + x\right)} + y\right) + x
\] |
distribute-rgt-in [=>]100.0 | \[ \left(\color{blue}{\left(y \cdot z + x \cdot z\right)} + y\right) + x
\] |
associate-+l+ [=>]100.0 | \[ \color{blue}{\left(y \cdot z + \left(x \cdot z + y\right)\right)} + x
\] |
Simplified100.0%
[Start]100.0 | \[ \left(y \cdot z + \left(x \cdot z + y\right)\right) + x
\] |
|---|---|
+-commutative [<=]100.0 | \[ \left(y \cdot z + \color{blue}{\left(y + x \cdot z\right)}\right) + x
\] |
*-commutative [<=]100.0 | \[ \left(\color{blue}{z \cdot y} + \left(y + x \cdot z\right)\right) + x
\] |
*-commutative [<=]100.0 | \[ \left(z \cdot y + \left(y + \color{blue}{z \cdot x}\right)\right) + x
\] |
+-commutative [<=]100.0 | \[ \left(z \cdot y + \color{blue}{\left(z \cdot x + y\right)}\right) + x
\] |
fma-def [=>]100.0 | \[ \color{blue}{\mathsf{fma}\left(z, y, z \cdot x + y\right)} + x
\] |
fma-def [=>]100.0 | \[ \mathsf{fma}\left(z, y, \color{blue}{\mathsf{fma}\left(z, x, y\right)}\right) + x
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 33.1% |
| Cost | 1380 |
| Alternative 2 | |
|---|---|
| Accuracy | 49.0% |
| Cost | 720 |
| Alternative 3 | |
|---|---|
| Accuracy | 59.2% |
| Cost | 717 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.3% |
| Cost | 716 |
| Alternative 5 | |
|---|---|
| Accuracy | 97.3% |
| Cost | 716 |
| Alternative 6 | |
|---|---|
| Accuracy | 79.4% |
| Cost | 585 |
| Alternative 7 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 576 |
| Alternative 8 | |
|---|---|
| Accuracy | 79.4% |
| Cost | 456 |
| Alternative 9 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 448 |
| Alternative 10 | |
|---|---|
| Accuracy | 39.4% |
| Cost | 196 |
| Alternative 11 | |
|---|---|
| Accuracy | 32.1% |
| Cost | 64 |
herbie shell --seed 2023137
(FPCore (x y z)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
:precision binary64
(* (+ x y) (+ z 1.0)))