Average Error: 4.4 → 1.2
Time: 38.2s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1.0 - z} = -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 1.4180564209083267 \cdot 10^{+296}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} - \frac{t}{1.0 - z} = -\infty:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 1.4180564209083267 \cdot 10^{+296}:\\
\;\;\;\;\left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r13529390 = x;
        double r13529391 = y;
        double r13529392 = z;
        double r13529393 = r13529391 / r13529392;
        double r13529394 = t;
        double r13529395 = 1.0;
        double r13529396 = r13529395 - r13529392;
        double r13529397 = r13529394 / r13529396;
        double r13529398 = r13529393 - r13529397;
        double r13529399 = r13529390 * r13529398;
        return r13529399;
}

double f(double x, double y, double z, double t) {
        double r13529400 = y;
        double r13529401 = z;
        double r13529402 = r13529400 / r13529401;
        double r13529403 = t;
        double r13529404 = 1.0;
        double r13529405 = r13529404 - r13529401;
        double r13529406 = r13529403 / r13529405;
        double r13529407 = r13529402 - r13529406;
        double r13529408 = -inf.0;
        bool r13529409 = r13529407 <= r13529408;
        double r13529410 = x;
        double r13529411 = r13529400 * r13529410;
        double r13529412 = r13529411 / r13529401;
        double r13529413 = 1.4180564209083267e+296;
        bool r13529414 = r13529407 <= r13529413;
        double r13529415 = r13529407 * r13529410;
        double r13529416 = r13529414 ? r13529415 : r13529412;
        double r13529417 = r13529409 ? r13529412 : r13529416;
        return r13529417;
}

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.4
Target4.3
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \lt -7.623226303312042 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1.0 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \lt 1.4133944927702302 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1.0 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1.0 - z}\right)\\ \end{array}\]

Derivation

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

    1. Initial program 55.6

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

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

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < 1.4180564209083267e+296

    1. Initial program 1.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1.0 - z} = -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 1.4180564209083267 \cdot 10^{+296}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(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 (- 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 (- 1.0 z)))))))

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