Average Error: 0.0 → 0.0
Time: 11.0s
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 r382926 = x;
        double r382927 = r382926 * r382926;
        double r382928 = 2.0;
        double r382929 = r382926 * r382928;
        double r382930 = y;
        double r382931 = r382929 * r382930;
        double r382932 = r382927 + r382931;
        double r382933 = r382930 * r382930;
        double r382934 = r382932 + r382933;
        return r382934;
}

double f(double x, double y) {
        double r382935 = x;
        double r382936 = 2.0;
        double r382937 = y;
        double r382938 = fma(r382935, r382936, r382937);
        double r382939 = r382938 * r382937;
        double r382940 = fma(r382935, r382935, r382939);
        return r382940;
}

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)))