Average Error: 7.8 → 7.8
Time: 14.4s
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 r38756089 = x;
        double r38756090 = y;
        double r38756091 = r38756089 * r38756090;
        double r38756092 = z;
        double r38756093 = t;
        double r38756094 = r38756092 * r38756093;
        double r38756095 = r38756091 - r38756094;
        double r38756096 = a;
        double r38756097 = r38756095 / r38756096;
        return r38756097;
}

double f(double x, double y, double z, double t, double a) {
        double r38756098 = x;
        double r38756099 = y;
        double r38756100 = z;
        double r38756101 = t;
        double r38756102 = r38756100 * r38756101;
        double r38756103 = -r38756102;
        double r38756104 = fma(r38756098, r38756099, r38756103);
        double r38756105 = a;
        double r38756106 = r38756104 / r38756105;
        return r38756106;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.8
Target5.9
Herbie7.8
\[\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.8

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

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

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

Reproduce

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