Average Error: 0.0 → 0.0
Time: 12.9s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(2.0, x, y\right) \cdot y\right)\]
\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \mathsf{fma}\left(2.0, x, y\right) \cdot y\right)
double f(double x, double y) {
        double r32475906 = x;
        double r32475907 = r32475906 * r32475906;
        double r32475908 = 2.0;
        double r32475909 = r32475906 * r32475908;
        double r32475910 = y;
        double r32475911 = r32475909 * r32475910;
        double r32475912 = r32475907 + r32475911;
        double r32475913 = r32475910 * r32475910;
        double r32475914 = r32475912 + r32475913;
        return r32475914;
}

double f(double x, double y) {
        double r32475915 = x;
        double r32475916 = 2.0;
        double r32475917 = y;
        double r32475918 = fma(r32475916, r32475915, r32475917);
        double r32475919 = r32475918 * r32475917;
        double r32475920 = fma(r32475915, r32475915, r32475919);
        return r32475920;
}

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

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

    \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(2.0, x, y\right) + x \cdot x}\]
  5. Taylor expanded around 0 0.0

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

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

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

Reproduce

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