Average Error: 7.7 → 0.8
Time: 14.8s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -4.907070607372141880864841580634098716505 \cdot 10^{217}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 3.609009921587506181399030317787405384418 \cdot 10^{247}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -4.907070607372141880864841580634098716505 \cdot 10^{217}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 3.609009921587506181399030317787405384418 \cdot 10^{247}:\\
\;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r37364146 = x;
        double r37364147 = y;
        double r37364148 = r37364146 * r37364147;
        double r37364149 = z;
        double r37364150 = t;
        double r37364151 = r37364149 * r37364150;
        double r37364152 = r37364148 - r37364151;
        double r37364153 = a;
        double r37364154 = r37364152 / r37364153;
        return r37364154;
}

double f(double x, double y, double z, double t, double a) {
        double r37364155 = x;
        double r37364156 = y;
        double r37364157 = r37364155 * r37364156;
        double r37364158 = z;
        double r37364159 = t;
        double r37364160 = r37364158 * r37364159;
        double r37364161 = r37364157 - r37364160;
        double r37364162 = -4.907070607372142e+217;
        bool r37364163 = r37364161 <= r37364162;
        double r37364164 = a;
        double r37364165 = r37364164 / r37364156;
        double r37364166 = r37364155 / r37364165;
        double r37364167 = r37364159 / r37364164;
        double r37364168 = r37364167 * r37364158;
        double r37364169 = r37364166 - r37364168;
        double r37364170 = 3.609009921587506e+247;
        bool r37364171 = r37364161 <= r37364170;
        double r37364172 = 1.0;
        double r37364173 = r37364172 / r37364164;
        double r37364174 = r37364173 * r37364161;
        double r37364175 = r37364171 ? r37364174 : r37364169;
        double r37364176 = r37364163 ? r37364169 : r37364175;
        return r37364176;
}

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
Herbie0.8
\[\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)) < -4.907070607372142e+217 or 3.609009921587506e+247 < (- (* x y) (* z t))

    1. Initial program 36.3

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

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

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

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

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

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

    if -4.907070607372142e+217 < (- (* x y) (* z t)) < 3.609009921587506e+247

    1. Initial program 0.7

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\left(z \cdot t\right) \cdot \frac{1}{a}}\]
    6. Applied div-inv0.8

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

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -4.907070607372141880864841580634098716505 \cdot 10^{217}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 3.609009921587506181399030317787405384418 \cdot 10^{247}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{a} \cdot z\\ \end{array}\]

Reproduce

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