Average Error: 0.0 → 0.0
Time: 14.1s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, \left(2.0 \cdot x\right) \cdot y\right)\right)\]
\left(x \cdot x + \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, \left(2.0 \cdot x\right) \cdot y\right)\right)
double f(double x, double y) {
        double r34273676 = x;
        double r34273677 = r34273676 * r34273676;
        double r34273678 = 2.0;
        double r34273679 = r34273676 * r34273678;
        double r34273680 = y;
        double r34273681 = r34273679 * r34273680;
        double r34273682 = r34273677 + r34273681;
        double r34273683 = r34273680 * r34273680;
        double r34273684 = r34273682 + r34273683;
        return r34273684;
}

double f(double x, double y) {
        double r34273685 = y;
        double r34273686 = x;
        double r34273687 = 2.0;
        double r34273688 = r34273687 * r34273686;
        double r34273689 = r34273688 * r34273685;
        double r34273690 = fma(r34273686, r34273686, r34273689);
        double r34273691 = fma(r34273685, r34273685, r34273690);
        return r34273691;
}

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, \left(x \cdot 2.0\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.0\right) \cdot y\right) + y \cdot y} \cdot \sqrt{\mathsf{fma}\left(x, x, \left(x \cdot 2.0\right) \cdot y\right) + y \cdot y}}\]
  6. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{y}^{2} + \left({x}^{2} + 2.0 \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.0\right) \cdot y\right)\right)}\]
  8. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, \left(2.0 \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)))