Average Error: 0.0 → 0.0
Time: 9.8s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
double f(double x, double y) {
        double r21609825 = x;
        double r21609826 = r21609825 * r21609825;
        double r21609827 = 2.0;
        double r21609828 = r21609825 * r21609827;
        double r21609829 = y;
        double r21609830 = r21609828 * r21609829;
        double r21609831 = r21609826 + r21609830;
        double r21609832 = r21609829 * r21609829;
        double r21609833 = r21609831 + r21609832;
        return r21609833;
}

double f(double x, double y) {
        double r21609834 = x;
        double r21609835 = 2.0;
        double r21609836 = r21609834 * r21609835;
        double r21609837 = y;
        double r21609838 = r21609836 * r21609837;
        double r21609839 = fma(r21609834, r21609834, r21609838);
        double r21609840 = r21609837 * r21609837;
        double r21609841 = r21609839 + r21609840;
        return r21609841;
}

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. Using strategy rm
  3. Applied fma-def0.0

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

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

Reproduce

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