?

Average Error: 0.0 → 0.1
Time: 7.2s
Precision: binary64
Cost: 576

?

\[2 \cdot \left(x \cdot x + x \cdot y\right) \]
\[x \cdot \left(x + \left(2 \cdot y + x\right)\right) \]
(FPCore (x y) :precision binary64 (* 2.0 (+ (* x x) (* x y))))
(FPCore (x y) :precision binary64 (* x (+ x (+ (* 2.0 y) x))))
double code(double x, double y) {
	return 2.0 * ((x * x) + (x * y));
}
double code(double x, double y) {
	return x * (x + ((2.0 * y) + 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 = x * (x + ((2.0d0 * y) + 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 x * (x + ((2.0 * y) + x));
}
def code(x, y):
	return 2.0 * ((x * x) + (x * y))
def code(x, y):
	return x * (x + ((2.0 * y) + x))
function code(x, y)
	return Float64(2.0 * Float64(Float64(x * x) + Float64(x * y)))
end
function code(x, y)
	return Float64(x * Float64(x + Float64(Float64(2.0 * y) + x)))
end
function tmp = code(x, y)
	tmp = 2.0 * ((x * x) + (x * y));
end
function tmp = code(x, y)
	tmp = x * (x + ((2.0 * y) + x));
end
code[x_, y_] := N[(2.0 * N[(N[(x * x), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(x * N[(x + N[(N[(2.0 * y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
2 \cdot \left(x \cdot x + x \cdot y\right)
x \cdot \left(x + \left(2 \cdot y + x\right)\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.1
\[\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.1

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

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

    [Start]0.1

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

    rational.json-simplify-1 [=>]0.1

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

    rational.json-simplify-51 [=>]0.1

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

    rational.json-simplify-41 [<=]0.1

    \[ x \cdot \left(x + \color{blue}{\left(y + \left(y + x\right)\right)}\right) \]
  4. Taylor expanded in y around 0 0.1

    \[\leadsto x \cdot \left(x + \color{blue}{\left(2 \cdot y + x\right)}\right) \]
  5. Final simplification0.1

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

Alternatives

Alternative 1
Error9.0
Cost848
\[\begin{array}{l} t_0 := y \cdot \left(x + x\right)\\ t_1 := x \cdot \left(x + x\right)\\ \mathbf{if}\;y \leq -7.2 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.85 \cdot 10^{-90}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost448
\[\left(x + y\right) \cdot \left(x \cdot 2\right) \]
Alternative 3
Error32.7
Cost320
\[x \cdot \left(x + x\right) \]

Error

Reproduce?

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

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

  (* 2.0 (+ (* x x) (* x y))))