Average Error: 0.0 → 0.0
Time: 2.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 r495952 = 2.0;
        double r495953 = x;
        double r495954 = r495953 * r495953;
        double r495955 = y;
        double r495956 = r495953 * r495955;
        double r495957 = r495954 - r495956;
        double r495958 = r495952 * r495957;
        return r495958;
}

double f(double x, double y) {
        double r495959 = 2.0;
        double r495960 = x;
        double r495961 = y;
        double r495962 = r495960 * r495961;
        double r495963 = -r495962;
        double r495964 = fma(r495960, r495960, r495963);
        double r495965 = r495959 * r495964;
        return r495965;
}

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