Average Error: 0.0 → 0.0
Time: 19.5s
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 r30757865 = x;
        double r30757866 = r30757865 * r30757865;
        double r30757867 = 2.0;
        double r30757868 = r30757865 * r30757867;
        double r30757869 = y;
        double r30757870 = r30757868 * r30757869;
        double r30757871 = r30757866 + r30757870;
        double r30757872 = r30757869 * r30757869;
        double r30757873 = r30757871 + r30757872;
        return r30757873;
}

double f(double x, double y) {
        double r30757874 = x;
        double r30757875 = 2.0;
        double r30757876 = r30757874 * r30757875;
        double r30757877 = y;
        double r30757878 = r30757876 * r30757877;
        double r30757879 = fma(r30757874, r30757874, r30757878);
        double r30757880 = r30757877 * r30757877;
        double r30757881 = r30757879 + r30757880;
        return r30757881;
}

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}{\left({x}^{2} + 2 \cdot \left(x \cdot y\right)\right)} + y \cdot y\]
  3. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot \left(x \cdot 2\right)\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 2019200 +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)))