?

Average Error: 39.1 → 0.0
Time: 1.8s
Precision: binary64
Cost: 448

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 39.1

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

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

    [Start]39.1

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

    rational_best_oopsla_all_46_json_45_simplify-45 [=>]39.1

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

    rational_best_oopsla_all_46_json_45_simplify-35 [=>]39.1

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

    rational_best_oopsla_all_46_json_45_simplify-37 [=>]39.1

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

    rational_best_oopsla_all_46_json_45_simplify-52 [=>]39.1

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

    rational_best_oopsla_all_46_json_45_simplify-82 [=>]33.7

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

    rational_best_oopsla_all_46_json_45_simplify-74 [=>]33.7

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

    rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.0

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

    metadata-eval [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-85 [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-52 [<=]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-23 [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.0

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

    rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.0

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

    metadata-eval [=>]0.0

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

    \[\leadsto \color{blue}{x \cdot x - -2 \cdot x} \]
  4. Final simplification0.0

    \[\leadsto x \cdot x - -2 \cdot x \]

Alternatives

Alternative 1
Error0.0
Cost320
\[x \cdot \left(x + 2\right) \]
Alternative 2
Error21.4
Cost192
\[x + x \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x)
  :name "Expanding a square"
  :precision binary64
  (- (* (+ x 1.0) (+ x 1.0)) 1.0))