Average Error: 7.3 → 0.9
Time: 13.5s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.284161215100964019331517826264419390806 \cdot 10^{268}:\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{a} \cdot z\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 1.572181209624885648767893140378987183951 \cdot 10^{197}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{\frac{z}{a}}{\frac{1}{t}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.284161215100964019331517826264419390806 \cdot 10^{268}:\\
\;\;\;\;\frac{x}{a} \cdot y - \frac{t}{a} \cdot z\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 1.572181209624885648767893140378987183951 \cdot 10^{197}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r772578 = x;
        double r772579 = y;
        double r772580 = r772578 * r772579;
        double r772581 = z;
        double r772582 = t;
        double r772583 = r772581 * r772582;
        double r772584 = r772580 - r772583;
        double r772585 = a;
        double r772586 = r772584 / r772585;
        return r772586;
}

double f(double x, double y, double z, double t, double a) {
        double r772587 = x;
        double r772588 = y;
        double r772589 = r772587 * r772588;
        double r772590 = z;
        double r772591 = t;
        double r772592 = r772590 * r772591;
        double r772593 = r772589 - r772592;
        double r772594 = -1.284161215100964e+268;
        bool r772595 = r772593 <= r772594;
        double r772596 = a;
        double r772597 = r772587 / r772596;
        double r772598 = r772597 * r772588;
        double r772599 = r772591 / r772596;
        double r772600 = r772599 * r772590;
        double r772601 = r772598 - r772600;
        double r772602 = 1.5721812096248856e+197;
        bool r772603 = r772593 <= r772602;
        double r772604 = r772593 / r772596;
        double r772605 = r772588 / r772596;
        double r772606 = r772587 * r772605;
        double r772607 = r772590 / r772596;
        double r772608 = 1.0;
        double r772609 = r772608 / r772591;
        double r772610 = r772607 / r772609;
        double r772611 = r772606 - r772610;
        double r772612 = r772603 ? r772604 : r772611;
        double r772613 = r772595 ? r772601 : r772612;
        return r772613;
}

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.3
Target6.1
Herbie0.9
\[\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.284161215100964e+268

    1. Initial program 44.3

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

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

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

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

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

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

    if -1.284161215100964e+268 < (- (* x y) (* z t)) < 1.5721812096248856e+197

    1. Initial program 0.8

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

    if 1.5721812096248856e+197 < (- (* x y) (* z t))

    1. Initial program 27.4

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

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

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

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{y}{a}} - \frac{z}{\frac{a}{t}}\]
    10. Using strategy rm
    11. Applied div-inv1.2

      \[\leadsto x \cdot \frac{y}{a} - \frac{z}{\color{blue}{a \cdot \frac{1}{t}}}\]
    12. Applied associate-/r*1.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.284161215100964019331517826264419390806 \cdot 10^{268}:\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{a} \cdot z\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 1.572181209624885648767893140378987183951 \cdot 10^{197}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{\frac{z}{a}}{\frac{1}{t}}\\ \end{array}\]

Reproduce

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