Average Error: 0.0 → 0.0
Time: 11.0s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(2, x \cdot y, y \cdot y\right)\right)\]
\left(x + y\right) \cdot \left(x + y\right)
\mathsf{fma}\left(x, x, \mathsf{fma}\left(2, x \cdot y, y \cdot y\right)\right)
double f(double x, double y) {
        double r392597 = x;
        double r392598 = y;
        double r392599 = r392597 + r392598;
        double r392600 = r392599 * r392599;
        return r392600;
}

double f(double x, double y) {
        double r392601 = x;
        double r392602 = 2.0;
        double r392603 = y;
        double r392604 = r392601 * r392603;
        double r392605 = r392603 * r392603;
        double r392606 = fma(r392602, r392604, r392605);
        double r392607 = fma(r392601, r392601, r392606);
        return r392607;
}

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 fma-def0.0

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

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

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

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

Reproduce

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

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

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