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 r616350 = 2.0;
        double r616351 = x;
        double r616352 = r616351 * r616351;
        double r616353 = y;
        double r616354 = r616351 * r616353;
        double r616355 = r616352 - r616354;
        double r616356 = r616350 * r616355;
        return r616356;
}

double f(double x, double y) {
        double r616357 = 2.0;
        double r616358 = x;
        double r616359 = y;
        double r616360 = r616358 * r616359;
        double r616361 = -r616360;
        double r616362 = fma(r616358, r616358, r616361);
        double r616363 = r616357 * r616362;
        return r616363;
}

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