Average Error: 4.4 → 1.2
Time: 25.9s
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{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 8.460748976825988 \cdot 10^{+248}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{1.0 - z} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot 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{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r20810152 = x;
        double r20810153 = y;
        double r20810154 = z;
        double r20810155 = r20810153 / r20810154;
        double r20810156 = t;
        double r20810157 = 1.0;
        double r20810158 = r20810157 - r20810154;
        double r20810159 = r20810156 / r20810158;
        double r20810160 = r20810155 - r20810159;
        double r20810161 = r20810152 * r20810160;
        return r20810161;
}

double f(double x, double y, double z, double t) {
        double r20810162 = y;
        double r20810163 = z;
        double r20810164 = r20810162 / r20810163;
        double r20810165 = t;
        double r20810166 = 1.0;
        double r20810167 = r20810166 - r20810163;
        double r20810168 = r20810165 / r20810167;
        double r20810169 = r20810164 - r20810168;
        double r20810170 = -inf.0;
        bool r20810171 = r20810169 <= r20810170;
        double r20810172 = x;
        double r20810173 = r20810167 * r20810162;
        double r20810174 = r20810165 * r20810163;
        double r20810175 = r20810173 - r20810174;
        double r20810176 = r20810172 * r20810175;
        double r20810177 = r20810167 * r20810163;
        double r20810178 = r20810176 / r20810177;
        double r20810179 = 8.460748976825988e+248;
        bool r20810180 = r20810169 <= r20810179;
        double r20810181 = 1.0;
        double r20810182 = r20810181 / r20810167;
        double r20810183 = r20810182 * r20810165;
        double r20810184 = r20810164 - r20810183;
        double r20810185 = r20810172 * r20810184;
        double r20810186 = r20810180 ? r20810185 : r20810178;
        double r20810187 = r20810171 ? r20810178 : r20810186;
        return r20810187;
}

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 8.460748976825988e+248 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 39.4

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

      \[\leadsto x \cdot \color{blue}{\frac{y \cdot \left(1.0 - z\right) - z \cdot t}{z \cdot \left(1.0 - z\right)}}\]
    4. Applied associate-*r/1.2

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

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < 8.460748976825988e+248

    1. Initial program 1.2

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{t \cdot \frac{1}{1.0 - z}}\right)\]
  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{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 8.460748976825988 \cdot 10^{+248}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{1.0 - z} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot 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)))))