Average Error: 0.0 → 0.0
Time: 6.4s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot \mathsf{fma}\left(x, 2, y\right)\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, y \cdot \mathsf{fma}\left(x, 2, y\right)\right)
double f(double x, double y) {
        double r377222 = x;
        double r377223 = r377222 * r377222;
        double r377224 = 2.0;
        double r377225 = r377222 * r377224;
        double r377226 = y;
        double r377227 = r377225 * r377226;
        double r377228 = r377223 + r377227;
        double r377229 = r377226 * r377226;
        double r377230 = r377228 + r377229;
        return r377230;
}

double f(double x, double y) {
        double r377231 = x;
        double r377232 = y;
        double r377233 = 2.0;
        double r377234 = fma(r377231, r377233, r377232);
        double r377235 = r377232 * r377234;
        double r377236 = fma(r377231, r377231, r377235);
        return r377236;
}

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. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, x\right), y \cdot y\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.0

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

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

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

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

Reproduce

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