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

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

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