Average Error: 7.7 → 7.7
Time: 18.6s
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 r35815275 = x;
        double r35815276 = y;
        double r35815277 = r35815275 * r35815276;
        double r35815278 = z;
        double r35815279 = t;
        double r35815280 = r35815278 * r35815279;
        double r35815281 = r35815277 - r35815280;
        double r35815282 = a;
        double r35815283 = r35815281 / r35815282;
        return r35815283;
}

double f(double x, double y, double z, double t, double a) {
        double r35815284 = x;
        double r35815285 = y;
        double r35815286 = z;
        double r35815287 = t;
        double r35815288 = r35815286 * r35815287;
        double r35815289 = -r35815288;
        double r35815290 = fma(r35815284, r35815285, r35815289);
        double r35815291 = a;
        double r35815292 = r35815290 / r35815291;
        return r35815292;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.7
Target6.2
Herbie7.7
\[\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.7

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

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

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

Reproduce

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