Average Error: 7.2 → 7.2
Time: 14.1s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(x, y, -z \cdot t\right)}{a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(x, y, -z \cdot t\right)}{a}
double f(double x, double y, double z, double t, double a) {
        double r38078324 = x;
        double r38078325 = y;
        double r38078326 = r38078324 * r38078325;
        double r38078327 = z;
        double r38078328 = t;
        double r38078329 = r38078327 * r38078328;
        double r38078330 = r38078326 - r38078329;
        double r38078331 = a;
        double r38078332 = r38078330 / r38078331;
        return r38078332;
}

double f(double x, double y, double z, double t, double a) {
        double r38078333 = x;
        double r38078334 = y;
        double r38078335 = z;
        double r38078336 = t;
        double r38078337 = r38078335 * r38078336;
        double r38078338 = -r38078337;
        double r38078339 = fma(r38078333, r38078334, r38078338);
        double r38078340 = a;
        double r38078341 = r38078339 / r38078340;
        return r38078341;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.2
Target5.6
Herbie7.2
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array}\]

Derivation

  1. Initial program 7.2

    \[\frac{x \cdot y - z \cdot t}{a}\]
  2. Using strategy rm
  3. Applied fma-neg7.2

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, -z \cdot t\right)}}{a}\]
  4. Final simplification7.2

    \[\leadsto \frac{\mathsf{fma}\left(x, y, -z \cdot t\right)}{a}\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))