Average Error: 0.3 → 0.2
Time: 5.3s
Precision: binary64
Cost: 448
\[\left(\left(x \cdot 3\right) \cdot y\right) \cdot y\]
↓
\[y \cdot \left(x \cdot \left(y \cdot 3\right)\right)\]
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
↓
y \cdot \left(x \cdot \left(y \cdot 3\right)\right)
(FPCore (x y) :precision binary64 (* (* (* x 3.0) y) y))
↓
(FPCore (x y) :precision binary64 (* y (* x (* y 3.0))))
double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
↓
double code(double x, double y) {
return y * (x * (y * 3.0));
}
Try it out
Enter valid numbers for all inputs
Target
| Original | 0.3 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.2 |
|---|
\[\left(x \cdot \left(3 \cdot y\right)\right) \cdot y\]
Alternatives
| Alternative 1 |
|---|
| Error | 1.2 |
|---|
| Cost | 66176 |
|---|
\[\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \left(\sqrt[3]{{\left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\right)}^{2}} \cdot \left(\sqrt[3]{{\left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\right)}^{2}} \cdot \sqrt[3]{{\left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\right)}^{2}}\right)\right)\]
| Alternative 2 |
|---|
| Error | 1.2 |
|---|
| Cost | 46848 |
|---|
\[\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \left(\sqrt[3]{\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}} \cdot {\left(\sqrt[3]{\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}}\right)}^{2}\right)\right)\]
| Alternative 3 |
|---|
| Error | 1.5 |
|---|
| Cost | 39936 |
|---|
\[\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \left(\sqrt[3]{\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}} \cdot {\left(\sqrt[3]{\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}}\right)}^{5}\right)\]
| Alternative 4 |
|---|
| Error | 22.5 |
|---|
| Cost | 39936 |
|---|
\[\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \left(\sqrt{\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}} \cdot {\left(\sqrt{\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}}\right)}^{3}\right)\]
| Alternative 5 |
|---|
| Error | 1.0 |
|---|
| Cost | 33472 |
|---|
\[\left(\sqrt[3]{y} \cdot \sqrt[3]{x \cdot \left(3 \cdot y\right)}\right) \cdot \left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{x \cdot \left(3 \cdot y\right)}\right)\right)\]
| Alternative 6 |
|---|
| Error | 0.9 |
|---|
| Cost | 33472 |
|---|
\[\left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\right) \cdot \left(\sqrt[3]{y} \cdot \left(\sqrt[3]{3} \cdot \sqrt[3]{x \cdot y}\right)\right)\]
| Alternative 7 |
|---|
| Error | 0.9 |
|---|
| Cost | 27072 |
|---|
\[\left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\right) \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{x \cdot \left(3 \cdot y\right)}\right)\]
| Alternative 8 |
|---|
| Error | 0.9 |
|---|
| Cost | 20672 |
|---|
\[\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\right)\]
| Alternative 9 |
|---|
| Error | 11.2 |
|---|
| Cost | 20672 |
|---|
\[\sqrt[3]{\left(x \cdot 3\right) \cdot \left(y \cdot y\right)} \cdot \left(\sqrt[3]{\left(x \cdot 3\right) \cdot \left(y \cdot y\right)} \cdot \sqrt[3]{\left(x \cdot 3\right) \cdot \left(y \cdot y\right)}\right)\]
| Alternative 10 |
|---|
| Error | 0.9 |
|---|
| Cost | 20416 |
|---|
\[y \cdot \left(\sqrt[3]{\left(x \cdot 3\right) \cdot y} \cdot \left(\sqrt[3]{\left(x \cdot 3\right) \cdot y} \cdot \sqrt[3]{\left(x \cdot 3\right) \cdot y}\right)\right)\]
| Alternative 11 |
|---|
| Error | 0.9 |
|---|
| Cost | 20224 |
|---|
\[\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot {\left(\sqrt[3]{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\right)}^{2}\]
| Alternative 12 |
|---|
| Error | 0.9 |
|---|
| Cost | 19904 |
|---|
\[y \cdot \left(\sqrt[3]{y} \cdot \left(\left(x \cdot 3\right) \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)\right)\right)\]
| Alternative 13 |
|---|
| Error | 22.2 |
|---|
| Cost | 13760 |
|---|
\[\sqrt{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)} \cdot \sqrt{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\]
| Alternative 14 |
|---|
| Error | 27.1 |
|---|
| Cost | 13760 |
|---|
\[\sqrt{\left(x \cdot 3\right) \cdot \left(y \cdot y\right)} \cdot \sqrt{\left(x \cdot 3\right) \cdot \left(y \cdot y\right)}\]
| Alternative 15 |
|---|
| Error | 27.7 |
|---|
| Cost | 13632 |
|---|
\[y \cdot \left(\sqrt{\left(x \cdot 3\right) \cdot y} \cdot \sqrt{\left(x \cdot 3\right) \cdot y}\right)\]
| Alternative 16 |
|---|
| Error | 32.2 |
|---|
| Cost | 13376 |
|---|
\[y \cdot \left(\sqrt{y} \cdot \left(\left(x \cdot 3\right) \cdot \sqrt{y}\right)\right)\]
| Alternative 17 |
|---|
| Error | 18.6 |
|---|
| Cost | 13312 |
|---|
\[y \cdot \sqrt[3]{{\left(\left(x \cdot 3\right) \cdot y\right)}^{3}}\]
| Alternative 18 |
|---|
| Error | 29.3 |
|---|
| Cost | 13312 |
|---|
\[\sqrt[3]{{\left(\left(x \cdot 3\right) \cdot \left(y \cdot y\right)\right)}^{3}}\]
| Alternative 19 |
|---|
| Error | 10.7 |
|---|
| Cost | 448 |
|---|
\[x \cdot \left(3 \cdot \left(y \cdot y\right)\right)\]
| Alternative 20 |
|---|
| Error | 10.7 |
|---|
| Cost | 448 |
|---|
\[\left(x \cdot 3\right) \cdot \left(y \cdot y\right)\]
| Alternative 21 |
|---|
| Error | 0.3 |
|---|
| Cost | 448 |
|---|
\[y \cdot \left(\left(x \cdot 3\right) \cdot y\right)\]
| Alternative 22 |
|---|
| Error | 0.2 |
|---|
| Cost | 448 |
|---|
\[y \cdot \left(x \cdot \left(3 \cdot y\right)\right)\]
| Alternative 23 |
|---|
| Error | 61.8 |
|---|
| Cost | 64 |
|---|
\[1\]
| Alternative 24 |
|---|
| Error | 41.7 |
|---|
| Cost | 64 |
|---|
\[0\]
| Alternative 25 |
|---|
| Error | 61.8 |
|---|
| Cost | 64 |
|---|
\[-1\]
Error

Derivation
Initial program 0.3
\[\left(\left(x \cdot 3\right) \cdot y\right) \cdot y\]
- Using strategy
rm Applied associate-*l*_binary64_193260.2
\[\leadsto \color{blue}{\left(x \cdot \left(3 \cdot y\right)\right)} \cdot y\]
Simplified0.2
\[\leadsto \color{blue}{y \cdot \left(x \cdot \left(3 \cdot y\right)\right)}\]
Final simplification0.2
\[\leadsto y \cdot \left(x \cdot \left(y \cdot 3\right)\right)\]
Reproduce
herbie shell --seed 2021042
(FPCore (x y)
:name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, B"
:precision binary64
:herbie-target
(* (* x (* 3.0 y)) y)
(* (* (* x 3.0) y) y))