Average Error: 4.6 → 0.5
Time: 38.5s
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} \le -4.160542626351909795163353104871194722583 \cdot 10^{218}:\\ \;\;\;\;\frac{x \cdot t}{\left(z + 1\right) \cdot \left(1 - z\right)} \cdot \left(-\left(z + 1\right)\right) + \frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.366221236771887487690780301547077348915 \cdot 10^{-172}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 8.675112053486182625656701995676329852873 \cdot 10^{-219}:\\ \;\;\;\;\frac{\left(-x\right) \cdot t}{1 - z} + \frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.409130514825537046443418609777720419861 \cdot 10^{217}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y + \left(-x\right) \cdot \frac{t}{1 - z}\\ \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} \le -4.160542626351909795163353104871194722583 \cdot 10^{218}:\\
\;\;\;\;\frac{x \cdot t}{\left(z + 1\right) \cdot \left(1 - z\right)} \cdot \left(-\left(z + 1\right)\right) + \frac{y \cdot x}{z}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r442097 = x;
        double r442098 = y;
        double r442099 = z;
        double r442100 = r442098 / r442099;
        double r442101 = t;
        double r442102 = 1.0;
        double r442103 = r442102 - r442099;
        double r442104 = r442101 / r442103;
        double r442105 = r442100 - r442104;
        double r442106 = r442097 * r442105;
        return r442106;
}

double f(double x, double y, double z, double t) {
        double r442107 = y;
        double r442108 = z;
        double r442109 = r442107 / r442108;
        double r442110 = t;
        double r442111 = 1.0;
        double r442112 = r442111 - r442108;
        double r442113 = r442110 / r442112;
        double r442114 = r442109 - r442113;
        double r442115 = -4.16054262635191e+218;
        bool r442116 = r442114 <= r442115;
        double r442117 = x;
        double r442118 = r442117 * r442110;
        double r442119 = r442108 + r442111;
        double r442120 = r442119 * r442112;
        double r442121 = r442118 / r442120;
        double r442122 = -r442119;
        double r442123 = r442121 * r442122;
        double r442124 = r442107 * r442117;
        double r442125 = r442124 / r442108;
        double r442126 = r442123 + r442125;
        double r442127 = -1.3662212367718875e-172;
        bool r442128 = r442114 <= r442127;
        double r442129 = 1.0;
        double r442130 = r442112 / r442110;
        double r442131 = r442129 / r442130;
        double r442132 = r442109 - r442131;
        double r442133 = r442132 * r442117;
        double r442134 = 8.675112053486183e-219;
        bool r442135 = r442114 <= r442134;
        double r442136 = -r442117;
        double r442137 = r442136 * r442110;
        double r442138 = r442137 / r442112;
        double r442139 = r442138 + r442125;
        double r442140 = 1.409130514825537e+217;
        bool r442141 = r442114 <= r442140;
        double r442142 = r442117 / r442108;
        double r442143 = r442142 * r442107;
        double r442144 = r442136 * r442113;
        double r442145 = r442143 + r442144;
        double r442146 = r442141 ? r442133 : r442145;
        double r442147 = r442135 ? r442139 : r442146;
        double r442148 = r442128 ? r442133 : r442147;
        double r442149 = r442116 ? r442126 : r442148;
        return r442149;
}

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.6
Target4.3
Herbie0.5
\[\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 4 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -4.16054262635191e+218

    1. Initial program 20.7

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-lft-in20.7

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\left(-x \cdot \frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied flip--0.4

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

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

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

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

    if -4.16054262635191e+218 < (- (/ y z) (/ t (- 1.0 z))) < -1.3662212367718875e-172 or 8.675112053486183e-219 < (- (/ y z) (/ t (- 1.0 z))) < 1.409130514825537e+217

    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 -1.3662212367718875e-172 < (- (/ y z) (/ t (- 1.0 z))) < 8.675112053486183e-219

    1. Initial program 8.0

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-lft-in8.0

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\left(-x \cdot \frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied pow14.4

      \[\leadsto \frac{y \cdot x}{z} + \left(-x \cdot \color{blue}{{\left(\frac{t}{1 - z}\right)}^{1}}\right)\]
    9. Applied pow14.4

      \[\leadsto \frac{y \cdot x}{z} + \left(-\color{blue}{{x}^{1}} \cdot {\left(\frac{t}{1 - z}\right)}^{1}\right)\]
    10. Applied pow-prod-down4.4

      \[\leadsto \frac{y \cdot x}{z} + \left(-\color{blue}{{\left(x \cdot \frac{t}{1 - z}\right)}^{1}}\right)\]
    11. Simplified1.4

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

    if 1.409130514825537e+217 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 23.6

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-lft-in23.6

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\left(-x \cdot \frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity0.7

      \[\leadsto \frac{y \cdot x}{\color{blue}{1 \cdot z}} + \left(-x \cdot \frac{t}{1 - z}\right)\]
    9. Applied times-frac0.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.160542626351909795163353104871194722583 \cdot 10^{218}:\\ \;\;\;\;\frac{x \cdot t}{\left(z + 1\right) \cdot \left(1 - z\right)} \cdot \left(-\left(z + 1\right)\right) + \frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.366221236771887487690780301547077348915 \cdot 10^{-172}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 8.675112053486182625656701995676329852873 \cdot 10^{-219}:\\ \;\;\;\;\frac{\left(-x\right) \cdot t}{1 - z} + \frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.409130514825537046443418609777720419861 \cdot 10^{217}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y + \left(-x\right) \cdot \frac{t}{1 - z}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))

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