| Alternative 1 | |
|---|---|
| Error | 13.0 |
| Cost | 2140 |
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
(FPCore (x y z) :precision binary64 (+ (* y x) (* 3.0 (* z 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 (y * x) + (3.0 * (z * 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 = (y * x) + (3.0d0 * (z * 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 (y * x) + (3.0 * (z * z));
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
def code(x, y, z): return (y * x) + (3.0 * (z * 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(y * x) + Float64(3.0 * Float64(z * 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 = (y * x) + (3.0 * (z * 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[(y * x), $MachinePrecision] + N[(3.0 * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
y \cdot x + 3 \cdot \left(z \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.json-simplify-1 [=>]0.1 | \[ \color{blue}{z \cdot z + \left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right)}
\] |
rational.json-simplify-1 [=>]0.1 | \[ z \cdot z + \color{blue}{\left(z \cdot z + \left(x \cdot y + z \cdot z\right)\right)}
\] |
rational.json-simplify-41 [=>]0.1 | \[ z \cdot z + \color{blue}{\left(x \cdot y + \left(z \cdot z + z \cdot z\right)\right)}
\] |
rational.json-simplify-41 [=>]0.1 | \[ \color{blue}{x \cdot y + \left(\left(z \cdot z + z \cdot z\right) + z \cdot z\right)}
\] |
rational.json-simplify-51 [=>]0.1 | \[ x \cdot y + \left(\color{blue}{z \cdot \left(z + z\right)} + z \cdot z\right)
\] |
rational.json-simplify-51 [=>]0.1 | \[ x \cdot y + \color{blue}{z \cdot \left(z + \left(z + z\right)\right)}
\] |
Taylor expanded in x around 0 0.1
Simplified0.1
[Start]0.1 | \[ y \cdot x + z \cdot \left(2 \cdot z + z\right)
\] |
|---|---|
rational.json-simplify-1 [=>]0.1 | \[ y \cdot x + z \cdot \color{blue}{\left(z + 2 \cdot z\right)}
\] |
metadata-eval [<=]0.1 | \[ y \cdot x + z \cdot \left(z + \color{blue}{\left(1 + 1\right)} \cdot z\right)
\] |
rational.json-simplify-7 [<=]0.1 | \[ y \cdot x + z \cdot \left(z + \left(1 + 1\right) \cdot \color{blue}{\frac{z}{1}}\right)
\] |
rational.json-simplify-30 [=>]0.1 | \[ y \cdot x + z \cdot \left(z + \color{blue}{\left(z + \frac{z}{1}\right)}\right)
\] |
rational.json-simplify-7 [=>]0.1 | \[ y \cdot x + z \cdot \left(z + \left(z + \color{blue}{z}\right)\right)
\] |
rational.json-simplify-1 [=>]0.1 | \[ y \cdot x + z \cdot \color{blue}{\left(\left(z + z\right) + z\right)}
\] |
rational.json-simplify-7 [<=]0.1 | \[ y \cdot x + z \cdot \left(\left(z + z\right) + \color{blue}{\frac{z}{1}}\right)
\] |
rational.json-simplify-35 [=>]0.1 | \[ y \cdot x + z \cdot \left(\left(z + z\right) + \color{blue}{\frac{z + z}{1 + 1}}\right)
\] |
metadata-eval [=>]0.1 | \[ y \cdot x + z \cdot \left(\left(z + z\right) + \frac{z + z}{\color{blue}{2}}\right)
\] |
rational.json-simplify-31 [=>]0.1 | \[ y \cdot x + z \cdot \color{blue}{\left(\left(2 + 1\right) \cdot \frac{z + z}{2}\right)}
\] |
metadata-eval [=>]0.1 | \[ y \cdot x + z \cdot \left(\color{blue}{3} \cdot \frac{z + z}{2}\right)
\] |
metadata-eval [<=]0.1 | \[ y \cdot x + z \cdot \left(3 \cdot \frac{z + z}{\color{blue}{1 + 1}}\right)
\] |
rational.json-simplify-35 [<=]0.1 | \[ y \cdot x + z \cdot \left(3 \cdot \color{blue}{\frac{z}{1}}\right)
\] |
rational.json-simplify-7 [=>]0.1 | \[ y \cdot x + z \cdot \left(3 \cdot \color{blue}{z}\right)
\] |
rational.json-simplify-43 [=>]0.1 | \[ y \cdot x + \color{blue}{3 \cdot \left(z \cdot z\right)}
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 13.0 |
| Cost | 2140 |
| Alternative 2 | |
|---|---|
| Error | 13.2 |
| Cost | 2140 |
| Alternative 3 | |
|---|---|
| Error | 24.3 |
| Cost | 192 |
herbie shell --seed 2023068
(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)))