Average Error: 0.0 → 0.0
Time: 5.6s
Precision: 64
\[2 \cdot \left(x \cdot x - x \cdot y\right)\]
\[2 \cdot \mathsf{fma}\left(x, x, -y \cdot x\right)\]
2 \cdot \left(x \cdot x - x \cdot y\right)
2 \cdot \mathsf{fma}\left(x, x, -y \cdot x\right)
double f(double x, double y) {
        double r322877 = 2.0;
        double r322878 = x;
        double r322879 = r322878 * r322878;
        double r322880 = y;
        double r322881 = r322878 * r322880;
        double r322882 = r322879 - r322881;
        double r322883 = r322877 * r322882;
        return r322883;
}

double f(double x, double y) {
        double r322884 = 2.0;
        double r322885 = x;
        double r322886 = y;
        double r322887 = r322886 * r322885;
        double r322888 = -r322887;
        double r322889 = fma(r322885, r322885, r322888);
        double r322890 = r322884 * r322889;
        return r322890;
}

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. Simplified0.0

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

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

Reproduce

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

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

  (* 2 (- (* x x) (* x y))))