Average Error: 0.0 → 0.0
Time: 2.8s
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 r476820 = x;
        double r476821 = r476820 * r476820;
        double r476822 = 2.0;
        double r476823 = r476820 * r476822;
        double r476824 = y;
        double r476825 = r476823 * r476824;
        double r476826 = r476821 + r476825;
        double r476827 = r476824 * r476824;
        double r476828 = r476826 + r476827;
        return r476828;
}

double f(double x, double y) {
        double r476829 = x;
        double r476830 = 2.0;
        double r476831 = r476829 * r476830;
        double r476832 = y;
        double r476833 = r476831 * r476832;
        double r476834 = fma(r476829, r476829, r476833);
        double r476835 = r476832 * r476832;
        double r476836 = r476834 + r476835;
        return r476836;
}

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

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