Average Error: 6.7 → 6.7
Time: 17.2s
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 r35990740 = x;
        double r35990741 = y;
        double r35990742 = r35990740 * r35990741;
        double r35990743 = z;
        double r35990744 = t;
        double r35990745 = r35990743 * r35990744;
        double r35990746 = r35990742 - r35990745;
        double r35990747 = a;
        double r35990748 = r35990746 / r35990747;
        return r35990748;
}

double f(double x, double y, double z, double t, double a) {
        double r35990749 = x;
        double r35990750 = y;
        double r35990751 = z;
        double r35990752 = t;
        double r35990753 = r35990751 * r35990752;
        double r35990754 = -r35990753;
        double r35990755 = fma(r35990749, r35990750, r35990754);
        double r35990756 = a;
        double r35990757 = r35990755 / r35990756;
        return r35990757;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original6.7
Target5.8
Herbie6.7
\[\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 6.7

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

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

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

Reproduce

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