Average Error: 0.0 → 0.0
Time: 11.8s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(2.0, x, y\right) \cdot y\right)\]
\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \mathsf{fma}\left(2.0, x, y\right) \cdot y\right)
double f(double x, double y) {
        double r30717974 = x;
        double r30717975 = r30717974 * r30717974;
        double r30717976 = 2.0;
        double r30717977 = r30717974 * r30717976;
        double r30717978 = y;
        double r30717979 = r30717977 * r30717978;
        double r30717980 = r30717975 + r30717979;
        double r30717981 = r30717978 * r30717978;
        double r30717982 = r30717980 + r30717981;
        return r30717982;
}

double f(double x, double y) {
        double r30717983 = x;
        double r30717984 = 2.0;
        double r30717985 = y;
        double r30717986 = fma(r30717984, r30717983, r30717985);
        double r30717987 = r30717986 * r30717985;
        double r30717988 = fma(r30717983, r30717983, r30717987);
        return r30717988;
}

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

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

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

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

Reproduce

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