| Alternative 1 | |
|---|---|
| Error | 11.2 |
| Cost | 584 |
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
(FPCore (x y z) :precision binary64 (+ (* z (* 3.0 z)) (* y x)))
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 (z * (3.0 * z)) + (y * x);
}
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 = (z * (3.0d0 * z)) + (y * x)
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 (z * (3.0 * z)) + (y * x);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
def code(x, y, z): return (z * (3.0 * z)) + (y * x)
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(z * Float64(3.0 * z)) + Float64(y * x)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
function tmp = code(x, y, z) tmp = (z * (3.0 * z)) + (y * x); 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[(z * N[(3.0 * z), $MachinePrecision]), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
z \cdot \left(3 \cdot z\right) + y \cdot x
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-simplify-3 [=>]0.1 | \[ \color{blue}{z \cdot z + \left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right)}
\] |
rational_best-simplify-3 [=>]0.1 | \[ z \cdot z + \color{blue}{\left(z \cdot z + \left(x \cdot y + z \cdot z\right)\right)}
\] |
rational_best-simplify-3 [=>]0.1 | \[ z \cdot z + \left(z \cdot z + \color{blue}{\left(z \cdot z + x \cdot y\right)}\right)
\] |
rational_best-simplify-47 [=>]0.1 | \[ z \cdot z + \color{blue}{\left(x \cdot y + \left(z \cdot z + z \cdot z\right)\right)}
\] |
rational_best-simplify-74 [=>]0.1 | \[ z \cdot z + \left(x \cdot y + \color{blue}{z \cdot \left(z + z\right)}\right)
\] |
Applied egg-rr9.6
Simplified0.1
[Start]9.6 | \[ z - \left(z - \left(x \cdot y + z \cdot \left(z + \left(z + z\right)\right)\right)\right)
\] |
|---|---|
rational_best-simplify-66 [=>]9.6 | \[ z - \color{blue}{\left(\left(z - x \cdot y\right) + \left(-z \cdot \left(z + \left(z + z\right)\right)\right)\right)}
\] |
rational_best-simplify-58 [=>]9.6 | \[ \color{blue}{\left(z - \left(-z \cdot \left(z + \left(z + z\right)\right)\right)\right) - \left(z - x \cdot y\right)}
\] |
rational_best-simplify-69 [=>]0.1 | \[ \color{blue}{x \cdot y - \left(-z \cdot \left(z + \left(z + z\right)\right)\right)}
\] |
rational_best-simplify-8 [<=]0.1 | \[ \color{blue}{\frac{x \cdot y}{1}} - \left(-z \cdot \left(z + \left(z + z\right)\right)\right)
\] |
rational_best-simplify-44 [=>]0.1 | \[ \color{blue}{\frac{x \cdot y + x \cdot y}{1 + 1}} - \left(-z \cdot \left(z + \left(z + z\right)\right)\right)
\] |
metadata-eval [=>]0.1 | \[ \frac{x \cdot y + x \cdot y}{\color{blue}{2}} - \left(-z \cdot \left(z + \left(z + z\right)\right)\right)
\] |
rational_best-simplify-77 [=>]0.1 | \[ \color{blue}{\left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right)} - \left(-z \cdot \left(z + \left(z + z\right)\right)\right)
\] |
rational_best-simplify-14 [=>]0.1 | \[ \left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right) - \color{blue}{\left(0 - z \cdot \left(z + \left(z + z\right)\right)\right)}
\] |
rational_best-simplify-75 [=>]0.1 | \[ \left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right) - \left(0 - \color{blue}{\left(z \cdot z + \left(z + z\right) \cdot z\right)}\right)
\] |
rational_best-simplify-1 [<=]0.1 | \[ \left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right) - \left(0 - \left(z \cdot z + \color{blue}{z \cdot \left(z + z\right)}\right)\right)
\] |
rational_best-simplify-58 [=>]0.1 | \[ \left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right) - \color{blue}{\left(\left(0 - z \cdot \left(z + z\right)\right) - z \cdot z\right)}
\] |
rational_best-simplify-75 [=>]0.1 | \[ \left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right) - \left(\left(0 - \color{blue}{\left(z \cdot z + z \cdot z\right)}\right) - z \cdot z\right)
\] |
rational_best-simplify-57 [<=]0.1 | \[ \left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right) - \left(\color{blue}{\left(\left(0 - z \cdot z\right) - z \cdot z\right)} - z \cdot z\right)
\] |
rational_best-simplify-14 [<=]0.1 | \[ \left(\frac{x \cdot y}{2} + \frac{x \cdot y}{2}\right) - \left(\left(\color{blue}{\left(-z \cdot z\right)} - z \cdot z\right) - z \cdot z\right)
\] |
rational_best-simplify-84 [=>]0.1 | \[ \color{blue}{\left(\frac{x \cdot y}{2} + z \cdot z\right) + \left(\frac{x \cdot y}{2} - \left(\left(-z \cdot z\right) - z \cdot z\right)\right)}
\] |
Applied egg-rr0.1
Simplified0.1
[Start]0.1 | \[ \left(z \cdot \left(z \cdot 3\right) + 0\right) + y \cdot x
\] |
|---|---|
rational_best-simplify-3 [=>]0.1 | \[ \color{blue}{\left(0 + z \cdot \left(z \cdot 3\right)\right)} + y \cdot x
\] |
rational_best-simplify-6 [=>]0.1 | \[ \color{blue}{z \cdot \left(z \cdot 3\right)} + y \cdot x
\] |
rational_best-simplify-1 [=>]0.1 | \[ z \cdot \color{blue}{\left(3 \cdot z\right)} + y \cdot x
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 11.2 |
| Cost | 584 |
| Alternative 2 | |
|---|---|
| Error | 11.2 |
| Cost | 584 |
| Alternative 3 | |
|---|---|
| Error | 23.8 |
| Cost | 192 |
herbie shell --seed 2023101
(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)))