| Alternative 1 | |
|---|---|
| Error | 23.7 |
| Cost | 192 |
\[y \cdot x
\]
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
(FPCore (x y z) :precision binary64 (+ (* x y) (* z (* 3.0 z))))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
double code(double x, double y, double z) {
return (x * y) + (z * (3.0 * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * y) + (z * z)) + (z * z)) + (z * z)
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * y) + (z * (3.0d0 * z))
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
public static double code(double x, double y, double z) {
return (x * y) + (z * (3.0 * z));
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
def code(x, y, z): return (x * y) + (z * (3.0 * z))
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function code(x, y, z) return Float64(Float64(x * y) + Float64(z * Float64(3.0 * z))) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
function tmp = code(x, y, z) tmp = (x * y) + (z * (3.0 * z)); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] + N[(z * N[(3.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
x \cdot y + z \cdot \left(3 \cdot z\right)
Results
| Original | 0.1 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.1 | \[ \color{blue}{z \cdot z + \left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.1 | \[ z \cdot z + \color{blue}{\left(z \cdot z + \left(x \cdot y + z \cdot z\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.1 | \[ z \cdot z + \color{blue}{\left(x \cdot y + \left(z \cdot z + z \cdot z\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.1 | \[ \color{blue}{x \cdot y + \left(z \cdot z + \left(z \cdot z + z \cdot z\right)\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]0.1 | \[ x \cdot y + \left(z \cdot z + \color{blue}{z \cdot \left(z + z\right)}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-23 [=>]0.1 | \[ x \cdot y + \color{blue}{z \cdot \left(z + \left(z + z\right)\right)}
\] |
Applied egg-rr0.1
Simplified0.1
[Start]0.1 | \[ x \cdot y + \left(z \cdot \left(z \cdot 3\right) + 0\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-85 [=>]0.1 | \[ x \cdot y + \color{blue}{z \cdot \left(z \cdot 3\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ x \cdot y + z \cdot \color{blue}{\left(3 \cdot z\right)}
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 23.7 |
| Cost | 192 |
herbie shell --seed 2023090
(FPCore (x y z)
:name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
:precision binary64
:herbie-target
(+ (* (* 3.0 z) z) (* y x))
(+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))