Average Error: 4.6 → 4.1
Time: 20.8s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -9.51321256569866472 \cdot 10^{57} \lor \neg \left(y \le 2.3394294986221365 \cdot 10^{37}\right):\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-t \cdot \frac{1}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;y \le -9.51321256569866472 \cdot 10^{57} \lor \neg \left(y \le 2.3394294986221365 \cdot 10^{37}\right):\\
\;\;\;\;y \cdot \frac{x}{z} + \left(-t \cdot \frac{1}{1 - z}\right) \cdot x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r559742 = x;
        double r559743 = y;
        double r559744 = z;
        double r559745 = r559743 / r559744;
        double r559746 = t;
        double r559747 = 1.0;
        double r559748 = r559747 - r559744;
        double r559749 = r559746 / r559748;
        double r559750 = r559745 - r559749;
        double r559751 = r559742 * r559750;
        return r559751;
}

double f(double x, double y, double z, double t) {
        double r559752 = y;
        double r559753 = -9.513212565698665e+57;
        bool r559754 = r559752 <= r559753;
        double r559755 = 2.3394294986221365e+37;
        bool r559756 = r559752 <= r559755;
        double r559757 = !r559756;
        bool r559758 = r559754 || r559757;
        double r559759 = x;
        double r559760 = z;
        double r559761 = r559759 / r559760;
        double r559762 = r559752 * r559761;
        double r559763 = t;
        double r559764 = 1.0;
        double r559765 = 1.0;
        double r559766 = r559765 - r559760;
        double r559767 = r559764 / r559766;
        double r559768 = r559763 * r559767;
        double r559769 = -r559768;
        double r559770 = r559769 * r559759;
        double r559771 = r559762 + r559770;
        double r559772 = r559752 / r559760;
        double r559773 = r559766 / r559763;
        double r559774 = r559764 / r559773;
        double r559775 = r559772 - r559774;
        double r559776 = r559759 * r559775;
        double r559777 = r559758 ? r559771 : r559776;
        return r559777;
}

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.1
Herbie4.1
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt -7.62322630331204244 \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.41339449277023022 \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 < -9.513212565698665e+57 or 2.3394294986221365e+37 < y

    1. Initial program 9.1

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

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

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

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

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

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

    if -9.513212565698665e+57 < y < 2.3394294986221365e+37

    1. Initial program 2.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -9.51321256569866472 \cdot 10^{57} \lor \neg \left(y \le 2.3394294986221365 \cdot 10^{37}\right):\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-t \cdot \frac{1}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(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)))))