Average Error: 0.0 → 0.0
Time: 1.2s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(\mathsf{fma}\left(y, 2, x\right), x, y \cdot y\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(\mathsf{fma}\left(y, 2, x\right), x, y \cdot y\right)
double f(double x, double y) {
        double r589297 = x;
        double r589298 = r589297 * r589297;
        double r589299 = 2.0;
        double r589300 = r589297 * r589299;
        double r589301 = y;
        double r589302 = r589300 * r589301;
        double r589303 = r589298 + r589302;
        double r589304 = r589301 * r589301;
        double r589305 = r589303 + r589304;
        return r589305;
}

double f(double x, double y) {
        double r589306 = y;
        double r589307 = 2.0;
        double r589308 = x;
        double r589309 = fma(r589306, r589307, r589308);
        double r589310 = r589306 * r589306;
        double r589311 = fma(r589309, r589308, r589310);
        return r589311;
}

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(\mathsf{fma}\left(y, 2, x\right), x, y \cdot y\right)}\]
  3. Final simplification0.0

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

Reproduce

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