Average Error: 0.0 → 0.0
Time: 12.0s
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 r344019 = 2.0;
        double r344020 = x;
        double r344021 = r344020 * r344020;
        double r344022 = y;
        double r344023 = r344020 * r344022;
        double r344024 = r344021 - r344023;
        double r344025 = r344019 * r344024;
        return r344025;
}

double f(double x, double y) {
        double r344026 = 2.0;
        double r344027 = x;
        double r344028 = y;
        double r344029 = r344028 * r344027;
        double r344030 = -r344029;
        double r344031 = fma(r344027, r344027, r344030);
        double r344032 = r344026 * r344031;
        return r344032;
}

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