Average Error: 0.0 → 0.0
Time: 9.1s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(x, 2, y\right) \cdot y\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \mathsf{fma}\left(x, 2, y\right) \cdot y\right)
double f(double x, double y) {
        double r472557 = x;
        double r472558 = r472557 * r472557;
        double r472559 = 2.0;
        double r472560 = r472557 * r472559;
        double r472561 = y;
        double r472562 = r472560 * r472561;
        double r472563 = r472558 + r472562;
        double r472564 = r472561 * r472561;
        double r472565 = r472563 + r472564;
        return r472565;
}

double f(double x, double y) {
        double r472566 = x;
        double r472567 = 2.0;
        double r472568 = y;
        double r472569 = fma(r472566, r472567, r472568);
        double r472570 = r472569 * r472568;
        double r472571 = fma(r472566, r472566, r472570);
        return r472571;
}

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. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{x}^{2} + \left({y}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  3. Simplified0.0

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

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

Reproduce

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