Average Error: 7.2 → 7.2
Time: 14.6s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(z, t, -x \cdot y\right)}{-a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(z, t, -x \cdot y\right)}{-a}
double f(double x, double y, double z, double t, double a) {
        double r35797331 = x;
        double r35797332 = y;
        double r35797333 = r35797331 * r35797332;
        double r35797334 = z;
        double r35797335 = t;
        double r35797336 = r35797334 * r35797335;
        double r35797337 = r35797333 - r35797336;
        double r35797338 = a;
        double r35797339 = r35797337 / r35797338;
        return r35797339;
}

double f(double x, double y, double z, double t, double a) {
        double r35797340 = z;
        double r35797341 = t;
        double r35797342 = x;
        double r35797343 = y;
        double r35797344 = r35797342 * r35797343;
        double r35797345 = -r35797344;
        double r35797346 = fma(r35797340, r35797341, r35797345);
        double r35797347 = a;
        double r35797348 = -r35797347;
        double r35797349 = r35797346 / r35797348;
        return r35797349;
}

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 frac-2neg7.2

    \[\leadsto \color{blue}{\frac{-\left(x \cdot y - z \cdot t\right)}{-a}}\]
  4. Simplified7.2

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

    \[\leadsto \frac{\mathsf{fma}\left(z, t, -x \cdot y\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))