Average Error: 7.4 → 4.5
Time: 3.0s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.382041856187151941628952525789930687569 \cdot 10^{163}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 1.405304208610043958519867955179698881269 \cdot 10^{146}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{a} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{1}{\frac{\frac{a}{t}}{z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.382041856187151941628952525789930687569 \cdot 10^{163}:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r875284 = x;
        double r875285 = y;
        double r875286 = r875284 * r875285;
        double r875287 = z;
        double r875288 = t;
        double r875289 = r875287 * r875288;
        double r875290 = r875286 - r875289;
        double r875291 = a;
        double r875292 = r875290 / r875291;
        return r875292;
}

double f(double x, double y, double z, double t, double a) {
        double r875293 = x;
        double r875294 = y;
        double r875295 = r875293 * r875294;
        double r875296 = z;
        double r875297 = t;
        double r875298 = r875296 * r875297;
        double r875299 = r875295 - r875298;
        double r875300 = -1.382041856187152e+163;
        bool r875301 = r875299 <= r875300;
        double r875302 = a;
        double r875303 = r875294 / r875302;
        double r875304 = r875293 * r875303;
        double r875305 = r875297 * r875296;
        double r875306 = r875305 / r875302;
        double r875307 = r875304 - r875306;
        double r875308 = 1.405304208610044e+146;
        bool r875309 = r875299 <= r875308;
        double r875310 = 1.0;
        double r875311 = r875310 / r875302;
        double r875312 = r875295 * r875311;
        double r875313 = r875312 - r875306;
        double r875314 = r875295 / r875302;
        double r875315 = r875302 / r875297;
        double r875316 = r875315 / r875296;
        double r875317 = r875310 / r875316;
        double r875318 = r875314 - r875317;
        double r875319 = r875309 ? r875313 : r875318;
        double r875320 = r875301 ? r875307 : r875319;
        return r875320;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.4
Target6.0
Herbie4.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. Split input into 3 regimes
  2. if (- (* x y) (* z t)) < -1.382041856187152e+163

    1. Initial program 22.1

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

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

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

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

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

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

    if -1.382041856187152e+163 < (- (* x y) (* z t)) < 1.405304208610044e+146

    1. Initial program 1.0

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

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

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

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

    if 1.405304208610044e+146 < (- (* x y) (* z t))

    1. Initial program 19.9

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied clear-num19.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.382041856187151941628952525789930687569 \cdot 10^{163}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 1.405304208610043958519867955179698881269 \cdot 10^{146}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{a} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{1}{\frac{\frac{a}{t}}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019356 
(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))