Average Error: 0.0 → 0.0
Time: 1.1s
Precision: 64
\[2 \cdot \left(x \cdot x - x \cdot y\right)\]
\[2 \cdot \mathsf{fma}\left(x, x, -x \cdot y\right)\]
2 \cdot \left(x \cdot x - x \cdot y\right)
2 \cdot \mathsf{fma}\left(x, x, -x \cdot y\right)
double f(double x, double y) {
        double r574861 = 2.0;
        double r574862 = x;
        double r574863 = r574862 * r574862;
        double r574864 = y;
        double r574865 = r574862 * r574864;
        double r574866 = r574863 - r574865;
        double r574867 = r574861 * r574866;
        return r574867;
}

double f(double x, double y) {
        double r574868 = 2.0;
        double r574869 = x;
        double r574870 = y;
        double r574871 = r574869 * r574870;
        double r574872 = -r574871;
        double r574873 = fma(r574869, r574869, r574872);
        double r574874 = r574868 * r574873;
        return r574874;
}

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 2 \cdot \mathsf{fma}\left(x, x, -x \cdot y\right)\]

Reproduce

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