Average Error: 0.0 → 0.0
Time: 7.9s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(2, y, x\right) \cdot x\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(y, y, \mathsf{fma}\left(2, y, x\right) \cdot x\right)
double f(double x, double y) {
        double r557236 = x;
        double r557237 = r557236 * r557236;
        double r557238 = 2.0;
        double r557239 = r557236 * r557238;
        double r557240 = y;
        double r557241 = r557239 * r557240;
        double r557242 = r557237 + r557241;
        double r557243 = r557240 * r557240;
        double r557244 = r557242 + r557243;
        return r557244;
}

double f(double x, double y) {
        double r557245 = y;
        double r557246 = 2.0;
        double r557247 = x;
        double r557248 = fma(r557246, r557245, r557247);
        double r557249 = r557248 * r557247;
        double r557250 = fma(r557245, r557245, r557249);
        return r557250;
}

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. Taylor expanded around 0 0.0

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

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

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

Reproduce

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