Average Error: 0.0 → 0.0
Time: 4.1s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
double f(double x, double y) {
        double r25458350 = x;
        double r25458351 = r25458350 * r25458350;
        double r25458352 = 2.0;
        double r25458353 = r25458350 * r25458352;
        double r25458354 = y;
        double r25458355 = r25458353 * r25458354;
        double r25458356 = r25458351 + r25458355;
        double r25458357 = r25458354 * r25458354;
        double r25458358 = r25458356 + r25458357;
        return r25458358;
}

double f(double x, double y) {
        double r25458359 = x;
        double r25458360 = 2.0;
        double r25458361 = r25458359 * r25458360;
        double r25458362 = y;
        double r25458363 = r25458361 * r25458362;
        double r25458364 = fma(r25458359, r25458359, r25458363);
        double r25458365 = r25458362 * r25458362;
        double r25458366 = r25458364 + r25458365;
        return r25458366;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

    \[\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
  2. Using strategy rm
  3. Applied fma-def0.0

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

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

Reproduce

herbie shell --seed 2019164 +o rules:numerics
(FPCore (x y)
  :name "Examples.Basics.ProofTests:f4 from sbv-4.4"

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

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