Average Error: 0.0 → 0.0
Time: 6.2s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(x \cdot 2, y, y \cdot y\right)\right)\]
\left(x + y\right) \cdot \left(x + y\right)
\mathsf{fma}\left(x, x, \mathsf{fma}\left(x \cdot 2, y, y \cdot y\right)\right)
double f(double x, double y) {
        double r26687464 = x;
        double r26687465 = y;
        double r26687466 = r26687464 + r26687465;
        double r26687467 = r26687466 * r26687466;
        return r26687467;
}

double f(double x, double y) {
        double r26687468 = x;
        double r26687469 = 2.0;
        double r26687470 = r26687468 * r26687469;
        double r26687471 = y;
        double r26687472 = r26687471 * r26687471;
        double r26687473 = fma(r26687470, r26687471, r26687472);
        double r26687474 = fma(r26687468, r26687468, r26687473);
        return r26687474;
}

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}{{y}^{2} + \left({x}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  3. Simplified0.0

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

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

Reproduce

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

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

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