Average Error: 7.3 → 7.3
Time: 44.3s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(x, y, \left(-t\right) \cdot z\right)}{a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(x, y, \left(-t\right) \cdot z\right)}{a}
double f(double x, double y, double z, double t, double a) {
        double r38254254 = x;
        double r38254255 = y;
        double r38254256 = r38254254 * r38254255;
        double r38254257 = z;
        double r38254258 = t;
        double r38254259 = r38254257 * r38254258;
        double r38254260 = r38254256 - r38254259;
        double r38254261 = a;
        double r38254262 = r38254260 / r38254261;
        return r38254262;
}

double f(double x, double y, double z, double t, double a) {
        double r38254263 = x;
        double r38254264 = y;
        double r38254265 = t;
        double r38254266 = -r38254265;
        double r38254267 = z;
        double r38254268 = r38254266 * r38254267;
        double r38254269 = fma(r38254263, r38254264, r38254268);
        double r38254270 = a;
        double r38254271 = r38254269 / r38254270;
        return r38254271;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.3
Target5.9
Herbie7.3
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548224247694913169778644284 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371209578784129518242708809 \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.3

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

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

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

Reproduce

herbie shell --seed 2019200 +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))