Average Error: 4.8 → 1.3
Time: 5.3s
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) = -\infty \lor \neg \left(x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 1.7453403644604060351407056750121489822 \cdot 10^{308}\right):\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - 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) = -\infty \lor \neg \left(x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 1.7453403644604060351407056750121489822 \cdot 10^{308}\right):\\
\;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r436315 = x;
        double r436316 = y;
        double r436317 = z;
        double r436318 = r436316 / r436317;
        double r436319 = t;
        double r436320 = 1.0;
        double r436321 = r436320 - r436317;
        double r436322 = r436319 / r436321;
        double r436323 = r436318 - r436322;
        double r436324 = r436315 * r436323;
        return r436324;
}

double f(double x, double y, double z, double t) {
        double r436325 = x;
        double r436326 = y;
        double r436327 = z;
        double r436328 = r436326 / r436327;
        double r436329 = t;
        double r436330 = 1.0;
        double r436331 = r436330 - r436327;
        double r436332 = r436329 / r436331;
        double r436333 = r436328 - r436332;
        double r436334 = r436325 * r436333;
        double r436335 = -inf.0;
        bool r436336 = r436334 <= r436335;
        double r436337 = 1.745340364460406e+308;
        bool r436338 = r436334 <= r436337;
        double r436339 = !r436338;
        bool r436340 = r436336 || r436339;
        double r436341 = r436326 * r436331;
        double r436342 = r436327 * r436329;
        double r436343 = r436341 - r436342;
        double r436344 = r436325 * r436343;
        double r436345 = r436327 * r436331;
        double r436346 = r436344 / r436345;
        double r436347 = 1.0;
        double r436348 = r436347 / r436331;
        double r436349 = r436329 * r436348;
        double r436350 = r436328 - r436349;
        double r436351 = r436325 * r436350;
        double r436352 = r436340 ? r436346 : r436351;
        return r436352;
}

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.8
Target4.4
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 (* x (- (/ y z) (/ t (- 1.0 z)))) < -inf.0 or 1.745340364460406e+308 < (* x (- (/ y z) (/ t (- 1.0 z))))

    1. Initial program 64.0

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

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

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

    if -inf.0 < (* x (- (/ y z) (/ t (- 1.0 z)))) < 1.745340364460406e+308

    1. Initial program 1.3

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

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

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

Reproduce

herbie shell --seed 2020001 
(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.623226303312042e-196) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z)))))))

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