Average Error: 4.7 → 0.4
Time: 13.0s
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 -9.165678624045873 \cdot 10^{188}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.16417746735656389 \cdot 10^{-222}:\\ \;\;\;\;\frac{y}{z} \cdot x + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z} + \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 2.3008111811729553 \cdot 10^{222}:\\ \;\;\;\;\frac{y}{z} \cdot x + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \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 -9.165678624045873 \cdot 10^{188}:\\
\;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \frac{t}{1 - z}\right)\\

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

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 0.0:\\
\;\;\;\;\frac{x \cdot y}{z} + \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r385897 = x;
        double r385898 = y;
        double r385899 = z;
        double r385900 = r385898 / r385899;
        double r385901 = t;
        double r385902 = 1.0;
        double r385903 = r385902 - r385899;
        double r385904 = r385901 / r385903;
        double r385905 = r385900 - r385904;
        double r385906 = r385897 * r385905;
        return r385906;
}

double f(double x, double y, double z, double t) {
        double r385907 = y;
        double r385908 = z;
        double r385909 = r385907 / r385908;
        double r385910 = t;
        double r385911 = 1.0;
        double r385912 = r385911 - r385908;
        double r385913 = r385910 / r385912;
        double r385914 = r385909 - r385913;
        double r385915 = -9.165678624045873e+188;
        bool r385916 = r385914 <= r385915;
        double r385917 = x;
        double r385918 = r385917 / r385908;
        double r385919 = r385907 * r385918;
        double r385920 = r385917 * r385913;
        double r385921 = -r385920;
        double r385922 = r385919 + r385921;
        double r385923 = -4.164177467356564e-222;
        bool r385924 = r385914 <= r385923;
        double r385925 = r385909 * r385917;
        double r385926 = r385925 + r385921;
        double r385927 = 0.0;
        bool r385928 = r385914 <= r385927;
        double r385929 = r385917 * r385907;
        double r385930 = r385929 / r385908;
        double r385931 = r385910 * r385917;
        double r385932 = 2.0;
        double r385933 = pow(r385908, r385932);
        double r385934 = r385931 / r385933;
        double r385935 = r385931 / r385908;
        double r385936 = fma(r385911, r385934, r385935);
        double r385937 = r385930 + r385936;
        double r385938 = 2.3008111811729553e+222;
        bool r385939 = r385914 <= r385938;
        double r385940 = r385939 ? r385926 : r385922;
        double r385941 = r385928 ? r385937 : r385940;
        double r385942 = r385924 ? r385926 : r385941;
        double r385943 = r385916 ? r385922 : r385942;
        return r385943;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.7
Target4.3
Herbie0.4
\[\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 (- (/ y z) (/ t (- 1.0 z))) < -9.165678624045873e+188 or 2.3008111811729553e+222 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 20.2

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{1}{\frac{1 - z}{t}}}\right)\]
    4. Using strategy rm
    5. Applied sub-neg20.2

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

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

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

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

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

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

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

    if -9.165678624045873e+188 < (- (/ y z) (/ t (- 1.0 z))) < -4.164177467356564e-222 or 0.0 < (- (/ y z) (/ t (- 1.0 z))) < 2.3008111811729553e+222

    1. Initial program 0.3

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{1}{\frac{1 - z}{t}}}\right)\]
    4. Using strategy rm
    5. Applied sub-neg0.4

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

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

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

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

    if -4.164177467356564e-222 < (- (/ y z) (/ t (- 1.0 z))) < 0.0

    1. Initial program 12.6

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{1}{\frac{1 - z}{t}}}\right)\]
    4. Taylor expanded around inf 0.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -9.165678624045873 \cdot 10^{188}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.16417746735656389 \cdot 10^{-222}:\\ \;\;\;\;\frac{y}{z} \cdot x + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 0.0:\\ \;\;\;\;\frac{x \cdot y}{z} + \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 2.3008111811729553 \cdot 10^{222}:\\ \;\;\;\;\frac{y}{z} \cdot x + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \frac{t}{1 - z}\right)\\ \end{array}\]

Reproduce

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