Average Error: 4.6 → 1.3
Time: 20.4s
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{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 5.734750356785414350135318053971508775162 \cdot 10^{301}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\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} = -\infty:\\
\;\;\;\;\frac{y \cdot x}{z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r17222213 = x;
        double r17222214 = y;
        double r17222215 = z;
        double r17222216 = r17222214 / r17222215;
        double r17222217 = t;
        double r17222218 = 1.0;
        double r17222219 = r17222218 - r17222215;
        double r17222220 = r17222217 / r17222219;
        double r17222221 = r17222216 - r17222220;
        double r17222222 = r17222213 * r17222221;
        return r17222222;
}

double f(double x, double y, double z, double t) {
        double r17222223 = y;
        double r17222224 = z;
        double r17222225 = r17222223 / r17222224;
        double r17222226 = t;
        double r17222227 = 1.0;
        double r17222228 = r17222227 - r17222224;
        double r17222229 = r17222226 / r17222228;
        double r17222230 = r17222225 - r17222229;
        double r17222231 = -inf.0;
        bool r17222232 = r17222230 <= r17222231;
        double r17222233 = x;
        double r17222234 = r17222223 * r17222233;
        double r17222235 = r17222234 / r17222224;
        double r17222236 = 5.734750356785414e+301;
        bool r17222237 = r17222230 <= r17222236;
        double r17222238 = r17222230 * r17222233;
        double r17222239 = r17222237 ? r17222238 : r17222235;
        double r17222240 = r17222232 ? r17222235 : r17222239;
        return r17222240;
}

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.5
Herbie1.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 2 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -inf.0 or 5.734750356785414e+301 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 60.8

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

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

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < 5.734750356785414e+301

    1. Initial program 1.3

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

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

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

Reproduce

herbie shell --seed 2019192 +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.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)))))