Average Error: 0.0 → 0.0
Time: 4.9s
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 r140653 = 0.5;
        double r140654 = x;
        double r140655 = r140654 * r140654;
        double r140656 = y;
        double r140657 = r140655 - r140656;
        double r140658 = r140653 * r140657;
        return r140658;
}

double f(double x, double y) {
        double r140659 = x;
        double r140660 = y;
        double r140661 = -r140660;
        double r140662 = fma(r140659, r140659, r140661);
        double r140663 = 0.5;
        double r140664 = r140662 * r140663;
        return r140664;
}

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 2019171 +o rules:numerics
(FPCore (x y)
  :name "System.Random.MWC.Distributions:standard from mwc-random-0.13.3.2"
  (* 0.5 (- (* x x) y)))