Average Error: 7.6 → 4.2
Time: 3.2s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -7.5984503078025436 \cdot 10^{138}:\\ \;\;\;\;\frac{x \cdot y}{a} - t \cdot \left(z \cdot \frac{1}{a}\right)\\ \mathbf{elif}\;x \cdot y \le 2.500198658412242 \cdot 10^{252}:\\ \;\;\;\;\frac{x \cdot y}{a} - \left(t \cdot z\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y = -\infty:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r885389 = x;
        double r885390 = y;
        double r885391 = r885389 * r885390;
        double r885392 = z;
        double r885393 = t;
        double r885394 = r885392 * r885393;
        double r885395 = r885391 - r885394;
        double r885396 = a;
        double r885397 = r885395 / r885396;
        return r885397;
}

double f(double x, double y, double z, double t, double a) {
        double r885398 = x;
        double r885399 = y;
        double r885400 = r885398 * r885399;
        double r885401 = -inf.0;
        bool r885402 = r885400 <= r885401;
        double r885403 = a;
        double r885404 = r885399 / r885403;
        double r885405 = r885398 * r885404;
        double r885406 = t;
        double r885407 = z;
        double r885408 = r885406 * r885407;
        double r885409 = r885408 / r885403;
        double r885410 = r885405 - r885409;
        double r885411 = -7.598450307802544e+138;
        bool r885412 = r885400 <= r885411;
        double r885413 = r885400 / r885403;
        double r885414 = 1.0;
        double r885415 = r885414 / r885403;
        double r885416 = r885407 * r885415;
        double r885417 = r885406 * r885416;
        double r885418 = r885413 - r885417;
        double r885419 = 2.500198658412242e+252;
        bool r885420 = r885400 <= r885419;
        double r885421 = r885408 * r885415;
        double r885422 = r885413 - r885421;
        double r885423 = r885420 ? r885422 : r885410;
        double r885424 = r885412 ? r885418 : r885423;
        double r885425 = r885402 ? r885410 : r885424;
        return r885425;
}

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.6
Target6.2
Herbie4.2
\[\begin{array}{l} \mathbf{if}\;z \lt -2.46868496869954822 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.30983112197837121 \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) < -inf.0 or 2.500198658412242e+252 < (* x y)

    1. Initial program 48.1

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

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

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

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

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

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

    if -inf.0 < (* x y) < -7.598450307802544e+138

    1. Initial program 5.5

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

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

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

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

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

    if -7.598450307802544e+138 < (* x y) < 2.500198658412242e+252

    1. Initial program 4.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le -7.5984503078025436 \cdot 10^{138}:\\ \;\;\;\;\frac{x \cdot y}{a} - t \cdot \left(z \cdot \frac{1}{a}\right)\\ \mathbf{elif}\;x \cdot y \le 2.500198658412242 \cdot 10^{252}:\\ \;\;\;\;\frac{x \cdot y}{a} - \left(t \cdot z\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

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