Average Error: 0.0 → 0.0
Time: 2.2s
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 r649693 = x;
        double r649694 = r649693 * r649693;
        double r649695 = 2.0;
        double r649696 = r649693 * r649695;
        double r649697 = y;
        double r649698 = r649696 * r649697;
        double r649699 = r649694 + r649698;
        double r649700 = r649697 * r649697;
        double r649701 = r649699 + r649700;
        return r649701;
}

double f(double x, double y) {
        double r649702 = y;
        double r649703 = 2.0;
        double r649704 = x;
        double r649705 = fma(r649703, r649704, r649702);
        double r649706 = 2.0;
        double r649707 = pow(r649704, r649706);
        double r649708 = fma(r649702, r649705, r649707);
        return r649708;
}

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 2020083 +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)))