Average Error: 0.0 → 0.0
Time: 6.6s
Precision: 64
\[2 \cdot \left(x \cdot x - x \cdot y\right)\]
\[2 \cdot \mathsf{fma}\left(x, x, -y \cdot x\right)\]
2 \cdot \left(x \cdot x - x \cdot y\right)
2 \cdot \mathsf{fma}\left(x, x, -y \cdot x\right)
double f(double x, double y) {
        double r725236 = 2.0;
        double r725237 = x;
        double r725238 = r725237 * r725237;
        double r725239 = y;
        double r725240 = r725237 * r725239;
        double r725241 = r725238 - r725240;
        double r725242 = r725236 * r725241;
        return r725242;
}

double f(double x, double y) {
        double r725243 = 2.0;
        double r725244 = x;
        double r725245 = y;
        double r725246 = r725245 * r725244;
        double r725247 = -r725246;
        double r725248 = fma(r725244, r725244, r725247);
        double r725249 = r725243 * r725248;
        return r725249;
}

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. Simplified0.0

    \[\leadsto 2 \cdot \mathsf{fma}\left(x, x, \color{blue}{-y \cdot x}\right)\]
  5. Final simplification0.0

    \[\leadsto 2 \cdot \mathsf{fma}\left(x, x, -y \cdot x\right)\]

Reproduce

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