Average Error: 39.1 → 0.0
Time: 12.0s
Precision: 64
\[\left(x + 1\right) \cdot \left(x + 1\right) - 1\]
\[2 \cdot x + x \cdot x\]
\left(x + 1\right) \cdot \left(x + 1\right) - 1
2 \cdot x + x \cdot x
double f(double x) {
        double r3328 = x;
        double r3329 = 1.0;
        double r3330 = r3328 + r3329;
        double r3331 = r3330 * r3330;
        double r3332 = r3331 - r3329;
        return r3332;
}

double f(double x) {
        double r3333 = 2.0;
        double r3334 = x;
        double r3335 = r3333 * r3334;
        double r3336 = r3334 * r3334;
        double r3337 = r3335 + r3336;
        return r3337;
}

Error

Bits error versus x

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. Taylor expanded around 0 0.0

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

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

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

    \[\leadsto \color{blue}{2 \cdot x} + x \cdot x\]
  7. Final simplification0.0

    \[\leadsto 2 \cdot x + x \cdot x\]

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x)
  :name "Expanding a square"
  :precision binary64
  (- (* (+ x 1) (+ x 1)) 1))