Average Error: 0.0 → 0.0
Time: 6.1s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\[x \cdot x + \mathsf{fma}\left(2.0, x, y\right) \cdot y\]
\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
x \cdot x + \mathsf{fma}\left(2.0, x, y\right) \cdot y
double f(double x, double y) {
        double r10947222 = x;
        double r10947223 = r10947222 * r10947222;
        double r10947224 = 2.0;
        double r10947225 = r10947222 * r10947224;
        double r10947226 = y;
        double r10947227 = r10947225 * r10947226;
        double r10947228 = r10947223 + r10947227;
        double r10947229 = r10947226 * r10947226;
        double r10947230 = r10947228 + r10947229;
        return r10947230;
}

double f(double x, double y) {
        double r10947231 = x;
        double r10947232 = r10947231 * r10947231;
        double r10947233 = 2.0;
        double r10947234 = y;
        double r10947235 = fma(r10947233, r10947231, r10947234);
        double r10947236 = r10947235 * r10947234;
        double r10947237 = r10947232 + r10947236;
        return r10947237;
}

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \mathsf{fma}\left(2.0, x, y\right), x \cdot x\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.0

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

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

Reproduce

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