Average Error: 0.0 → 0.0
Time: 31.7s
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 r21791318 = 2.0;
        double r21791319 = x;
        double r21791320 = r21791319 * r21791319;
        double r21791321 = y;
        double r21791322 = r21791319 * r21791321;
        double r21791323 = r21791320 + r21791322;
        double r21791324 = r21791318 * r21791323;
        return r21791324;
}

double f(double x, double y) {
        double r21791325 = x;
        double r21791326 = y;
        double r21791327 = r21791326 * r21791325;
        double r21791328 = fma(r21791325, r21791325, r21791327);
        double r21791329 = 2.0;
        double r21791330 = r21791328 * r21791329;
        return r21791330;
}

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 2019200 +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))))