Average Error: 7.8 → 0.8
Time: 5.8s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -5.571537105635647305055441915656520766598 \cdot 10^{201}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le -5.318639919188520705096400337034496027923 \cdot 10^{-101}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.705096932880445635207773638884756059712 \cdot 10^{-219}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 9.866299714254808615331411381510550183903 \cdot 10^{207}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -5.571537105635647305055441915656520766598 \cdot 10^{201}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\

\mathbf{elif}\;x \cdot y - z \cdot t \le -5.318639919188520705096400337034496027923 \cdot 10^{-101}:\\
\;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 2.705096932880445635207773638884756059712 \cdot 10^{-219}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 9.866299714254808615331411381510550183903 \cdot 10^{207}:\\
\;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r842826 = x;
        double r842827 = y;
        double r842828 = r842826 * r842827;
        double r842829 = z;
        double r842830 = t;
        double r842831 = r842829 * r842830;
        double r842832 = r842828 - r842831;
        double r842833 = a;
        double r842834 = r842832 / r842833;
        return r842834;
}

double f(double x, double y, double z, double t, double a) {
        double r842835 = x;
        double r842836 = y;
        double r842837 = r842835 * r842836;
        double r842838 = z;
        double r842839 = t;
        double r842840 = r842838 * r842839;
        double r842841 = r842837 - r842840;
        double r842842 = -5.571537105635647e+201;
        bool r842843 = r842841 <= r842842;
        double r842844 = 1.0;
        double r842845 = r842835 / r842844;
        double r842846 = a;
        double r842847 = r842836 / r842846;
        double r842848 = r842846 / r842838;
        double r842849 = r842839 / r842848;
        double r842850 = -r842849;
        double r842851 = fma(r842845, r842847, r842850);
        double r842852 = -5.318639919188521e-101;
        bool r842853 = r842841 <= r842852;
        double r842854 = r842844 / r842846;
        double r842855 = r842839 * r842838;
        double r842856 = r842837 - r842855;
        double r842857 = r842854 * r842856;
        double r842858 = 2.7050969328804456e-219;
        bool r842859 = r842841 <= r842858;
        double r842860 = 9.866299714254809e+207;
        bool r842861 = r842841 <= r842860;
        double r842862 = r842846 / r842836;
        double r842863 = r842835 / r842862;
        double r842864 = r842863 - r842849;
        double r842865 = r842861 ? r842857 : r842864;
        double r842866 = r842859 ? r842851 : r842865;
        double r842867 = r842853 ? r842857 : r842866;
        double r842868 = r842843 ? r842851 : r842867;
        return r842868;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.8
Target6.1
Herbie0.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 3 regimes
  2. if (- (* x y) (* z t)) < -5.571537105635647e+201 or -5.318639919188521e-101 < (- (* x y) (* z t)) < 2.7050969328804456e-219

    1. Initial program 17.9

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied associate-/l*10.5

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

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

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

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

    if -5.571537105635647e+201 < (- (* x y) (* z t)) < -5.318639919188521e-101 or 2.7050969328804456e-219 < (- (* x y) (* z t)) < 9.866299714254809e+207

    1. Initial program 0.3

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied div-inv0.3

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{a}}\]
    7. Applied div-inv0.3

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{a}} - \left(t \cdot z\right) \cdot \frac{1}{a}\]
    8. Applied distribute-rgt-out--0.3

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

    if 9.866299714254809e+207 < (- (* x y) (* z t))

    1. Initial program 29.1

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied associate-/l*16.8

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t}{\frac{a}{z}}}\]
    7. Using strategy rm
    8. Applied associate-/l*0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -5.571537105635647305055441915656520766598 \cdot 10^{201}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le -5.318639919188520705096400337034496027923 \cdot 10^{-101}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.705096932880445635207773638884756059712 \cdot 10^{-219}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 9.866299714254808615331411381510550183903 \cdot 10^{207}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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