Average Error: 0.0 → 0.0
Time: 1.6s
Precision: 64
\[0.5 \cdot \left(x \cdot x - y\right)\]
\[\mathsf{fma}\left(x, x, -y\right) \cdot 0.5\]
0.5 \cdot \left(x \cdot x - y\right)
\mathsf{fma}\left(x, x, -y\right) \cdot 0.5
double f(double x, double y) {
        double r8054 = 0.5;
        double r8055 = x;
        double r8056 = r8055 * r8055;
        double r8057 = y;
        double r8058 = r8056 - r8057;
        double r8059 = r8054 * r8058;
        return r8059;
}

double f(double x, double y) {
        double r8060 = x;
        double r8061 = y;
        double r8062 = -r8061;
        double r8063 = fma(r8060, r8060, r8062);
        double r8064 = 0.5;
        double r8065 = r8063 * r8064;
        return r8065;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

    \[0.5 \cdot \left(x \cdot x - y\right)\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y)
  :name "System.Random.MWC.Distributions:standard from mwc-random-0.13.3.2"
  (* 0.5 (- (* x x) y)))