Average Error: 7.3 → 7.3
Time: 19.5s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(x, y, -t \cdot z\right)}{a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(x, y, -t \cdot z\right)}{a}
double f(double x, double y, double z, double t, double a) {
        double r590672 = x;
        double r590673 = y;
        double r590674 = r590672 * r590673;
        double r590675 = z;
        double r590676 = t;
        double r590677 = r590675 * r590676;
        double r590678 = r590674 - r590677;
        double r590679 = a;
        double r590680 = r590678 / r590679;
        return r590680;
}

double f(double x, double y, double z, double t, double a) {
        double r590681 = x;
        double r590682 = y;
        double r590683 = t;
        double r590684 = z;
        double r590685 = r590683 * r590684;
        double r590686 = -r590685;
        double r590687 = fma(r590681, r590682, r590686);
        double r590688 = a;
        double r590689 = r590687 / r590688;
        return r590689;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

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

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

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

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

Reproduce

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