?

Average Error: 0.1 → 0.1
Time: 12.2s
Precision: binary64
Cost: 576

?

\[\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 \]
(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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.1
Herbie0.1
\[\left(3 \cdot z\right) \cdot z + y \cdot x \]

Derivation?

  1. Initial program 0.1

    \[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z \]
  2. Simplified0.1

    \[\leadsto \color{blue}{z \cdot z + \left(x \cdot y + z \cdot \left(z + z\right)\right)} \]
    Proof

    [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) \]
  3. Applied egg-rr9.6

    \[\leadsto \color{blue}{z - \left(z - \left(x \cdot y + z \cdot \left(z + \left(z + z\right)\right)\right)\right)} \]
  4. Simplified0.1

    \[\leadsto \color{blue}{\left(z \cdot z\right) \cdot 3 + y \cdot x} \]
    Proof

    [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)} \]
  5. Applied egg-rr0.1

    \[\leadsto \color{blue}{\left(z \cdot \left(z \cdot 3\right) + 0\right)} + y \cdot x \]
  6. Simplified0.1

    \[\leadsto \color{blue}{z \cdot \left(3 \cdot z\right)} + y \cdot x \]
    Proof

    [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 \]
  7. Final simplification0.1

    \[\leadsto z \cdot \left(3 \cdot z\right) + y \cdot x \]

Alternatives

Alternative 1
Error11.2
Cost584
\[\begin{array}{l} t_0 := 3 \cdot \left(z \cdot z\right)\\ \mathbf{if}\;z \leq -0.098:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-57}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error11.2
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -0.125:\\ \;\;\;\;3 \cdot \left(z \cdot z\right)\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-57}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(3 \cdot z\right)\\ \end{array} \]
Alternative 3
Error23.8
Cost192
\[y \cdot x \]

Error

Reproduce?

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)))