Average Error: 0.0 → 0.0
Time: 3.8s
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 r448926 = 2.0;
        double r448927 = x;
        double r448928 = r448927 * r448927;
        double r448929 = y;
        double r448930 = r448927 * r448929;
        double r448931 = r448928 - r448930;
        double r448932 = r448926 * r448931;
        return r448932;
}

double f(double x, double y) {
        double r448933 = x;
        double r448934 = y;
        double r448935 = r448934 * r448933;
        double r448936 = -r448935;
        double r448937 = fma(r448933, r448933, r448936);
        double r448938 = 2.0;
        double r448939 = r448937 * r448938;
        return r448939;
}

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-neg0.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 2019194 +o rules:numerics
(FPCore (x y)
  :name "Linear.Matrix:fromQuaternion from linear-1.19.1.3, A"

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

  (* 2.0 (- (* x x) (* x y))))