Average Error: 4.5 → 0.5
Time: 16.4s
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} = -\infty:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -2.145223723342324046712267811210494216144 \cdot 10^{-232}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -0.0:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \left(\frac{1}{z} + 1\right) \cdot \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.051161075875252365315860485678053244137 \cdot 10^{156}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \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} = -\infty:\\
\;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r313034 = x;
        double r313035 = y;
        double r313036 = z;
        double r313037 = r313035 / r313036;
        double r313038 = t;
        double r313039 = 1.0;
        double r313040 = r313039 - r313036;
        double r313041 = r313038 / r313040;
        double r313042 = r313037 - r313041;
        double r313043 = r313034 * r313042;
        return r313043;
}

double f(double x, double y, double z, double t) {
        double r313044 = y;
        double r313045 = z;
        double r313046 = r313044 / r313045;
        double r313047 = t;
        double r313048 = 1.0;
        double r313049 = r313048 - r313045;
        double r313050 = r313047 / r313049;
        double r313051 = r313046 - r313050;
        double r313052 = -inf.0;
        bool r313053 = r313051 <= r313052;
        double r313054 = x;
        double r313055 = r313044 * r313049;
        double r313056 = r313045 * r313047;
        double r313057 = r313055 - r313056;
        double r313058 = r313054 * r313057;
        double r313059 = r313045 * r313049;
        double r313060 = r313058 / r313059;
        double r313061 = -2.145223723342324e-232;
        bool r313062 = r313051 <= r313061;
        double r313063 = 1.0;
        double r313064 = r313063 / r313049;
        double r313065 = r313047 * r313064;
        double r313066 = r313046 - r313065;
        double r313067 = r313054 * r313066;
        double r313068 = -0.0;
        bool r313069 = r313051 <= r313068;
        double r313070 = r313054 / r313045;
        double r313071 = r313048 / r313045;
        double r313072 = r313071 + r313063;
        double r313073 = r313047 * r313054;
        double r313074 = r313073 / r313045;
        double r313075 = r313072 * r313074;
        double r313076 = fma(r313070, r313044, r313075);
        double r313077 = 1.0511610758752524e+156;
        bool r313078 = r313051 <= r313077;
        double r313079 = r313054 * r313044;
        double r313080 = r313079 / r313045;
        double r313081 = -r313050;
        double r313082 = r313081 * r313054;
        double r313083 = r313080 + r313082;
        double r313084 = r313078 ? r313067 : r313083;
        double r313085 = r313069 ? r313076 : r313084;
        double r313086 = r313062 ? r313067 : r313085;
        double r313087 = r313053 ? r313060 : r313086;
        return r313087;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target4.2
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt -7.623226303312042442144691872793570510727 \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.413394492770230216018398633584271456447 \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 4 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto x \cdot \color{blue}{\frac{y \cdot \left(1 - z\right) - z \cdot t}{z \cdot \left(1 - z\right)}}\]
    4. Applied associate-*r/0.3

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

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < -2.145223723342324e-232 or -0.0 < (- (/ y z) (/ t (- 1.0 z))) < 1.0511610758752524e+156

    1. Initial program 1.2

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

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

    if -2.145223723342324e-232 < (- (/ y z) (/ t (- 1.0 z))) < -0.0

    1. Initial program 5.5

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

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

      \[\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.5

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

    if 1.0511610758752524e+156 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 13.2

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

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

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

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -t \cdot \frac{1}{1 - z}\right)}\]
    7. Simplified13.2

      \[\leadsto x \cdot \mathsf{fma}\left(y, \frac{1}{z}, \color{blue}{-\frac{t}{1 - z}}\right)\]
    8. Using strategy rm
    9. Applied fma-udef13.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} = -\infty:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -2.145223723342324046712267811210494216144 \cdot 10^{-232}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -0.0:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \left(\frac{1}{z} + 1\right) \cdot \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.051161075875252365315860485678053244137 \cdot 10^{156}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 +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.62322630331204244e-196) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 1.41339449277023022e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z)))))))

  (* x (- (/ y z) (/ t (- 1 z)))))