Average Error: 7.6 → 1.3
Time: 11.2s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.703235287902862224100755201234564323846 \cdot 10^{231} \lor \neg \left(x \cdot y - z \cdot t \le 7.357670235460499077841315140089746402074 \cdot 10^{238}\right):\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, \left(-\frac{z}{a}\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{\frac{t \cdot z}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.703235287902862224100755201234564323846 \cdot 10^{231} \lor \neg \left(x \cdot y - z \cdot t \le 7.357670235460499077841315140089746402074 \cdot 10^{238}\right):\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, \left(-\frac{z}{a}\right) \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{a} - \frac{\frac{t \cdot z}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r615063 = x;
        double r615064 = y;
        double r615065 = r615063 * r615064;
        double r615066 = z;
        double r615067 = t;
        double r615068 = r615066 * r615067;
        double r615069 = r615065 - r615068;
        double r615070 = a;
        double r615071 = r615069 / r615070;
        return r615071;
}

double f(double x, double y, double z, double t, double a) {
        double r615072 = x;
        double r615073 = y;
        double r615074 = r615072 * r615073;
        double r615075 = z;
        double r615076 = t;
        double r615077 = r615075 * r615076;
        double r615078 = r615074 - r615077;
        double r615079 = -1.7032352879028622e+231;
        bool r615080 = r615078 <= r615079;
        double r615081 = 7.357670235460499e+238;
        bool r615082 = r615078 <= r615081;
        double r615083 = !r615082;
        bool r615084 = r615080 || r615083;
        double r615085 = a;
        double r615086 = r615073 / r615085;
        double r615087 = r615075 / r615085;
        double r615088 = -r615087;
        double r615089 = r615088 * r615076;
        double r615090 = fma(r615072, r615086, r615089);
        double r615091 = r615074 / r615085;
        double r615092 = r615076 * r615075;
        double r615093 = cbrt(r615085);
        double r615094 = r615093 * r615093;
        double r615095 = r615092 / r615094;
        double r615096 = r615095 / r615093;
        double r615097 = r615091 - r615096;
        double r615098 = r615084 ? r615090 : r615097;
        return r615098;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.6
Target5.8
Herbie1.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. Split input into 2 regimes
  2. if (- (* x y) (* z t)) < -1.7032352879028622e+231 or 7.357670235460499e+238 < (- (* x y) (* z t))

    1. Initial program 35.6

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified35.6

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity35.6

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{t \cdot z}{a}\]
    7. Applied times-frac19.6

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{t \cdot z}{a}\]
    8. Applied fma-neg19.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t \cdot z}{a}\right)}\]
    9. Simplified0.6

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

    if -1.7032352879028622e+231 < (- (* x y) (* z t)) < 7.357670235460499e+238

    1. Initial program 0.9

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified0.9

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt1.4

      \[\leadsto \frac{x \cdot y}{a} - \frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    7. Applied associate-/r*1.4

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{\frac{t \cdot z}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.703235287902862224100755201234564323846 \cdot 10^{231} \lor \neg \left(x \cdot y - z \cdot t \le 7.357670235460499077841315140089746402074 \cdot 10^{238}\right):\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, \left(-\frac{z}{a}\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{\frac{t \cdot z}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}\\ \end{array}\]

Reproduce

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