Average Error: 0.0 → 0.0
Time: 1.4s
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 r523769 = 2.0;
        double r523770 = x;
        double r523771 = r523770 * r523770;
        double r523772 = y;
        double r523773 = r523770 * r523772;
        double r523774 = r523771 - r523773;
        double r523775 = r523769 * r523774;
        return r523775;
}

double f(double x, double y) {
        double r523776 = 2.0;
        double r523777 = x;
        double r523778 = y;
        double r523779 = r523777 * r523778;
        double r523780 = -r523779;
        double r523781 = fma(r523777, r523777, r523780);
        double r523782 = r523776 * r523781;
        return r523782;
}

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