Average Error: 0.0 → 0.0
Time: 2.9s
Precision: 64
\[\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2.0, x \cdot x\right)\right)\]
\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2.0, x \cdot x\right)\right)
double f(double x, double y) {
        double r20683395 = x;
        double r20683396 = 2.0;
        double r20683397 = r20683395 * r20683396;
        double r20683398 = r20683395 * r20683395;
        double r20683399 = r20683397 + r20683398;
        double r20683400 = y;
        double r20683401 = r20683400 * r20683400;
        double r20683402 = r20683399 + r20683401;
        return r20683402;
}

double f(double x, double y) {
        double r20683403 = y;
        double r20683404 = x;
        double r20683405 = 2.0;
        double r20683406 = r20683404 * r20683404;
        double r20683407 = fma(r20683404, r20683405, r20683406);
        double r20683408 = fma(r20683403, r20683403, r20683407);
        return r20683408;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, \left(2.0 + x\right) \cdot x\right)}\]
  3. Taylor expanded around 0 0.0

    \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{2.0 \cdot x + {x}^{2}}\right)\]
  4. Simplified0.0

    \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{\mathsf{fma}\left(x, 2.0, x \cdot x\right)}\right)\]
  5. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2.0, x \cdot x\right)\right)\]

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"

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

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