?

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

?

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

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}{x \cdot y + z \cdot \left(z + \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.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)} \]
  3. Taylor expanded in x around 0 0.1

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

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

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

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

Alternatives

Alternative 1
Error13.0
Cost2140
\[\begin{array}{l} t_0 := 3 \cdot \left(z \cdot z\right)\\ \mathbf{if}\;z \cdot z \leq 7.8 \cdot 10^{-175}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \cdot z \leq 4.6 \cdot 10^{-136}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \cdot z \leq 8 \cdot 10^{-67}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \cdot z \leq 3.1 \cdot 10^{-36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \cdot z \leq 2.5 \cdot 10^{-6}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \cdot z \leq 2.55 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \cdot z \leq 3.8 \cdot 10^{+106}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error13.2
Cost2140
\[\begin{array}{l} t_0 := 3 \cdot \left(z \cdot z\right)\\ \mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-182}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{-136}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{-71}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{-7}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+65}:\\ \;\;\;\;z \cdot \left(3 \cdot z\right)\\ \mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+106}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error24.3
Cost192
\[y \cdot x \]

Error

Reproduce?

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