Average Error: 0.0 → 0.0
Time: 9.5s
Precision: 64
\[2.0 \cdot \left(x \cdot x + x \cdot y\right)\]
\[\mathsf{fma}\left(x, x, y \cdot x\right) \cdot 2.0\]
2.0 \cdot \left(x \cdot x + x \cdot y\right)
\mathsf{fma}\left(x, x, y \cdot x\right) \cdot 2.0
double f(double x, double y) {
        double r25005797 = 2.0;
        double r25005798 = x;
        double r25005799 = r25005798 * r25005798;
        double r25005800 = y;
        double r25005801 = r25005798 * r25005800;
        double r25005802 = r25005799 + r25005801;
        double r25005803 = r25005797 * r25005802;
        return r25005803;
}

double f(double x, double y) {
        double r25005804 = x;
        double r25005805 = y;
        double r25005806 = r25005805 * r25005804;
        double r25005807 = fma(r25005804, r25005804, r25005806);
        double r25005808 = 2.0;
        double r25005809 = r25005807 * r25005808;
        return r25005809;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

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

    \[\leadsto 2.0 \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.0\]

Reproduce

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