Average Error: 0.0 → 0.0
Time: 825.0ms
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(x, 2 + x, y \cdot y\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(x, 2 + x, y \cdot y\right)
double f(double x, double y) {
        double r459617 = x;
        double r459618 = 2.0;
        double r459619 = r459617 * r459618;
        double r459620 = r459617 * r459617;
        double r459621 = r459619 + r459620;
        double r459622 = y;
        double r459623 = r459622 * r459622;
        double r459624 = r459621 + r459623;
        return r459624;
}

double f(double x, double y) {
        double r459625 = x;
        double r459626 = 2.0;
        double r459627 = r459626 + r459625;
        double r459628 = y;
        double r459629 = r459628 * r459628;
        double r459630 = fma(r459625, r459627, r459629);
        return r459630;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

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

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

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

Reproduce

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

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

  (+ (+ (* x 2) (* x x)) (* y y)))