Average Error: 0.0 → 0.0
Time: 1.0s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)
double f(double x, double y) {
        double r673983 = x;
        double r673984 = r673983 * r673983;
        double r673985 = 2.0;
        double r673986 = r673983 * r673985;
        double r673987 = y;
        double r673988 = r673986 * r673987;
        double r673989 = r673984 + r673988;
        double r673990 = r673987 * r673987;
        double r673991 = r673989 + r673990;
        return r673991;
}

double f(double x, double y) {
        double r673992 = y;
        double r673993 = 2.0;
        double r673994 = x;
        double r673995 = fma(r673993, r673994, r673992);
        double r673996 = 2.0;
        double r673997 = pow(r673994, r673996);
        double r673998 = fma(r673992, r673995, r673997);
        return r673998;
}

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}{{x}^{2} + \left({y}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  3. Simplified0.0

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

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

Reproduce

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