Average Error: 0.0 → 0.0
Time: 21.2s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[x \cdot \left(y + x\right) + \mathsf{fma}\left(y, y, x \cdot y\right)\]
\left(x + y\right) \cdot \left(x + y\right)
x \cdot \left(y + x\right) + \mathsf{fma}\left(y, y, x \cdot y\right)
double f(double x, double y) {
        double r26913629 = x;
        double r26913630 = y;
        double r26913631 = r26913629 + r26913630;
        double r26913632 = r26913631 * r26913631;
        return r26913632;
}

double f(double x, double y) {
        double r26913633 = x;
        double r26913634 = y;
        double r26913635 = r26913634 + r26913633;
        double r26913636 = r26913633 * r26913635;
        double r26913637 = r26913633 * r26913634;
        double r26913638 = fma(r26913634, r26913634, r26913637);
        double r26913639 = r26913636 + r26913638;
        return r26913639;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[x \cdot x + \left(y \cdot y + 2.0 \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-rgt-in0.0

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

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

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

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

Reproduce

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