Average Error: 7.9 → 7.9
Time: 3.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 r974985 = x;
        double r974986 = y;
        double r974987 = r974985 * r974986;
        double r974988 = z;
        double r974989 = t;
        double r974990 = r974988 * r974989;
        double r974991 = r974987 - r974990;
        double r974992 = a;
        double r974993 = r974991 / r974992;
        return r974993;
}

double f(double x, double y, double z, double t, double a) {
        double r974994 = x;
        double r974995 = y;
        double r974996 = z;
        double r974997 = t;
        double r974998 = r974996 * r974997;
        double r974999 = -r974998;
        double r975000 = fma(r974994, r974995, r974999);
        double r975001 = a;
        double r975002 = r975000 / r975001;
        return r975002;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

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

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

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

Reproduce

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

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