Average Error: 7.5 → 7.5
Time: 15.2s
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 r501618 = x;
        double r501619 = y;
        double r501620 = r501618 * r501619;
        double r501621 = z;
        double r501622 = t;
        double r501623 = r501621 * r501622;
        double r501624 = r501620 - r501623;
        double r501625 = a;
        double r501626 = r501624 / r501625;
        return r501626;
}

double f(double x, double y, double z, double t, double a) {
        double r501627 = x;
        double r501628 = y;
        double r501629 = -r501628;
        double r501630 = t;
        double r501631 = z;
        double r501632 = r501630 * r501631;
        double r501633 = fma(r501627, r501629, r501632);
        double r501634 = a;
        double r501635 = -r501634;
        double r501636 = r501633 / r501635;
        return r501636;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

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

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

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

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

Reproduce

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