Average Error: 0.0 → 0.0
Time: 8.4s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \left(x \cdot 2\right) \cdot y\right) + y \cdot y
double f(double x, double y) {
        double r512366 = x;
        double r512367 = r512366 * r512366;
        double r512368 = 2.0;
        double r512369 = r512366 * r512368;
        double r512370 = y;
        double r512371 = r512369 * r512370;
        double r512372 = r512367 + r512371;
        double r512373 = r512370 * r512370;
        double r512374 = r512372 + r512373;
        return r512374;
}

double f(double x, double y) {
        double r512375 = x;
        double r512376 = 2.0;
        double r512377 = r512375 * r512376;
        double r512378 = y;
        double r512379 = r512377 * r512378;
        double r512380 = fma(r512375, r512375, r512379);
        double r512381 = r512378 * r512378;
        double r512382 = r512380 + r512381;
        return r512382;
}

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\right)\]

Derivation

  1. Initial program 0.0

    \[\left(x \cdot x + \left(x \cdot 2\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\right) \cdot y\right)} + y \cdot y\]
  4. Final simplification0.0

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

Reproduce

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

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

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