Average Error: 7.6 → 0.7
Time: 13.7s
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 r657791 = x;
        double r657792 = y;
        double r657793 = r657791 * r657792;
        double r657794 = z;
        double r657795 = t;
        double r657796 = r657794 * r657795;
        double r657797 = r657793 - r657796;
        double r657798 = a;
        double r657799 = r657797 / r657798;
        return r657799;
}

double f(double x, double y, double z, double t, double a) {
        double r657800 = x;
        double r657801 = y;
        double r657802 = r657800 * r657801;
        double r657803 = z;
        double r657804 = t;
        double r657805 = r657803 * r657804;
        double r657806 = r657802 - r657805;
        double r657807 = -3.339667653993159e+287;
        bool r657808 = r657806 <= r657807;
        double r657809 = 4.681279714610345e+292;
        bool r657810 = r657806 <= r657809;
        double r657811 = !r657810;
        bool r657812 = r657808 || r657811;
        double r657813 = a;
        double r657814 = r657800 / r657813;
        double r657815 = r657814 * r657801;
        double r657816 = r657804 / r657813;
        double r657817 = r657816 * r657803;
        double r657818 = r657815 - r657817;
        double r657819 = r657806 / r657813;
        double r657820 = r657812 ? r657818 : r657819;
        return r657820;
}

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. Using strategy rm
    5. Applied *-un-lft-identity1.1

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(x \cdot y - z \cdot t\right)}}}\]
    6. Applied *-un-lft-identity1.1

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{x \cdot y - z \cdot t}}}\]
    8. Applied add-cube-cbrt1.1

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a}{x \cdot y - z \cdot t}}\]
    9. Applied times-frac1.1

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{a}{x \cdot y - z \cdot t}}}\]
    10. Simplified1.1

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

      \[\leadsto 1 \cdot \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))