Average Error: 4.8 → 0.3
Time: 16.2s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} = -\infty:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -9.919168302961412809853444956495048310677 \cdot 10^{-197}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 6.885649768433984338622139142821395249624 \cdot 10^{-312}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 7.856892780321220316695232968574835303737 \cdot 10^{298}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} = -\infty:\\
\;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\

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

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 6.885649768433984338622139142821395249624 \cdot 10^{-312}:\\
\;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r341896 = x;
        double r341897 = y;
        double r341898 = z;
        double r341899 = r341897 / r341898;
        double r341900 = t;
        double r341901 = 1.0;
        double r341902 = r341901 - r341898;
        double r341903 = r341900 / r341902;
        double r341904 = r341899 - r341903;
        double r341905 = r341896 * r341904;
        return r341905;
}

double f(double x, double y, double z, double t) {
        double r341906 = y;
        double r341907 = z;
        double r341908 = r341906 / r341907;
        double r341909 = t;
        double r341910 = 1.0;
        double r341911 = r341910 - r341907;
        double r341912 = r341909 / r341911;
        double r341913 = r341908 - r341912;
        double r341914 = -inf.0;
        bool r341915 = r341913 <= r341914;
        double r341916 = x;
        double r341917 = r341906 * r341911;
        double r341918 = r341907 * r341909;
        double r341919 = r341917 - r341918;
        double r341920 = r341916 * r341919;
        double r341921 = r341907 * r341911;
        double r341922 = r341920 / r341921;
        double r341923 = -9.919168302961413e-197;
        bool r341924 = r341913 <= r341923;
        double r341925 = 1.0;
        double r341926 = r341911 / r341909;
        double r341927 = r341925 / r341926;
        double r341928 = r341908 - r341927;
        double r341929 = r341916 * r341928;
        double r341930 = 6.885649768434e-312;
        bool r341931 = r341913 <= r341930;
        double r341932 = r341916 * r341906;
        double r341933 = r341932 / r341907;
        double r341934 = r341909 * r341916;
        double r341935 = 2.0;
        double r341936 = pow(r341907, r341935);
        double r341937 = r341934 / r341936;
        double r341938 = r341910 * r341937;
        double r341939 = r341934 / r341907;
        double r341940 = r341938 + r341939;
        double r341941 = r341933 + r341940;
        double r341942 = 7.85689278032122e+298;
        bool r341943 = r341913 <= r341942;
        double r341944 = r341943 ? r341929 : r341922;
        double r341945 = r341931 ? r341941 : r341944;
        double r341946 = r341924 ? r341929 : r341945;
        double r341947 = r341915 ? r341922 : r341946;
        return r341947;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.8
Target4.3
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt -7.623226303312042442144691872793570510727 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt 1.413394492770230216018398633584271456447 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -inf.0 or 7.85689278032122e+298 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 60.8

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied frac-sub60.8

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

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

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < -9.919168302961413e-197 or 6.885649768434e-312 < (- (/ y z) (/ t (- 1.0 z))) < 7.85689278032122e+298

    1. Initial program 0.2

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied clear-num0.3

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

    if -9.919168302961413e-197 < (- (/ y z) (/ t (- 1.0 z))) < 6.885649768434e-312

    1. Initial program 13.0

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Taylor expanded around inf 0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} = -\infty:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -9.919168302961412809853444956495048310677 \cdot 10^{-197}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 6.885649768433984338622139142821395249624 \cdot 10^{-312}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 7.856892780321220316695232968574835303737 \cdot 10^{298}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019305 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1 z)))) -7.62322630331204244e-196) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 1.41339449277023022e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z)))))))

  (* x (- (/ y z) (/ t (- 1 z)))))