Average Error: 7.7 → 1.8
Time: 2.5m
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -2.829533880468204293018311062466912085651 \cdot 10^{150}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -z \cdot \frac{t}{a}\right) + \mathsf{fma}\left(-\frac{t}{a}, z, z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.560348681674806982161079926590341946882 \cdot 10^{214}:\\ \;\;\;\;\left(\sqrt[3]{x \cdot y - z \cdot t} \cdot \sqrt[3]{x \cdot y - z \cdot t}\right) \cdot \frac{\sqrt[3]{x \cdot y - z \cdot t}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -z \cdot \frac{t}{a}\right) + \mathsf{fma}\left(-\frac{t}{a}, z, z \cdot \frac{t}{a}\right)\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -2.829533880468204293018311062466912085651 \cdot 10^{150}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -z \cdot \frac{t}{a}\right) + \mathsf{fma}\left(-\frac{t}{a}, z, z \cdot \frac{t}{a}\right)\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 2.560348681674806982161079926590341946882 \cdot 10^{214}:\\
\;\;\;\;\left(\sqrt[3]{x \cdot y - z \cdot t} \cdot \sqrt[3]{x \cdot y - z \cdot t}\right) \cdot \frac{\sqrt[3]{x \cdot y - z \cdot t}}{a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -z \cdot \frac{t}{a}\right) + \mathsf{fma}\left(-\frac{t}{a}, z, z \cdot \frac{t}{a}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r198633761 = x;
        double r198633762 = y;
        double r198633763 = r198633761 * r198633762;
        double r198633764 = z;
        double r198633765 = t;
        double r198633766 = r198633764 * r198633765;
        double r198633767 = r198633763 - r198633766;
        double r198633768 = a;
        double r198633769 = r198633767 / r198633768;
        return r198633769;
}

double f(double x, double y, double z, double t, double a) {
        double r198633770 = x;
        double r198633771 = y;
        double r198633772 = r198633770 * r198633771;
        double r198633773 = z;
        double r198633774 = t;
        double r198633775 = r198633773 * r198633774;
        double r198633776 = r198633772 - r198633775;
        double r198633777 = -2.8295338804682043e+150;
        bool r198633778 = r198633776 <= r198633777;
        double r198633779 = a;
        double r198633780 = r198633771 / r198633779;
        double r198633781 = r198633774 / r198633779;
        double r198633782 = r198633773 * r198633781;
        double r198633783 = -r198633782;
        double r198633784 = fma(r198633770, r198633780, r198633783);
        double r198633785 = -r198633781;
        double r198633786 = fma(r198633785, r198633773, r198633782);
        double r198633787 = r198633784 + r198633786;
        double r198633788 = 2.560348681674807e+214;
        bool r198633789 = r198633776 <= r198633788;
        double r198633790 = cbrt(r198633776);
        double r198633791 = r198633790 * r198633790;
        double r198633792 = r198633790 / r198633779;
        double r198633793 = r198633791 * r198633792;
        double r198633794 = r198633789 ? r198633793 : r198633787;
        double r198633795 = r198633778 ? r198633787 : r198633794;
        return r198633795;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.7
Target6.0
Herbie1.8
\[\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)) < -2.8295338804682043e+150 or 2.560348681674807e+214 < (- (* x y) (* z t))

    1. Initial program 25.2

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{z}{1} \cdot \frac{t}{a}}\]
    7. Applied *-un-lft-identity14.5

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{z}{1} \cdot \frac{t}{a}\]
    9. Applied prod-diff1.6

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

    if -2.8295338804682043e+150 < (- (* x y) (* z t)) < 2.560348681674807e+214

    1. Initial program 1.0

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity1.0

      \[\leadsto \frac{x \cdot y - z \cdot t}{\color{blue}{1 \cdot a}}\]
    4. Applied add-cube-cbrt1.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{x \cdot y - z \cdot t} \cdot \sqrt[3]{x \cdot y - z \cdot t}\right) \cdot \sqrt[3]{x \cdot y - z \cdot t}}}{1 \cdot a}\]
    5. Applied times-frac1.9

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x \cdot y - z \cdot t} \cdot \sqrt[3]{x \cdot y - z \cdot t}}{1} \cdot \frac{\sqrt[3]{x \cdot y - z \cdot t}}{a}}\]
    6. Simplified1.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -2.829533880468204293018311062466912085651 \cdot 10^{150}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -z \cdot \frac{t}{a}\right) + \mathsf{fma}\left(-\frac{t}{a}, z, z \cdot \frac{t}{a}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.560348681674806982161079926590341946882 \cdot 10^{214}:\\ \;\;\;\;\left(\sqrt[3]{x \cdot y - z \cdot t} \cdot \sqrt[3]{x \cdot y - z \cdot t}\right) \cdot \frac{\sqrt[3]{x \cdot y - z \cdot t}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{a}, -z \cdot \frac{t}{a}\right) + \mathsf{fma}\left(-\frac{t}{a}, z, z \cdot \frac{t}{a}\right)\\ \end{array}\]

Reproduce

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