Average Error: 0.0 → 0.0
Time: 2.5s
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 r427551 = x;
        double r427552 = 2.0;
        double r427553 = r427551 * r427552;
        double r427554 = r427551 * r427551;
        double r427555 = r427553 + r427554;
        double r427556 = y;
        double r427557 = r427556 * r427556;
        double r427558 = r427555 + r427557;
        return r427558;
}

double f(double x, double y) {
        double r427559 = x;
        double r427560 = 2.0;
        double r427561 = r427560 + r427559;
        double r427562 = y;
        double r427563 = r427562 * r427562;
        double r427564 = fma(r427559, r427561, r427563);
        return r427564;
}

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 2019326 +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)))