Average Error: 7.9 → 1.0
Time: 48.8s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.7525031253365581 \cdot 10^{+190}:\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.9626375528019777 \cdot 10^{+168}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.7525031253365581 \cdot 10^{+190}:\\
\;\;\;\;\frac{x}{a} \cdot y - \frac{t}{\frac{a}{z}}\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 2.9626375528019777 \cdot 10^{+168}:\\
\;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r30282889 = x;
        double r30282890 = y;
        double r30282891 = r30282889 * r30282890;
        double r30282892 = z;
        double r30282893 = t;
        double r30282894 = r30282892 * r30282893;
        double r30282895 = r30282891 - r30282894;
        double r30282896 = a;
        double r30282897 = r30282895 / r30282896;
        return r30282897;
}

double f(double x, double y, double z, double t, double a) {
        double r30282898 = x;
        double r30282899 = y;
        double r30282900 = r30282898 * r30282899;
        double r30282901 = z;
        double r30282902 = t;
        double r30282903 = r30282901 * r30282902;
        double r30282904 = r30282900 - r30282903;
        double r30282905 = -1.7525031253365581e+190;
        bool r30282906 = r30282904 <= r30282905;
        double r30282907 = a;
        double r30282908 = r30282898 / r30282907;
        double r30282909 = r30282908 * r30282899;
        double r30282910 = r30282907 / r30282901;
        double r30282911 = r30282902 / r30282910;
        double r30282912 = r30282909 - r30282911;
        double r30282913 = 2.9626375528019777e+168;
        bool r30282914 = r30282904 <= r30282913;
        double r30282915 = r30282904 / r30282907;
        double r30282916 = r30282914 ? r30282915 : r30282912;
        double r30282917 = r30282906 ? r30282912 : r30282916;
        return r30282917;
}

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.9
Target6.2
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371 \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.7525031253365581e+190 or 2.9626375528019777e+168 < (- (* x y) (* z t))

    1. Initial program 26.0

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

      \[\leadsto \frac{x \cdot y - z \cdot t}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\]
    4. Applied associate-/r*26.6

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y - z \cdot t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}{\sqrt[3]{a}}}\]
    5. Using strategy rm
    6. Applied div-sub26.6

      \[\leadsto \frac{\color{blue}{\frac{x \cdot y}{\sqrt[3]{a} \cdot \sqrt[3]{a}} - \frac{z \cdot t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}}}{\sqrt[3]{a}}\]
    7. Applied div-sub26.6

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

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

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

    if -1.7525031253365581e+190 < (- (* x y) (* z t)) < 2.9626375528019777e+168

    1. Initial program 0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.7525031253365581 \cdot 10^{+190}:\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.9626375528019777 \cdot 10^{+168}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a} \cdot y - \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019165 +o rules:numerics
(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))