Average Error: 7.7 → 1.3
Time: 16.4s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -9.394719029713430336184196844060657080243 \cdot 10^{217}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t}{a} \cdot z\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 1.124253069602987652296527783384903075511 \cdot 10^{149}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t}{a} \cdot z\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -9.394719029713430336184196844060657080243 \cdot 10^{217}:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{t}{a} \cdot z\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r39236324 = x;
        double r39236325 = y;
        double r39236326 = r39236324 * r39236325;
        double r39236327 = z;
        double r39236328 = t;
        double r39236329 = r39236327 * r39236328;
        double r39236330 = r39236326 - r39236329;
        double r39236331 = a;
        double r39236332 = r39236330 / r39236331;
        return r39236332;
}

double f(double x, double y, double z, double t, double a) {
        double r39236333 = x;
        double r39236334 = y;
        double r39236335 = r39236333 * r39236334;
        double r39236336 = z;
        double r39236337 = t;
        double r39236338 = r39236336 * r39236337;
        double r39236339 = r39236335 - r39236338;
        double r39236340 = -9.39471902971343e+217;
        bool r39236341 = r39236339 <= r39236340;
        double r39236342 = a;
        double r39236343 = r39236334 / r39236342;
        double r39236344 = r39236333 * r39236343;
        double r39236345 = r39236337 / r39236342;
        double r39236346 = r39236345 * r39236336;
        double r39236347 = r39236344 - r39236346;
        double r39236348 = 1.1242530696029877e+149;
        bool r39236349 = r39236339 <= r39236348;
        double r39236350 = 1.0;
        double r39236351 = r39236350 / r39236342;
        double r39236352 = r39236351 * r39236339;
        double r39236353 = r39236349 ? r39236352 : r39236347;
        double r39236354 = r39236341 ? r39236347 : r39236353;
        return r39236354;
}

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.7
Target5.9
Herbie1.3
\[\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)) < -9.39471902971343e+217 or 1.1242530696029877e+149 < (- (* x y) (* z t))

    1. Initial program 25.3

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

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

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

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

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

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

      \[\leadsto x \cdot \frac{y}{a} - \color{blue}{\frac{z}{1} \cdot \frac{t}{a}}\]
    11. Simplified2.0

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

    if -9.39471902971343e+217 < (- (* x y) (* z t)) < 1.1242530696029877e+149

    1. Initial program 0.9

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

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

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

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

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

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

Reproduce

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