Average Error: 0.0 → 0.0
Time: 9.6s
Precision: 64
\[\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, 2.0 \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, x, 2.0 \cdot x\right)\right)
double f(double x, double y) {
        double r18878511 = x;
        double r18878512 = 2.0;
        double r18878513 = r18878511 * r18878512;
        double r18878514 = r18878511 * r18878511;
        double r18878515 = r18878513 + r18878514;
        double r18878516 = y;
        double r18878517 = r18878516 * r18878516;
        double r18878518 = r18878515 + r18878517;
        return r18878518;
}

double f(double x, double y) {
        double r18878519 = y;
        double r18878520 = x;
        double r18878521 = 2.0;
        double r18878522 = r18878521 * r18878520;
        double r18878523 = fma(r18878520, r18878520, r18878522);
        double r18878524 = fma(r18878519, r18878519, r18878523);
        return r18878524;
}

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, x, 2.0 \cdot x\right)}\right)\]
  5. Final simplification0.0

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

Reproduce

herbie shell --seed 2019162 +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)))