Average Error: 7.6 → 4.7
Time: 19.3s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -4.80424266986926131 \cdot 10^{306} \lor \neg \left(x \cdot y \le 3.18956358068375949 \cdot 10^{185}\right):\\ \;\;\;\;\left(-\frac{t \cdot z}{a}\right) + y \cdot \frac{x}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -4.80424266986926131 \cdot 10^{306} \lor \neg \left(x \cdot y \le 3.18956358068375949 \cdot 10^{185}\right):\\
\;\;\;\;\left(-\frac{t \cdot z}{a}\right) + y \cdot \frac{x}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r605104 = x;
        double r605105 = y;
        double r605106 = r605104 * r605105;
        double r605107 = z;
        double r605108 = t;
        double r605109 = r605107 * r605108;
        double r605110 = r605106 - r605109;
        double r605111 = a;
        double r605112 = r605110 / r605111;
        return r605112;
}

double f(double x, double y, double z, double t, double a) {
        double r605113 = x;
        double r605114 = y;
        double r605115 = r605113 * r605114;
        double r605116 = -4.804242669869261e+306;
        bool r605117 = r605115 <= r605116;
        double r605118 = 3.1895635806837595e+185;
        bool r605119 = r605115 <= r605118;
        double r605120 = !r605119;
        bool r605121 = r605117 || r605120;
        double r605122 = t;
        double r605123 = z;
        double r605124 = r605122 * r605123;
        double r605125 = a;
        double r605126 = r605124 / r605125;
        double r605127 = -r605126;
        double r605128 = r605113 / r605125;
        double r605129 = r605114 * r605128;
        double r605130 = r605127 + r605129;
        double r605131 = 1.0;
        double r605132 = r605123 * r605122;
        double r605133 = r605115 - r605132;
        double r605134 = r605125 / r605133;
        double r605135 = r605131 / r605134;
        double r605136 = r605121 ? r605130 : r605135;
        return r605136;
}

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
Target6.3
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) < -4.804242669869261e+306 or 3.1895635806837595e+185 < (* x y)

    1. Initial program 38.1

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

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

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

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

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

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

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\mathsf{fma}\left(-t, z, y \cdot x\right)}\]
    10. Using strategy rm
    11. Applied fma-udef38.2

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(\left(-t\right) \cdot z + y \cdot x\right)}\]
    12. Applied distribute-lft-in38.2

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(\left(-t\right) \cdot z\right) + \frac{1}{a} \cdot \left(y \cdot x\right)}\]
    13. Simplified38.2

      \[\leadsto \color{blue}{\left(-\frac{t \cdot z}{a}\right)} + \frac{1}{a} \cdot \left(y \cdot x\right)\]
    14. Simplified7.9

      \[\leadsto \left(-\frac{t \cdot z}{a}\right) + \color{blue}{y \cdot \frac{x}{a}}\]

    if -4.804242669869261e+306 < (* x y) < 3.1895635806837595e+185

    1. Initial program 4.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -4.80424266986926131 \cdot 10^{306} \lor \neg \left(x \cdot y \le 3.18956358068375949 \cdot 10^{185}\right):\\ \;\;\;\;\left(-\frac{t \cdot z}{a}\right) + y \cdot \frac{x}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019199 +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))