Average Error: 8.0 → 1.0
Time: 15.3s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -4.383331106152861900951102199381909984691 \cdot 10^{280}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\ \mathbf{elif}\;x \cdot y - z \cdot t \le -4.786275461705487451909418853171691851444 \cdot 10^{-219} \lor \neg \left(x \cdot y - z \cdot t \le 1.208173474037350523235565944307269650349 \cdot 10^{-137}\right) \land x \cdot y - z \cdot t \le 2.18948982729949330391777060282568530612 \cdot 10^{176}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a} - t \cdot \frac{z}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -4.383331106152861900951102199381909984691 \cdot 10^{280}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\

\mathbf{elif}\;x \cdot y - z \cdot t \le -4.786275461705487451909418853171691851444 \cdot 10^{-219} \lor \neg \left(x \cdot y - z \cdot t \le 1.208173474037350523235565944307269650349 \cdot 10^{-137}\right) \land x \cdot y - z \cdot t \le 2.18948982729949330391777060282568530612 \cdot 10^{176}:\\
\;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r645786 = x;
        double r645787 = y;
        double r645788 = r645786 * r645787;
        double r645789 = z;
        double r645790 = t;
        double r645791 = r645789 * r645790;
        double r645792 = r645788 - r645791;
        double r645793 = a;
        double r645794 = r645792 / r645793;
        return r645794;
}

double f(double x, double y, double z, double t, double a) {
        double r645795 = x;
        double r645796 = y;
        double r645797 = r645795 * r645796;
        double r645798 = z;
        double r645799 = t;
        double r645800 = r645798 * r645799;
        double r645801 = r645797 - r645800;
        double r645802 = -4.383331106152862e+280;
        bool r645803 = r645801 <= r645802;
        double r645804 = a;
        double r645805 = r645804 / r645796;
        double r645806 = r645795 / r645805;
        double r645807 = r645799 / r645804;
        double r645808 = r645807 * r645798;
        double r645809 = r645806 - r645808;
        double r645810 = -4.7862754617054875e-219;
        bool r645811 = r645801 <= r645810;
        double r645812 = 1.2081734740373505e-137;
        bool r645813 = r645801 <= r645812;
        double r645814 = !r645813;
        double r645815 = 2.1894898272994933e+176;
        bool r645816 = r645801 <= r645815;
        bool r645817 = r645814 && r645816;
        bool r645818 = r645811 || r645817;
        double r645819 = 1.0;
        double r645820 = r645804 / r645801;
        double r645821 = r645819 / r645820;
        double r645822 = r645795 / r645804;
        double r645823 = r645796 * r645822;
        double r645824 = r645798 / r645804;
        double r645825 = r645799 * r645824;
        double r645826 = r645823 - r645825;
        double r645827 = r645818 ? r645821 : r645826;
        double r645828 = r645803 ? r645809 : r645827;
        return r645828;
}

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

Original8.0
Target6.2
Herbie1.0
\[\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)) < -4.383331106152862e+280

    1. Initial program 50.3

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

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

      \[\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 inf 50.3

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

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

    if -4.383331106152862e+280 < (- (* x y) (* z t)) < -4.7862754617054875e-219 or 1.2081734740373505e-137 < (- (* x y) (* z t)) < 2.1894898272994933e+176

    1. Initial program 0.2

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

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

    if -4.7862754617054875e-219 < (- (* x y) (* z t)) < 1.2081734740373505e-137 or 2.1894898272994933e+176 < (- (* x y) (* z t))

    1. Initial program 17.5

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

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

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

      \[\leadsto \frac{x}{a} \cdot y - \color{blue}{\frac{z}{\frac{a}{t}}}\]
    6. Using strategy rm
    7. Applied associate-/r/2.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -4.383331106152861900951102199381909984691 \cdot 10^{280}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\ \mathbf{elif}\;x \cdot y - z \cdot t \le -4.786275461705487451909418853171691851444 \cdot 10^{-219} \lor \neg \left(x \cdot y - z \cdot t \le 1.208173474037350523235565944307269650349 \cdot 10^{-137}\right) \land x \cdot y - z \cdot t \le 2.18948982729949330391777060282568530612 \cdot 10^{176}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{a} - t \cdot \frac{z}{a}\\ \end{array}\]

Reproduce

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