Average Error: 0.0 → 0.0
Time: 3.8s
Precision: binary64
Cost: 576
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y \]
\[y \cdot y + x \cdot \left(x + 2\right) \]
(FPCore (x y) :precision binary64 (+ (+ (* x 2.0) (* x x)) (* y y)))
(FPCore (x y) :precision binary64 (+ (* y y) (* x (+ x 2.0))))
double code(double x, double y) {
	return ((x * 2.0) + (x * x)) + (y * y);
}
double code(double x, double y) {
	return (y * y) + (x * (x + 2.0));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * 2.0d0) + (x * x)) + (y * y)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (y * y) + (x * (x + 2.0d0))
end function
public static double code(double x, double y) {
	return ((x * 2.0) + (x * x)) + (y * y);
}
public static double code(double x, double y) {
	return (y * y) + (x * (x + 2.0));
}
def code(x, y):
	return ((x * 2.0) + (x * x)) + (y * y)
def code(x, y):
	return (y * y) + (x * (x + 2.0))
function code(x, y)
	return Float64(Float64(Float64(x * 2.0) + Float64(x * x)) + Float64(y * y))
end
function code(x, y)
	return Float64(Float64(y * y) + Float64(x * Float64(x + 2.0)))
end
function tmp = code(x, y)
	tmp = ((x * 2.0) + (x * x)) + (y * y);
end
function tmp = code(x, y)
	tmp = (y * y) + (x * (x + 2.0));
end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(y * y), $MachinePrecision] + N[(x * N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
y \cdot y + x \cdot \left(x + 2\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x + 2, y \cdot y\right)} \]
  3. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error23.3
Cost1512
\[\begin{array}{l} \mathbf{if}\;y \leq -8.090415211560587 \cdot 10^{-60}:\\ \;\;\;\;y \cdot y\\ \mathbf{elif}\;y \leq -2.7418161779546055 \cdot 10^{-103}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;y \leq 6.020938185527993 \cdot 10^{-280}:\\ \;\;\;\;x \cdot 2\\ \mathbf{elif}\;y \leq 4.3215576700986393 \cdot 10^{-246}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;y \leq 2.8592466077075347 \cdot 10^{-101}:\\ \;\;\;\;x \cdot 2\\ \mathbf{elif}\;y \leq 3.0336423605415836 \cdot 10^{-82}:\\ \;\;\;\;y \cdot y\\ \mathbf{elif}\;y \leq 6.472843817006802 \cdot 10^{-71}:\\ \;\;\;\;x \cdot 2\\ \mathbf{elif}\;y \leq 1.3072718881620541 \cdot 10^{-45}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;y \leq 5.2579804179458313 \cdot 10^{-14}:\\ \;\;\;\;y \cdot y\\ \mathbf{elif}\;y \leq 3821255.528034045:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot y\\ \end{array} \]
Alternative 2
Error10.3
Cost1100
\[\begin{array}{l} t_0 := x \cdot \left(x + 2\right)\\ \mathbf{if}\;y \cdot y \leq 1.0230518381963677 \cdot 10^{-65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \cdot y \leq 2.764635807550182 \cdot 10^{-27}:\\ \;\;\;\;y \cdot y\\ \mathbf{elif}\;y \cdot y \leq 128881898965185.98:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot y\\ \end{array} \]
Alternative 3
Error4.3
Cost712
\[\begin{array}{l} t_0 := x \cdot \left(x + 2\right)\\ \mathbf{if}\;x \leq -2.0627567669706132 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.4678579052086466 \cdot 10^{-28}:\\ \;\;\;\;y \cdot y + x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.3
Cost712
\[\begin{array}{l} t_0 := y \cdot y + x \cdot x\\ \mathbf{if}\;x \leq -280338.6794393384:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.11673240549718435:\\ \;\;\;\;y \cdot y + x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error21.5
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7094079459717318 \cdot 10^{-74}:\\ \;\;\;\;y \cdot y\\ \mathbf{elif}\;y \leq 2.8592466077075347 \cdot 10^{-101}:\\ \;\;\;\;x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;y \cdot y\\ \end{array} \]
Alternative 6
Error42.4
Cost192
\[x \cdot 2 \]

Error

Reproduce

herbie shell --seed 2022228 
(FPCore (x y)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"
  :precision binary64

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

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