| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 448 |
\[y \cdot \left(\left(y \cdot 3\right) \cdot x\right)
\]

(FPCore (x y) :precision binary64 (* (* (* x 3.0) y) y))
(FPCore (x y) :precision binary64 (* y (* (* y 3.0) x)))
double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
double code(double x, double y) {
return y * ((y * 3.0) * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 3.0d0) * y) * y
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * ((y * 3.0d0) * x)
end function
public static double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
public static double code(double x, double y) {
return y * ((y * 3.0) * x);
}
def code(x, y): return ((x * 3.0) * y) * y
def code(x, y): return y * ((y * 3.0) * x)
function code(x, y) return Float64(Float64(Float64(x * 3.0) * y) * y) end
function code(x, y) return Float64(y * Float64(Float64(y * 3.0) * x)) end
function tmp = code(x, y) tmp = ((x * 3.0) * y) * y; end
function tmp = code(x, y) tmp = y * ((y * 3.0) * x); end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]
code[x_, y_] := N[(y * N[(N[(y * 3.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
y \cdot \left(\left(y \cdot 3\right) \cdot x\right)
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 99.7% |
|---|---|
| Target | 99.7% |
| Herbie | 99.7% |
Initial program 99.7%
Applied egg-rr78.2%
[Start]99.7% | \[ \left(\left(x \cdot 3\right) \cdot y\right) \cdot y
\] |
|---|---|
add-cbrt-cube [=>]78.2% | \[ \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot 3\right) \cdot y\right) \cdot \left(\left(x \cdot 3\right) \cdot y\right)\right) \cdot \left(\left(x \cdot 3\right) \cdot y\right)}} \cdot y
\] |
pow3 [=>]78.2% | \[ \sqrt[3]{\color{blue}{{\left(\left(x \cdot 3\right) \cdot y\right)}^{3}}} \cdot y
\] |
*-commutative [=>]78.2% | \[ \sqrt[3]{{\left(\color{blue}{\left(3 \cdot x\right)} \cdot y\right)}^{3}} \cdot y
\] |
associate-*l* [=>]78.2% | \[ \sqrt[3]{{\color{blue}{\left(3 \cdot \left(x \cdot y\right)\right)}}^{3}} \cdot y
\] |
Applied egg-rr99.8%
[Start]78.2% | \[ \sqrt[3]{{\left(3 \cdot \left(x \cdot y\right)\right)}^{3}} \cdot y
\] |
|---|---|
rem-cbrt-cube [=>]99.7% | \[ \color{blue}{\left(3 \cdot \left(x \cdot y\right)\right)} \cdot y
\] |
*-commutative [<=]99.7% | \[ \left(3 \cdot \color{blue}{\left(y \cdot x\right)}\right) \cdot y
\] |
associate-*r* [=>]99.8% | \[ \color{blue}{\left(\left(3 \cdot y\right) \cdot x\right)} \cdot y
\] |
*-commutative [=>]99.8% | \[ \left(\color{blue}{\left(y \cdot 3\right)} \cdot x\right) \cdot y
\] |
Final simplification99.8%
| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 448 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 448 |
herbie shell --seed 2023245
(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))