Average Error: 7.7 → 4.3
Time: 3.3s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.01414647933800124 \cdot 10^{166}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{\frac{t}{a}}{\frac{1}{z}}\\ \mathbf{elif}\;x \cdot y \le -3.21143 \cdot 10^{-322}:\\ \;\;\;\;\frac{x \cdot y}{a} - \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \frac{t}{\frac{a}{\sqrt[3]{z}}}\\ \mathbf{elif}\;x \cdot y \le 8.1013163874093183 \cdot 10^{-125}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 2.31552892253560307 \cdot 10^{114}:\\ \;\;\;\;\frac{x \cdot y}{a} + \left(-\frac{t}{\frac{a}{z}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{\frac{t}{a}}{\frac{1}{z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -1.01414647933800124 \cdot 10^{166}:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{\frac{t}{a}}{\frac{1}{z}}\\

\mathbf{elif}\;x \cdot y \le -3.21143 \cdot 10^{-322}:\\
\;\;\;\;\frac{x \cdot y}{a} - \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \frac{t}{\frac{a}{\sqrt[3]{z}}}\\

\mathbf{elif}\;x \cdot y \le 8.1013163874093183 \cdot 10^{-125}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\

\mathbf{elif}\;x \cdot y \le 2.31552892253560307 \cdot 10^{114}:\\
\;\;\;\;\frac{x \cdot y}{a} + \left(-\frac{t}{\frac{a}{z}}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r971888 = x;
        double r971889 = y;
        double r971890 = r971888 * r971889;
        double r971891 = z;
        double r971892 = t;
        double r971893 = r971891 * r971892;
        double r971894 = r971890 - r971893;
        double r971895 = a;
        double r971896 = r971894 / r971895;
        return r971896;
}

double f(double x, double y, double z, double t, double a) {
        double r971897 = x;
        double r971898 = y;
        double r971899 = r971897 * r971898;
        double r971900 = -1.0141464793380012e+166;
        bool r971901 = r971899 <= r971900;
        double r971902 = a;
        double r971903 = r971898 / r971902;
        double r971904 = r971897 * r971903;
        double r971905 = t;
        double r971906 = r971905 / r971902;
        double r971907 = 1.0;
        double r971908 = z;
        double r971909 = r971907 / r971908;
        double r971910 = r971906 / r971909;
        double r971911 = r971904 - r971910;
        double r971912 = -3.2114266979681e-322;
        bool r971913 = r971899 <= r971912;
        double r971914 = r971899 / r971902;
        double r971915 = cbrt(r971908);
        double r971916 = r971915 * r971915;
        double r971917 = r971902 / r971915;
        double r971918 = r971905 / r971917;
        double r971919 = r971916 * r971918;
        double r971920 = r971914 - r971919;
        double r971921 = 8.101316387409318e-125;
        bool r971922 = r971899 <= r971921;
        double r971923 = r971902 / r971898;
        double r971924 = r971897 / r971923;
        double r971925 = r971905 * r971908;
        double r971926 = r971925 / r971902;
        double r971927 = r971924 - r971926;
        double r971928 = 2.315528922535603e+114;
        bool r971929 = r971899 <= r971928;
        double r971930 = r971902 / r971908;
        double r971931 = r971905 / r971930;
        double r971932 = -r971931;
        double r971933 = r971914 + r971932;
        double r971934 = r971929 ? r971933 : r971911;
        double r971935 = r971922 ? r971927 : r971934;
        double r971936 = r971913 ? r971920 : r971935;
        double r971937 = r971901 ? r971911 : r971936;
        return r971937;
}

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.3
\[\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 4 regimes
  2. if (* x y) < -1.0141464793380012e+166 or 2.315528922535603e+114 < (* x y)

    1. Initial program 21.8

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

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \frac{t}{\color{blue}{a \cdot \frac{1}{z}}}\]
    9. Applied associate-/r*19.1

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{\frac{t}{a}}{\frac{1}{z}}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity19.1

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{\frac{t}{a}}{\frac{1}{z}}\]
    13. Simplified3.2

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

    if -1.0141464793380012e+166 < (* x y) < -3.2114266979681e-322

    1. Initial program 4.0

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t}{\frac{a}{z}}}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt5.6

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

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

      \[\leadsto \frac{x \cdot y}{a} - \frac{t}{\color{blue}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{a}{\sqrt[3]{z}}}}\]
    11. Applied *-un-lft-identity5.6

      \[\leadsto \frac{x \cdot y}{a} - \frac{\color{blue}{1 \cdot t}}{\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{a}{\sqrt[3]{z}}}\]
    12. Applied times-frac4.4

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

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

    if -3.2114266979681e-322 < (* x y) < 8.101316387409318e-125

    1. Initial program 4.7

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

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

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

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

    if 8.101316387409318e-125 < (* x y) < 2.315528922535603e+114

    1. Initial program 3.5

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t}{\frac{a}{z}}}\]
    7. Using strategy rm
    8. Applied sub-neg4.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.01414647933800124 \cdot 10^{166}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{\frac{t}{a}}{\frac{1}{z}}\\ \mathbf{elif}\;x \cdot y \le -3.21143 \cdot 10^{-322}:\\ \;\;\;\;\frac{x \cdot y}{a} - \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \frac{t}{\frac{a}{\sqrt[3]{z}}}\\ \mathbf{elif}\;x \cdot y \le 8.1013163874093183 \cdot 10^{-125}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \le 2.31552892253560307 \cdot 10^{114}:\\ \;\;\;\;\frac{x \cdot y}{a} + \left(-\frac{t}{\frac{a}{z}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{\frac{t}{a}}{\frac{1}{z}}\\ \end{array}\]

Reproduce

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