Average Error: 7.8 → 0.8
Time: 5.6s
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 r785228 = x;
        double r785229 = y;
        double r785230 = r785228 * r785229;
        double r785231 = z;
        double r785232 = t;
        double r785233 = r785231 * r785232;
        double r785234 = r785230 - r785233;
        double r785235 = a;
        double r785236 = r785234 / r785235;
        return r785236;
}

double f(double x, double y, double z, double t, double a) {
        double r785237 = x;
        double r785238 = y;
        double r785239 = r785237 * r785238;
        double r785240 = z;
        double r785241 = t;
        double r785242 = r785240 * r785241;
        double r785243 = r785239 - r785242;
        double r785244 = -5.571537105635647e+201;
        bool r785245 = r785243 <= r785244;
        double r785246 = 1.0;
        double r785247 = r785237 / r785246;
        double r785248 = a;
        double r785249 = r785238 / r785248;
        double r785250 = r785248 / r785240;
        double r785251 = r785241 / r785250;
        double r785252 = -r785251;
        double r785253 = fma(r785247, r785249, r785252);
        double r785254 = -5.318639919188521e-101;
        bool r785255 = r785243 <= r785254;
        double r785256 = r785246 / r785248;
        double r785257 = r785241 * r785240;
        double r785258 = r785239 - r785257;
        double r785259 = r785256 * r785258;
        double r785260 = 2.7050969328804456e-219;
        bool r785261 = r785243 <= r785260;
        double r785262 = 9.866299714254809e+207;
        bool r785263 = r785243 <= r785262;
        double r785264 = r785248 / r785238;
        double r785265 = r785237 / r785264;
        double r785266 = r785265 - r785251;
        double r785267 = r785263 ? r785259 : r785266;
        double r785268 = r785261 ? r785253 : r785267;
        double r785269 = r785255 ? r785259 : r785268;
        double r785270 = r785245 ? r785253 : r785269;
        return r785270;
}

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))