Average Error: 4.8 → 3.2
Time: 8.8s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.1148798322517719 \cdot 10^{21}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{elif}\;z \le 6.52761212898463406 \cdot 10^{48}:\\ \;\;\;\;\frac{x \cdot y}{z} + \frac{\left(-t\right) \cdot x}{1 - z}\\ \mathbf{elif}\;z \le 1.05604830505701976 \cdot 10^{277}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-t\right) \cdot \frac{x}{1 - z}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;z \le -1.1148798322517719 \cdot 10^{21}:\\
\;\;\;\;\frac{x}{\frac{z}{y}} + \left(-\frac{t}{1 - z}\right) \cdot x\\

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r477860 = x;
        double r477861 = y;
        double r477862 = z;
        double r477863 = r477861 / r477862;
        double r477864 = t;
        double r477865 = 1.0;
        double r477866 = r477865 - r477862;
        double r477867 = r477864 / r477866;
        double r477868 = r477863 - r477867;
        double r477869 = r477860 * r477868;
        return r477869;
}

double f(double x, double y, double z, double t) {
        double r477870 = z;
        double r477871 = -1.1148798322517719e+21;
        bool r477872 = r477870 <= r477871;
        double r477873 = x;
        double r477874 = y;
        double r477875 = r477870 / r477874;
        double r477876 = r477873 / r477875;
        double r477877 = t;
        double r477878 = 1.0;
        double r477879 = r477878 - r477870;
        double r477880 = r477877 / r477879;
        double r477881 = -r477880;
        double r477882 = r477881 * r477873;
        double r477883 = r477876 + r477882;
        double r477884 = 6.527612128984634e+48;
        bool r477885 = r477870 <= r477884;
        double r477886 = r477873 * r477874;
        double r477887 = r477886 / r477870;
        double r477888 = -r477877;
        double r477889 = r477888 * r477873;
        double r477890 = r477889 / r477879;
        double r477891 = r477887 + r477890;
        double r477892 = 1.0560483050570198e+277;
        bool r477893 = r477870 <= r477892;
        double r477894 = r477873 / r477879;
        double r477895 = r477888 * r477894;
        double r477896 = r477887 + r477895;
        double r477897 = r477893 ? r477883 : r477896;
        double r477898 = r477885 ? r477891 : r477897;
        double r477899 = r477872 ? r477883 : r477898;
        return r477899;
}

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.3
Herbie3.2
\[\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 3 regimes
  2. if z < -1.1148798322517719e+21 or 6.527612128984634e+48 < z < 1.0560483050570198e+277

    1. Initial program 2.1

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \frac{z}{x \cdot y}}} + \left(-\frac{t}{1 - z}\right) \cdot x\]
    11. Applied add-cube-cbrt6.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{1 \cdot \frac{z}{x \cdot y}} + \left(-\frac{t}{1 - z}\right) \cdot x\]
    12. Applied times-frac6.6

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

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

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

    if -1.1148798322517719e+21 < z < 6.527612128984634e+48

    1. Initial program 7.7

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

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

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

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

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

      \[\leadsto \frac{x \cdot y}{z} + \color{blue}{\frac{-t}{1 - z}} \cdot x\]
    9. Applied associate-*l/3.4

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

    if 1.0560483050570198e+277 < z

    1. Initial program 3.0

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.1148798322517719 \cdot 10^{21}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{elif}\;z \le 6.52761212898463406 \cdot 10^{48}:\\ \;\;\;\;\frac{x \cdot y}{z} + \frac{\left(-t\right) \cdot x}{1 - z}\\ \mathbf{elif}\;z \le 1.05604830505701976 \cdot 10^{277}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-t\right) \cdot \frac{x}{1 - z}\\ \end{array}\]

Reproduce

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