Average Error: 4.6 → 0.7
Time: 29.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} \le -4.160542626351909795163353104871194722583 \cdot 10^{218}:\\ \;\;\;\;\frac{y \cdot x}{z} + \frac{x}{\sqrt{1 - z}} \cdot \frac{-t}{\sqrt{1 - z}}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.366221236771887487690780301547077348915 \cdot 10^{-172}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 8.675112053486182625656701995676329852873 \cdot 10^{-219}:\\ \;\;\;\;\frac{x \cdot \left(-t\right)}{1 - z} + \frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.409130514825537046443418609777720419861 \cdot 10^{217}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y + \frac{-t}{1 - z} \cdot x\\ \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} \le -4.160542626351909795163353104871194722583 \cdot 10^{218}:\\
\;\;\;\;\frac{y \cdot x}{z} + \frac{x}{\sqrt{1 - z}} \cdot \frac{-t}{\sqrt{1 - z}}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y + \frac{-t}{1 - z} \cdot x\\

\end{array}
double f(double x, double y, double z, double t) {
        double r375637 = x;
        double r375638 = y;
        double r375639 = z;
        double r375640 = r375638 / r375639;
        double r375641 = t;
        double r375642 = 1.0;
        double r375643 = r375642 - r375639;
        double r375644 = r375641 / r375643;
        double r375645 = r375640 - r375644;
        double r375646 = r375637 * r375645;
        return r375646;
}

double f(double x, double y, double z, double t) {
        double r375647 = y;
        double r375648 = z;
        double r375649 = r375647 / r375648;
        double r375650 = t;
        double r375651 = 1.0;
        double r375652 = r375651 - r375648;
        double r375653 = r375650 / r375652;
        double r375654 = r375649 - r375653;
        double r375655 = -4.16054262635191e+218;
        bool r375656 = r375654 <= r375655;
        double r375657 = x;
        double r375658 = r375647 * r375657;
        double r375659 = r375658 / r375648;
        double r375660 = sqrt(r375652);
        double r375661 = r375657 / r375660;
        double r375662 = -r375650;
        double r375663 = r375662 / r375660;
        double r375664 = r375661 * r375663;
        double r375665 = r375659 + r375664;
        double r375666 = -1.3662212367718875e-172;
        bool r375667 = r375654 <= r375666;
        double r375668 = 1.0;
        double r375669 = r375652 / r375650;
        double r375670 = r375668 / r375669;
        double r375671 = r375649 - r375670;
        double r375672 = r375671 * r375657;
        double r375673 = 8.675112053486183e-219;
        bool r375674 = r375654 <= r375673;
        double r375675 = r375657 * r375662;
        double r375676 = r375675 / r375652;
        double r375677 = r375676 + r375659;
        double r375678 = 1.409130514825537e+217;
        bool r375679 = r375654 <= r375678;
        double r375680 = r375657 / r375648;
        double r375681 = r375680 * r375647;
        double r375682 = r375662 / r375652;
        double r375683 = r375682 * r375657;
        double r375684 = r375681 + r375683;
        double r375685 = r375679 ? r375672 : r375684;
        double r375686 = r375674 ? r375677 : r375685;
        double r375687 = r375667 ? r375672 : r375686;
        double r375688 = r375656 ? r375665 : r375687;
        return r375688;
}

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.3
Herbie0.7
\[\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 4 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -4.16054262635191e+218

    1. Initial program 20.7

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-lft-in20.7

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\left(-x \cdot \frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt3.9

      \[\leadsto \frac{y \cdot x}{z} + \left(-x \cdot \frac{t}{\color{blue}{\sqrt{1 - z} \cdot \sqrt{1 - z}}}\right)\]
    9. Applied *-un-lft-identity3.9

      \[\leadsto \frac{y \cdot x}{z} + \left(-x \cdot \frac{\color{blue}{1 \cdot t}}{\sqrt{1 - z} \cdot \sqrt{1 - z}}\right)\]
    10. Applied times-frac3.9

      \[\leadsto \frac{y \cdot x}{z} + \left(-x \cdot \color{blue}{\left(\frac{1}{\sqrt{1 - z}} \cdot \frac{t}{\sqrt{1 - z}}\right)}\right)\]
    11. Applied associate-*r*4.0

      \[\leadsto \frac{y \cdot x}{z} + \left(-\color{blue}{\left(x \cdot \frac{1}{\sqrt{1 - z}}\right) \cdot \frac{t}{\sqrt{1 - z}}}\right)\]
    12. Simplified4.0

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

    if -4.16054262635191e+218 < (- (/ y z) (/ t (- 1.0 z))) < -1.3662212367718875e-172 or 8.675112053486183e-219 < (- (/ y z) (/ t (- 1.0 z))) < 1.409130514825537e+217

    1. Initial program 0.2

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

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

    if -1.3662212367718875e-172 < (- (/ y z) (/ t (- 1.0 z))) < 8.675112053486183e-219

    1. Initial program 8.0

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-lft-in8.0

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\left(-x \cdot \frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity4.4

      \[\leadsto \frac{y \cdot x}{z} + \left(-\color{blue}{\left(1 \cdot x\right)} \cdot \frac{t}{1 - z}\right)\]
    9. Applied associate-*l*4.4

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

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

    if 1.409130514825537e+217 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 23.6

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-lft-in23.6

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\left(-x \cdot \frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity0.7

      \[\leadsto \frac{y \cdot x}{\color{blue}{1 \cdot z}} + \left(-x \cdot \frac{t}{1 - z}\right)\]
    9. Applied times-frac0.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.160542626351909795163353104871194722583 \cdot 10^{218}:\\ \;\;\;\;\frac{y \cdot x}{z} + \frac{x}{\sqrt{1 - z}} \cdot \frac{-t}{\sqrt{1 - z}}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.366221236771887487690780301547077348915 \cdot 10^{-172}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 8.675112053486182625656701995676329852873 \cdot 10^{-219}:\\ \;\;\;\;\frac{x \cdot \left(-t\right)}{1 - z} + \frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.409130514825537046443418609777720419861 \cdot 10^{217}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y + \frac{-t}{1 - z} \cdot x\\ \end{array}\]

Reproduce

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