Average Error: 0.0 → 0.0
Time: 6.6s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[\mathsf{fma}\left(x, x, 2 \cdot \left(x \cdot y\right) + y \cdot y\right)\]
\left(x + y\right) \cdot \left(x + y\right)
\mathsf{fma}\left(x, x, 2 \cdot \left(x \cdot y\right) + y \cdot y\right)
double f(double x, double y) {
        double r508288 = x;
        double r508289 = y;
        double r508290 = r508288 + r508289;
        double r508291 = r508290 * r508290;
        return r508291;
}

double f(double x, double y) {
        double r508292 = x;
        double r508293 = 2.0;
        double r508294 = y;
        double r508295 = r508292 * r508294;
        double r508296 = r508293 * r508295;
        double r508297 = r508294 * r508294;
        double r508298 = r508296 + r508297;
        double r508299 = fma(r508292, r508292, r508298);
        return r508299;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[x \cdot x + \left(y \cdot y + 2 \cdot \left(y \cdot x\right)\right)\]

Derivation

  1. Initial program 0.0

    \[\left(x + y\right) \cdot \left(x + y\right)\]
  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(x, x, y \cdot \mathsf{fma}\left(x, 2, y\right)\right)}\]
  4. Using strategy rm
  5. Applied fma-udef0.0

    \[\leadsto \mathsf{fma}\left(x, x, y \cdot \color{blue}{\left(x \cdot 2 + y\right)}\right)\]
  6. Applied distribute-lft-in0.0

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

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

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

Reproduce

herbie shell --seed 2019209 +o rules:numerics
(FPCore (x y)
  :name "Examples.Basics.BasicTests:f3 from sbv-4.4"
  :precision binary64

  :herbie-target
  (+ (* x x) (+ (* y y) (* 2 (* y x))))

  (* (+ x y) (+ x y)))