Average Error: 7.2 → 6.2
Time: 12.7s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \le -9.637778577628268 \cdot 10^{+191}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;a \le 1.8721002625462693 \cdot 10^{-84}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;a \le 7.642381353223433 \cdot 10^{+278}:\\ \;\;\;\;\frac{x \cdot y}{a} - t \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;a \le -9.637778577628268 \cdot 10^{+191}:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\

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

\mathbf{elif}\;a \le 7.642381353223433 \cdot 10^{+278}:\\
\;\;\;\;\frac{x \cdot y}{a} - t \cdot \frac{z}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r41764286 = x;
        double r41764287 = y;
        double r41764288 = r41764286 * r41764287;
        double r41764289 = z;
        double r41764290 = t;
        double r41764291 = r41764289 * r41764290;
        double r41764292 = r41764288 - r41764291;
        double r41764293 = a;
        double r41764294 = r41764292 / r41764293;
        return r41764294;
}

double f(double x, double y, double z, double t, double a) {
        double r41764295 = a;
        double r41764296 = -9.637778577628268e+191;
        bool r41764297 = r41764295 <= r41764296;
        double r41764298 = x;
        double r41764299 = y;
        double r41764300 = r41764299 / r41764295;
        double r41764301 = r41764298 * r41764300;
        double r41764302 = z;
        double r41764303 = t;
        double r41764304 = r41764302 * r41764303;
        double r41764305 = r41764304 / r41764295;
        double r41764306 = r41764301 - r41764305;
        double r41764307 = 1.8721002625462693e-84;
        bool r41764308 = r41764295 <= r41764307;
        double r41764309 = r41764298 * r41764299;
        double r41764310 = r41764309 - r41764304;
        double r41764311 = 1.0;
        double r41764312 = r41764311 / r41764295;
        double r41764313 = r41764310 * r41764312;
        double r41764314 = 7.642381353223433e+278;
        bool r41764315 = r41764295 <= r41764314;
        double r41764316 = r41764309 / r41764295;
        double r41764317 = r41764302 / r41764295;
        double r41764318 = r41764303 * r41764317;
        double r41764319 = r41764316 - r41764318;
        double r41764320 = r41764315 ? r41764319 : r41764306;
        double r41764321 = r41764308 ? r41764313 : r41764320;
        double r41764322 = r41764297 ? r41764306 : r41764321;
        return r41764322;
}

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.2
Target5.6
Herbie6.2
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371 \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 a < -9.637778577628268e+191 or 7.642381353223433e+278 < a

    1. Initial program 13.6

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

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

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

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

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

    if -9.637778577628268e+191 < a < 1.8721002625462693e-84

    1. Initial program 4.1

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

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

    if 1.8721002625462693e-84 < a < 7.642381353223433e+278

    1. Initial program 8.5

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Taylor expanded around 0 8.5

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -9.637778577628268 \cdot 10^{+191}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;a \le 1.8721002625462693 \cdot 10^{-84}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;a \le 7.642381353223433 \cdot 10^{+278}:\\ \;\;\;\;\frac{x \cdot y}{a} - t \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \end{array}\]

Reproduce

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