Average Error: 4.7 → 1.6
Time: 8.6s
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 -8.7469245905233031 \cdot 10^{265} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.5905951762285947 \cdot 10^{176}\right):\\ \;\;\;\;\frac{x \cdot y}{z} + \frac{x \cdot \left(-t\right)}{1 - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} + x \cdot \left(-\frac{t}{1 - z}\right)\\ \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 -8.7469245905233031 \cdot 10^{265} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.5905951762285947 \cdot 10^{176}\right):\\
\;\;\;\;\frac{x \cdot y}{z} + \frac{x \cdot \left(-t\right)}{1 - z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r700627 = x;
        double r700628 = y;
        double r700629 = z;
        double r700630 = r700628 / r700629;
        double r700631 = t;
        double r700632 = 1.0;
        double r700633 = r700632 - r700629;
        double r700634 = r700631 / r700633;
        double r700635 = r700630 - r700634;
        double r700636 = r700627 * r700635;
        return r700636;
}

double f(double x, double y, double z, double t) {
        double r700637 = y;
        double r700638 = z;
        double r700639 = r700637 / r700638;
        double r700640 = t;
        double r700641 = 1.0;
        double r700642 = r700641 - r700638;
        double r700643 = r700640 / r700642;
        double r700644 = r700639 - r700643;
        double r700645 = -8.746924590523303e+265;
        bool r700646 = r700644 <= r700645;
        double r700647 = 2.5905951762285947e+176;
        bool r700648 = r700644 <= r700647;
        double r700649 = !r700648;
        bool r700650 = r700646 || r700649;
        double r700651 = x;
        double r700652 = r700651 * r700637;
        double r700653 = r700652 / r700638;
        double r700654 = -r700640;
        double r700655 = r700651 * r700654;
        double r700656 = r700655 / r700642;
        double r700657 = r700653 + r700656;
        double r700658 = r700638 / r700637;
        double r700659 = r700651 / r700658;
        double r700660 = -r700643;
        double r700661 = r700651 * r700660;
        double r700662 = r700659 + r700661;
        double r700663 = r700650 ? r700657 : r700662;
        return r700663;
}

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.7
Target4.3
Herbie1.6
\[\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 z) (/ t (- 1.0 z))) < -8.746924590523303e+265 or 2.5905951762285947e+176 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 22.8

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    6. Using strategy rm
    7. Applied distribute-neg-frac0.9

      \[\leadsto \frac{x \cdot y}{z} + x \cdot \color{blue}{\frac{-t}{1 - z}}\]
    8. Applied associate-*r/1.4

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

    if -8.746924590523303e+265 < (- (/ y z) (/ t (- 1.0 z))) < 2.5905951762285947e+176

    1. Initial program 1.5

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    6. Using strategy rm
    7. Applied associate-/l*1.6

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

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

Reproduce

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