Average Error: 7.7 → 4.7
Time: 3.3s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.4943716958645776 \cdot 10^{135} \lor \neg \left(x \cdot y - z \cdot t \le 8.4070151176901548 \cdot 10^{254}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{1}{\frac{a}{t \cdot z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.4943716958645776 \cdot 10^{135} \lor \neg \left(x \cdot y - z \cdot t \le 8.4070151176901548 \cdot 10^{254}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r817979 = x;
        double r817980 = y;
        double r817981 = r817979 * r817980;
        double r817982 = z;
        double r817983 = t;
        double r817984 = r817982 * r817983;
        double r817985 = r817981 - r817984;
        double r817986 = a;
        double r817987 = r817985 / r817986;
        return r817987;
}

double f(double x, double y, double z, double t, double a) {
        double r817988 = x;
        double r817989 = y;
        double r817990 = r817988 * r817989;
        double r817991 = z;
        double r817992 = t;
        double r817993 = r817991 * r817992;
        double r817994 = r817990 - r817993;
        double r817995 = -1.4943716958645776e+135;
        bool r817996 = r817994 <= r817995;
        double r817997 = 8.407015117690155e+254;
        bool r817998 = r817994 <= r817997;
        double r817999 = !r817998;
        bool r818000 = r817996 || r817999;
        double r818001 = a;
        double r818002 = r818001 / r817989;
        double r818003 = r817988 / r818002;
        double r818004 = r817992 * r817991;
        double r818005 = r818004 / r818001;
        double r818006 = r818003 - r818005;
        double r818007 = r817990 / r818001;
        double r818008 = 1.0;
        double r818009 = r818001 / r818004;
        double r818010 = r818008 / r818009;
        double r818011 = r818007 - r818010;
        double r818012 = r818000 ? r818006 : r818011;
        return r818012;
}

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.7
Target6.2
Herbie4.7
\[\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 2 regimes
  2. if (- (* x y) (* z t)) < -1.4943716958645776e+135 or 8.407015117690155e+254 < (- (* x y) (* z t))

    1. Initial program 25.8

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied associate-/l*14.4

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

    if -1.4943716958645776e+135 < (- (* x y) (* z t)) < 8.407015117690155e+254

    1. Initial program 0.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.4943716958645776 \cdot 10^{135} \lor \neg \left(x \cdot y - z \cdot t \le 8.4070151176901548 \cdot 10^{254}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{1}{\frac{a}{t \cdot z}}\\ \end{array}\]

Reproduce

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