?

Average Error: 0.0 → 0.0
Time: 7.2s
Precision: binary64
Cost: 448

?

\[2 \cdot \left(x \cdot x - x \cdot y\right) \]
\[\left(y - x\right) \cdot \left(-2 \cdot x\right) \]
(FPCore (x y) :precision binary64 (* 2.0 (- (* x x) (* x y))))
(FPCore (x y) :precision binary64 (* (- y x) (* -2.0 x)))
double code(double x, double y) {
	return 2.0 * ((x * x) - (x * y));
}
double code(double x, double y) {
	return (y - x) * (-2.0 * x);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 2.0d0 * ((x * x) - (x * y))
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (y - x) * ((-2.0d0) * x)
end function
public static double code(double x, double y) {
	return 2.0 * ((x * x) - (x * y));
}
public static double code(double x, double y) {
	return (y - x) * (-2.0 * x);
}
def code(x, y):
	return 2.0 * ((x * x) - (x * y))
def code(x, y):
	return (y - x) * (-2.0 * x)
function code(x, y)
	return Float64(2.0 * Float64(Float64(x * x) - Float64(x * y)))
end
function code(x, y)
	return Float64(Float64(y - x) * Float64(-2.0 * x))
end
function tmp = code(x, y)
	tmp = 2.0 * ((x * x) - (x * y));
end
function tmp = code(x, y)
	tmp = (y - x) * (-2.0 * x);
end
code[x_, y_] := N[(2.0 * N[(N[(x * x), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(y - x), $MachinePrecision] * N[(-2.0 * x), $MachinePrecision]), $MachinePrecision]
2 \cdot \left(x \cdot x - x \cdot y\right)
\left(y - x\right) \cdot \left(-2 \cdot x\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.0
\[\left(x \cdot 2\right) \cdot \left(x - y\right) \]

Derivation?

  1. Initial program 0.0

    \[2 \cdot \left(x \cdot x - x \cdot y\right) \]
  2. Applied egg-rr0.0

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

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

    [Start]0.0

    \[ x \cdot \left(x - y\right) + x \cdot \left(x - y\right) \]

    rational.json-simplify-7 [<=]0.0

    \[ x \cdot \left(x - y\right) + \color{blue}{\frac{x \cdot \left(x - y\right)}{1}} \]

    rational.json-simplify-30 [<=]0.0

    \[ \color{blue}{\left(1 + 1\right) \cdot \frac{x \cdot \left(x - y\right)}{1}} \]

    metadata-eval [=>]0.0

    \[ \color{blue}{2} \cdot \frac{x \cdot \left(x - y\right)}{1} \]

    metadata-eval [<=]0.0

    \[ \color{blue}{\left(1 - -1\right)} \cdot \frac{x \cdot \left(x - y\right)}{1} \]

    rational.json-simplify-7 [=>]0.0

    \[ \left(1 - -1\right) \cdot \color{blue}{\left(x \cdot \left(x - y\right)\right)} \]

    rational.json-simplify-5 [<=]0.0

    \[ \left(1 - -1\right) \cdot \left(x \cdot \left(x - \color{blue}{\left(y - 0\right)}\right)\right) \]

    rational.json-simplify-45 [<=]0.0

    \[ \left(1 - -1\right) \cdot \left(x \cdot \color{blue}{\left(0 - \left(y - x\right)\right)}\right) \]

    rational.json-simplify-12 [<=]0.0

    \[ \left(1 - -1\right) \cdot \left(x \cdot \color{blue}{\left(-\left(y - x\right)\right)}\right) \]

    rational.json-simplify-10 [=>]0.0

    \[ \left(1 - -1\right) \cdot \left(x \cdot \color{blue}{\frac{y - x}{-1}}\right) \]

    rational.json-simplify-49 [<=]0.0

    \[ \left(1 - -1\right) \cdot \color{blue}{\frac{\left(y - x\right) \cdot x}{-1}} \]

    rational.json-simplify-2 [<=]0.0

    \[ \left(1 - -1\right) \cdot \frac{\color{blue}{x \cdot \left(y - x\right)}}{-1} \]

    rational.json-simplify-32 [=>]0.0

    \[ \color{blue}{\frac{x \cdot \left(y - x\right)}{-1} - x \cdot \left(y - x\right)} \]

    rational.json-simplify-49 [=>]0.0

    \[ \color{blue}{\left(y - x\right) \cdot \frac{x}{-1}} - x \cdot \left(y - x\right) \]

    rational.json-simplify-52 [=>]0.0

    \[ \color{blue}{\left(y - x\right) \cdot \left(\frac{x}{-1} - x\right)} \]

    rational.json-simplify-11 [=>]0.0

    \[ \left(y - x\right) \cdot \left(\color{blue}{\left(-x\right)} - x\right) \]

    rational.json-simplify-9 [<=]0.0

    \[ \left(y - x\right) \cdot \left(\color{blue}{x \cdot -1} - x\right) \]

    rational.json-simplify-6 [<=]0.0

    \[ \left(y - x\right) \cdot \left(x \cdot -1 - \color{blue}{1 \cdot x}\right) \]

    rational.json-simplify-52 [=>]0.0

    \[ \left(y - x\right) \cdot \color{blue}{\left(x \cdot \left(-1 - 1\right)\right)} \]

    metadata-eval [=>]0.0

    \[ \left(y - x\right) \cdot \left(x \cdot \color{blue}{-2}\right) \]

    rational.json-simplify-2 [=>]0.0

    \[ \left(y - x\right) \cdot \color{blue}{\left(-2 \cdot x\right)} \]
  4. Final simplification0.0

    \[\leadsto \left(y - x\right) \cdot \left(-2 \cdot x\right) \]

Alternatives

Alternative 1
Error0.0
Cost448
\[2 \cdot \left(x \cdot \left(x - y\right)\right) \]
Alternative 2
Error22.3
Cost320
\[y \cdot \left(x \cdot -2\right) \]

Error

Reproduce?

herbie shell --seed 2023064 
(FPCore (x y)
  :name "Linear.Matrix:fromQuaternion from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (* (* x 2.0) (- x y))

  (* 2.0 (- (* x x) (* x y))))