Average Error: 0.0 → 0.0
Time: 1.3s
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 r540740 = 2.0;
        double r540741 = x;
        double r540742 = r540741 * r540741;
        double r540743 = y;
        double r540744 = r540741 * r540743;
        double r540745 = r540742 - r540744;
        double r540746 = r540740 * r540745;
        return r540746;
}

double f(double x, double y) {
        double r540747 = 2.0;
        double r540748 = x;
        double r540749 = y;
        double r540750 = r540748 * r540749;
        double r540751 = -r540750;
        double r540752 = fma(r540748, r540748, r540751);
        double r540753 = r540747 * r540752;
        return r540753;
}

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