Average Error: 4.8 → 1.3
Time: 19.8s
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{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.986045605745200854539506088256694706869 \cdot 10^{273}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot 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{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r18193662 = x;
        double r18193663 = y;
        double r18193664 = z;
        double r18193665 = r18193663 / r18193664;
        double r18193666 = t;
        double r18193667 = 1.0;
        double r18193668 = r18193667 - r18193664;
        double r18193669 = r18193666 / r18193668;
        double r18193670 = r18193665 - r18193669;
        double r18193671 = r18193662 * r18193670;
        return r18193671;
}

double f(double x, double y, double z, double t) {
        double r18193672 = y;
        double r18193673 = z;
        double r18193674 = r18193672 / r18193673;
        double r18193675 = t;
        double r18193676 = 1.0;
        double r18193677 = r18193676 - r18193673;
        double r18193678 = r18193675 / r18193677;
        double r18193679 = r18193674 - r18193678;
        double r18193680 = -inf.0;
        bool r18193681 = r18193679 <= r18193680;
        double r18193682 = x;
        double r18193683 = r18193677 * r18193672;
        double r18193684 = r18193675 * r18193673;
        double r18193685 = r18193683 - r18193684;
        double r18193686 = r18193682 * r18193685;
        double r18193687 = r18193677 * r18193673;
        double r18193688 = r18193686 / r18193687;
        double r18193689 = 1.9860456057452009e+273;
        bool r18193690 = r18193679 <= r18193689;
        double r18193691 = r18193679 * r18193682;
        double r18193692 = r18193690 ? r18193691 : r18193688;
        double r18193693 = r18193681 ? r18193688 : r18193692;
        return r18193693;
}

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.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 1.9860456057452009e+273 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 49.4

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

      \[\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/1.1

      \[\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 < (- (/ y z) (/ t (- 1.0 z))) < 1.9860456057452009e+273

    1. Initial program 1.4

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
  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{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.986045605745200854539506088256694706869 \cdot 10^{273}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \end{array}\]

Reproduce

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