Average Error: 7.5 → 7.5
Time: 16.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 r1275727 = x;
        double r1275728 = y;
        double r1275729 = r1275727 * r1275728;
        double r1275730 = z;
        double r1275731 = t;
        double r1275732 = r1275730 * r1275731;
        double r1275733 = r1275729 - r1275732;
        double r1275734 = a;
        double r1275735 = r1275733 / r1275734;
        return r1275735;
}

double f(double x, double y, double z, double t, double a) {
        double r1275736 = x;
        double r1275737 = y;
        double r1275738 = -r1275737;
        double r1275739 = t;
        double r1275740 = z;
        double r1275741 = r1275739 * r1275740;
        double r1275742 = fma(r1275736, r1275738, r1275741);
        double r1275743 = a;
        double r1275744 = -r1275743;
        double r1275745 = r1275742 / r1275744;
        return r1275745;
}

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 2019306 +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.46868496869954822e170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.30983112197837121e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))