Average Error: 0.0 → 0.0
Time: 8.7s
Precision: 64
\[\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, x \cdot \left(2.0 + x\right)\right)\]
\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, x \cdot \left(2.0 + x\right)\right)
double f(double x, double y) {
        double r21507631 = x;
        double r21507632 = 2.0;
        double r21507633 = r21507631 * r21507632;
        double r21507634 = r21507631 * r21507631;
        double r21507635 = r21507633 + r21507634;
        double r21507636 = y;
        double r21507637 = r21507636 * r21507636;
        double r21507638 = r21507635 + r21507637;
        return r21507638;
}

double f(double x, double y) {
        double r21507639 = y;
        double r21507640 = x;
        double r21507641 = 2.0;
        double r21507642 = r21507641 + r21507640;
        double r21507643 = r21507640 * r21507642;
        double r21507644 = fma(r21507639, r21507639, r21507643);
        return r21507644;
}

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. Final simplification0.0

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

Reproduce

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