Average Error: 0.0 → 0.0
Time: 1.5s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[x \cdot x + \mathsf{fma}\left(x, 2, y\right) \cdot y\]
\left(x + y\right) \cdot \left(x + y\right)
x \cdot x + \mathsf{fma}\left(x, 2, y\right) \cdot y
double f(double x, double y) {
        double r629050 = x;
        double r629051 = y;
        double r629052 = r629050 + r629051;
        double r629053 = r629052 * r629052;
        return r629053;
}

double f(double x, double y) {
        double r629054 = x;
        double r629055 = r629054 * r629054;
        double r629056 = 2.0;
        double r629057 = y;
        double r629058 = fma(r629054, r629056, r629057);
        double r629059 = r629058 * r629057;
        double r629060 = r629055 + r629059;
        return r629060;
}

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. Using strategy rm
  3. Applied distribute-lft-in0.0

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

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

    \[\leadsto x \cdot \left(x + y\right) + \color{blue}{y \cdot \left(x + y\right)}\]
  6. Using strategy rm
  7. Applied distribute-lft-in0.0

    \[\leadsto \color{blue}{\left(x \cdot x + x \cdot y\right)} + y \cdot \left(x + y\right)\]
  8. Applied associate-+l+0.0

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

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

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

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

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

Reproduce

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