Average Error: 38.6 → 0.0
Time: 1.3s
Precision: binary64
Cost: 448
\[\left(x + 1\right) \cdot \left(x + 1\right) - 1\]
\[\left(x + x\right) + x \cdot x\]
\left(x + 1\right) \cdot \left(x + 1\right) - 1
\left(x + x\right) + x \cdot x
(FPCore (x) :precision binary64 (- (* (+ x 1.0) (+ x 1.0)) 1.0))
(FPCore (x) :precision binary64 (+ (+ x x) (* x x)))
double code(double x) {
	return ((x + 1.0) * (x + 1.0)) - 1.0;
}
double code(double x) {
	return (x + x) + (x * x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error0.0
Cost320
\[x \cdot \left(x + 2\right)\]
Alternative 2
Error1.8
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -1.999608141342932 \lor \neg \left(x \leq 2.040429526562208\right):\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + x\\ \end{array}\]
Alternative 3
Error21.9
Cost192
\[x + x\]
Alternative 4
Error61.2
Cost64
\[1\]

Error

Derivation

  1. Initial program 38.6

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

    \[\leadsto \color{blue}{x \cdot \left(x + 2\right)}\]
  3. Using strategy rm
  4. Applied distribute-rgt-in_binary640.0

    \[\leadsto \color{blue}{x \cdot x + 2 \cdot x}\]
  5. Simplified0.0

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

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

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

Reproduce

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