Average Error: 7.6 → 0.7
Time: 13.4s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -3.339667653993158922458762552949546866149 \cdot 10^{287} \lor \neg \left(x \cdot y - z \cdot t \le 4.681279714610344744150833825920741179863 \cdot 10^{292}\right):\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{a} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -3.339667653993158922458762552949546866149 \cdot 10^{287} \lor \neg \left(x \cdot y - z \cdot t \le 4.681279714610344744150833825920741179863 \cdot 10^{292}\right):\\
\;\;\;\;\frac{x}{a} \cdot y - \frac{t}{a} \cdot z\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r583681 = x;
        double r583682 = y;
        double r583683 = r583681 * r583682;
        double r583684 = z;
        double r583685 = t;
        double r583686 = r583684 * r583685;
        double r583687 = r583683 - r583686;
        double r583688 = a;
        double r583689 = r583687 / r583688;
        return r583689;
}

double f(double x, double y, double z, double t, double a) {
        double r583690 = x;
        double r583691 = y;
        double r583692 = r583690 * r583691;
        double r583693 = z;
        double r583694 = t;
        double r583695 = r583693 * r583694;
        double r583696 = r583692 - r583695;
        double r583697 = -3.339667653993159e+287;
        bool r583698 = r583696 <= r583697;
        double r583699 = 4.681279714610345e+292;
        bool r583700 = r583696 <= r583699;
        double r583701 = !r583700;
        bool r583702 = r583698 || r583701;
        double r583703 = a;
        double r583704 = r583690 / r583703;
        double r583705 = r583704 * r583691;
        double r583706 = r583694 / r583703;
        double r583707 = r583706 * r583693;
        double r583708 = r583705 - r583707;
        double r583709 = r583696 / r583703;
        double r583710 = r583702 ? r583708 : r583709;
        return r583710;
}

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
Target5.8
Herbie0.7
\[\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)) < -3.339667653993159e+287 or 4.681279714610345e+292 < (- (* x y) (* z t))

    1. Initial program 54.1

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

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

      \[\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. Taylor expanded around 0 30.9

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

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

    if -3.339667653993159e+287 < (- (* x y) (* z t)) < 4.681279714610345e+292

    1. Initial program 0.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -3.339667653993158922458762552949546866149 \cdot 10^{287} \lor \neg \left(x \cdot y - z \cdot t \le 4.681279714610344744150833825920741179863 \cdot 10^{292}\right):\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{a} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array}\]

Reproduce

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