Average Error: 0.0 → 0.0
Time: 2.0s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[x \cdot x + \mathsf{fma}\left(2, x, y\right) \cdot y\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
x \cdot x + \mathsf{fma}\left(2, x, y\right) \cdot y
double f(double x, double y) {
        double r575273 = x;
        double r575274 = r575273 * r575273;
        double r575275 = 2.0;
        double r575276 = r575273 * r575275;
        double r575277 = y;
        double r575278 = r575276 * r575277;
        double r575279 = r575274 + r575278;
        double r575280 = r575277 * r575277;
        double r575281 = r575279 + r575280;
        return r575281;
}

double f(double x, double y) {
        double r575282 = x;
        double r575283 = r575282 * r575282;
        double r575284 = 2.0;
        double r575285 = y;
        double r575286 = fma(r575284, r575282, r575285);
        double r575287 = r575286 * r575285;
        double r575288 = r575283 + r575287;
        return r575288;
}

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 associate-+l+0.0

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

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

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

Reproduce

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