Average Error: 0.0 → 0.0
Time: 5.0s
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 r140661 = 0.5;
        double r140662 = x;
        double r140663 = r140662 * r140662;
        double r140664 = y;
        double r140665 = r140663 - r140664;
        double r140666 = r140661 * r140665;
        return r140666;
}

double f(double x, double y) {
        double r140667 = x;
        double r140668 = y;
        double r140669 = -r140668;
        double r140670 = fma(r140667, r140667, r140669);
        double r140671 = 0.5;
        double r140672 = r140670 * r140671;
        return r140672;
}

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. Using strategy rm
  3. Applied fma-neg0.0

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

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

Reproduce

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