Average Error: 4.5 → 1.4
Time: 15.0s
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 -1.548240730790440881436662006949490760264 \cdot 10^{219}:\\ \;\;\;\;\frac{x \cdot \left(-t\right)}{1 - z} + \frac{x}{z} \cdot y\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 4.862861552770296825237343335186305099433 \cdot 10^{206}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 - z} \cdot \left(-t\right) + \frac{y \cdot x}{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 -1.548240730790440881436662006949490760264 \cdot 10^{219}:\\
\;\;\;\;\frac{x \cdot \left(-t\right)}{1 - z} + \frac{x}{z} \cdot y\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r339029 = x;
        double r339030 = y;
        double r339031 = z;
        double r339032 = r339030 / r339031;
        double r339033 = t;
        double r339034 = 1.0;
        double r339035 = r339034 - r339031;
        double r339036 = r339033 / r339035;
        double r339037 = r339032 - r339036;
        double r339038 = r339029 * r339037;
        return r339038;
}

double f(double x, double y, double z, double t) {
        double r339039 = y;
        double r339040 = z;
        double r339041 = r339039 / r339040;
        double r339042 = t;
        double r339043 = 1.0;
        double r339044 = r339043 - r339040;
        double r339045 = r339042 / r339044;
        double r339046 = r339041 - r339045;
        double r339047 = -1.548240730790441e+219;
        bool r339048 = r339046 <= r339047;
        double r339049 = x;
        double r339050 = -r339042;
        double r339051 = r339049 * r339050;
        double r339052 = r339051 / r339044;
        double r339053 = r339049 / r339040;
        double r339054 = r339053 * r339039;
        double r339055 = r339052 + r339054;
        double r339056 = 4.862861552770297e+206;
        bool r339057 = r339046 <= r339056;
        double r339058 = r339046 * r339049;
        double r339059 = r339049 / r339044;
        double r339060 = r339059 * r339050;
        double r339061 = r339039 * r339049;
        double r339062 = r339061 / r339040;
        double r339063 = r339060 + r339062;
        double r339064 = r339057 ? r339058 : r339063;
        double r339065 = r339048 ? r339055 : r339064;
        return r339065;
}

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.5
Target4.2
Herbie1.4
\[\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))) < -1.548240730790441e+219

    1. Initial program 22.2

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

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

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

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

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

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

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

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

    if -1.548240730790441e+219 < (- (/ y z) (/ t (- 1.0 z))) < 4.862861552770297e+206

    1. Initial program 1.5

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

    if 4.862861552770297e+206 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 19.0

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

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

      \[\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. Simplified1.2

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\frac{x}{\frac{1 - z}{-t}}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity0.8

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{1 \cdot \frac{x}{\frac{1 - z}{-t}}}\]
    11. Applied *-un-lft-identity0.8

      \[\leadsto \color{blue}{1 \cdot \frac{y \cdot x}{z}} + 1 \cdot \frac{x}{\frac{1 - z}{-t}}\]
    12. Applied distribute-lft-out0.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.548240730790440881436662006949490760264 \cdot 10^{219}:\\ \;\;\;\;\frac{x \cdot \left(-t\right)}{1 - z} + \frac{x}{z} \cdot y\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 4.862861552770296825237343335186305099433 \cdot 10^{206}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 - z} \cdot \left(-t\right) + \frac{y \cdot x}{z}\\ \end{array}\]

Reproduce

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