Average Error: 4.5 → 2.6
Time: 14.9s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le -2.523584725210957964757168770581199359887 \cdot 10^{305}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le -2.06002969207582852285665827584193301962 \cdot 10^{-210} \lor \neg \left(x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 4.70215779512531126576872654913714406239 \cdot 10^{-285}\right):\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le -2.523584725210957964757168770581199359887 \cdot 10^{305}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le -2.06002969207582852285665827584193301962 \cdot 10^{-210} \lor \neg \left(x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 4.70215779512531126576872654913714406239 \cdot 10^{-285}\right):\\
\;\;\;\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r321328 = x;
        double r321329 = y;
        double r321330 = z;
        double r321331 = r321329 / r321330;
        double r321332 = t;
        double r321333 = 1.0;
        double r321334 = r321333 - r321330;
        double r321335 = r321332 / r321334;
        double r321336 = r321331 - r321335;
        double r321337 = r321328 * r321336;
        return r321337;
}

double f(double x, double y, double z, double t) {
        double r321338 = x;
        double r321339 = y;
        double r321340 = z;
        double r321341 = r321339 / r321340;
        double r321342 = t;
        double r321343 = 1.0;
        double r321344 = r321343 - r321340;
        double r321345 = r321342 / r321344;
        double r321346 = r321341 - r321345;
        double r321347 = r321338 * r321346;
        double r321348 = -2.523584725210958e+305;
        bool r321349 = r321347 <= r321348;
        double r321350 = r321338 * r321339;
        double r321351 = r321350 / r321340;
        double r321352 = -2.0600296920758285e-210;
        bool r321353 = r321347 <= r321352;
        double r321354 = 4.702157795125311e-285;
        bool r321355 = r321347 <= r321354;
        double r321356 = !r321355;
        bool r321357 = r321353 || r321356;
        double r321358 = r321342 * r321338;
        double r321359 = 2.0;
        double r321360 = pow(r321340, r321359);
        double r321361 = r321358 / r321360;
        double r321362 = r321343 * r321361;
        double r321363 = r321358 / r321340;
        double r321364 = r321362 + r321363;
        double r321365 = r321351 + r321364;
        double r321366 = r321357 ? r321347 : r321365;
        double r321367 = r321349 ? r321351 : r321366;
        return r321367;
}

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.0
Herbie2.6
\[\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 (* x (- (/ y z) (/ t (- 1.0 z)))) < -2.523584725210958e+305

    1. Initial program 58.8

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

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

    if -2.523584725210958e+305 < (* x (- (/ y z) (/ t (- 1.0 z)))) < -2.0600296920758285e-210 or 4.702157795125311e-285 < (* x (- (/ y z) (/ t (- 1.0 z))))

    1. Initial program 2.3

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

    if -2.0600296920758285e-210 < (* x (- (/ y z) (/ t (- 1.0 z)))) < 4.702157795125311e-285

    1. Initial program 6.2

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

      \[\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 simplification2.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le -2.523584725210957964757168770581199359887 \cdot 10^{305}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le -2.06002969207582852285665827584193301962 \cdot 10^{-210} \lor \neg \left(x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 4.70215779512531126576872654913714406239 \cdot 10^{-285}\right):\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\ \end{array}\]

Reproduce

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