Average Error: 0.0 → 0.0
Time: 5.5s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y, 2, x\right) \cdot x + y \cdot y\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(y, 2, x\right) \cdot x + y \cdot y
double f(double x, double y) {
        double r431496 = x;
        double r431497 = r431496 * r431496;
        double r431498 = 2.0;
        double r431499 = r431496 * r431498;
        double r431500 = y;
        double r431501 = r431499 * r431500;
        double r431502 = r431497 + r431501;
        double r431503 = r431500 * r431500;
        double r431504 = r431502 + r431503;
        return r431504;
}

double f(double x, double y) {
        double r431505 = y;
        double r431506 = 2.0;
        double r431507 = x;
        double r431508 = fma(r431505, r431506, r431507);
        double r431509 = r431508 * r431507;
        double r431510 = r431505 * r431505;
        double r431511 = r431509 + r431510;
        return r431511;
}

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. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, x\right), y \cdot y\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.0

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

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

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

Reproduce

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