Average Error: 0.0 → 0.0
Time: 13.8s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, x\right), y \cdot y\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, x\right), y \cdot y\right)
double f(double x, double y) {
        double r39754045 = x;
        double r39754046 = r39754045 * r39754045;
        double r39754047 = 2.0;
        double r39754048 = r39754045 * r39754047;
        double r39754049 = y;
        double r39754050 = r39754048 * r39754049;
        double r39754051 = r39754046 + r39754050;
        double r39754052 = r39754049 * r39754049;
        double r39754053 = r39754051 + r39754052;
        return r39754053;
}

double f(double x, double y) {
        double r39754054 = x;
        double r39754055 = y;
        double r39754056 = 2.0;
        double r39754057 = fma(r39754055, r39754056, r39754054);
        double r39754058 = r39754055 * r39754055;
        double r39754059 = fma(r39754054, r39754057, r39754058);
        return r39754059;
}

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

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

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

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

Reproduce

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