Average Error: 0.0 → 0.0
Time: 6.3s
Precision: 64
\[2 \cdot \left(x \cdot x + x \cdot y\right)\]
\[\mathsf{fma}\left(x, x, y \cdot x\right) \cdot 2\]
2 \cdot \left(x \cdot x + x \cdot y\right)
\mathsf{fma}\left(x, x, y \cdot x\right) \cdot 2
double f(double x, double y) {
        double r341173 = 2.0;
        double r341174 = x;
        double r341175 = r341174 * r341174;
        double r341176 = y;
        double r341177 = r341174 * r341176;
        double r341178 = r341175 + r341177;
        double r341179 = r341173 * r341178;
        return r341179;
}

double f(double x, double y) {
        double r341180 = x;
        double r341181 = y;
        double r341182 = r341181 * r341180;
        double r341183 = fma(r341180, r341180, r341182);
        double r341184 = 2.0;
        double r341185 = r341183 * r341184;
        return r341185;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

    \[2 \cdot \left(x \cdot x + x \cdot y\right)\]
  2. Using strategy rm
  3. Applied fma-def0.0

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

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

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y)
  :name "Linear.Matrix:fromQuaternion from linear-1.19.1.3, B"

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

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