Average Error: 0.0 → 0.0
Time: 27.7s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, \left(2 \cdot x\right) \cdot y\right)\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, \left(2 \cdot x\right) \cdot y\right)\right)
double f(double x, double y) {
        double r25312642 = x;
        double r25312643 = r25312642 * r25312642;
        double r25312644 = 2.0;
        double r25312645 = r25312642 * r25312644;
        double r25312646 = y;
        double r25312647 = r25312645 * r25312646;
        double r25312648 = r25312643 + r25312647;
        double r25312649 = r25312646 * r25312646;
        double r25312650 = r25312648 + r25312649;
        return r25312650;
}

double f(double x, double y) {
        double r25312651 = y;
        double r25312652 = x;
        double r25312653 = 2.0;
        double r25312654 = r25312653 * r25312652;
        double r25312655 = r25312654 * r25312651;
        double r25312656 = fma(r25312652, r25312652, r25312655);
        double r25312657 = fma(r25312651, r25312651, r25312656);
        return r25312657;
}

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. Using strategy rm
  3. Applied fma-def0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, \left(x \cdot 2\right) \cdot y\right)} + y \cdot y\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt0.0

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, x, \left(x \cdot 2\right) \cdot y\right) + y \cdot y} \cdot \sqrt{\mathsf{fma}\left(x, x, \left(x \cdot 2\right) \cdot y\right) + y \cdot y}}\]
  6. Taylor expanded around 0 0.0

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

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

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

Reproduce

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