Average Error: 4.7 → 2.5
Time: 10.4s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.37676244964921993 \cdot 10^{-15} \lor \neg \left(x \le 3.26227413877637986 \cdot 10^{49}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y}} + t \cdot \left(-\frac{x}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} - \frac{t}{1 - z} \cdot x\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;x \le -2.37676244964921993 \cdot 10^{-15} \lor \neg \left(x \le 3.26227413877637986 \cdot 10^{49}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}} + t \cdot \left(-\frac{x}{1 - z}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r588637 = x;
        double r588638 = y;
        double r588639 = z;
        double r588640 = r588638 / r588639;
        double r588641 = t;
        double r588642 = 1.0;
        double r588643 = r588642 - r588639;
        double r588644 = r588641 / r588643;
        double r588645 = r588640 - r588644;
        double r588646 = r588637 * r588645;
        return r588646;
}

double f(double x, double y, double z, double t) {
        double r588647 = x;
        double r588648 = -2.37676244964922e-15;
        bool r588649 = r588647 <= r588648;
        double r588650 = 3.26227413877638e+49;
        bool r588651 = r588647 <= r588650;
        double r588652 = !r588651;
        bool r588653 = r588649 || r588652;
        double r588654 = z;
        double r588655 = y;
        double r588656 = r588654 / r588655;
        double r588657 = r588647 / r588656;
        double r588658 = t;
        double r588659 = 1.0;
        double r588660 = r588659 - r588654;
        double r588661 = r588647 / r588660;
        double r588662 = -r588661;
        double r588663 = r588658 * r588662;
        double r588664 = r588657 + r588663;
        double r588665 = r588647 * r588655;
        double r588666 = r588665 / r588654;
        double r588667 = r588658 / r588660;
        double r588668 = r588667 * r588647;
        double r588669 = r588666 - r588668;
        double r588670 = r588653 ? r588664 : r588669;
        return r588670;
}

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
Herbie2.5
\[\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 x < -2.37676244964922e-15 or 3.26227413877638e+49 < x

    1. Initial program 3.2

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

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

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

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

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

      \[\leadsto \frac{x}{\frac{z}{y}} + \left(-\color{blue}{t \cdot \frac{1}{1 - z}}\right) \cdot x\]
    9. Applied distribute-rgt-neg-in3.6

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

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

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

    if -2.37676244964922e-15 < x < 3.26227413877638e+49

    1. Initial program 5.6

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

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

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

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

      \[\leadsto \frac{x}{\frac{z}{y}} + \color{blue}{\left(-\frac{t}{1 - z}\right) \cdot x}\]
    7. Taylor expanded around 0 2.7

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

      \[\leadsto \frac{x \cdot y}{z} + \color{blue}{\left(-\frac{t}{1 - z} \cdot x\right)}\]
    10. Applied unsub-neg2.7

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t}{1 - z} \cdot x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.5

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

Reproduce

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