Average Error: 0.0 → 0.0
Time: 7.5s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), x \cdot x\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), x \cdot x\right)
double f(double x, double y) {
        double r26455338 = x;
        double r26455339 = r26455338 * r26455338;
        double r26455340 = 2.0;
        double r26455341 = r26455338 * r26455340;
        double r26455342 = y;
        double r26455343 = r26455341 * r26455342;
        double r26455344 = r26455339 + r26455343;
        double r26455345 = r26455342 * r26455342;
        double r26455346 = r26455344 + r26455345;
        return r26455346;
}

double f(double x, double y) {
        double r26455347 = y;
        double r26455348 = 2.0;
        double r26455349 = x;
        double r26455350 = fma(r26455348, r26455349, r26455347);
        double r26455351 = r26455349 * r26455349;
        double r26455352 = fma(r26455347, r26455350, r26455351);
        return r26455352;
}

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

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

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

Reproduce

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