Average Error: 4.8 → 0.3
Time: 8.5s
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 -2.2592621423955549 \cdot 10^{306}:\\ \;\;\;\;\frac{\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z}}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.7536441784100923 \cdot 10^{-305}:\\ \;\;\;\;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:\\ \;\;\;\;\frac{x}{z} \cdot \frac{y \cdot \left(1 - z\right) - z \cdot t}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 3.1420396255810733 \cdot 10^{257}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z}}{1 - z}\\ \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 -2.2592621423955549 \cdot 10^{306}:\\
\;\;\;\;\frac{\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z}}{1 - z}\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.7536441784100923 \cdot 10^{-305}:\\
\;\;\;\;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:\\
\;\;\;\;\frac{x}{z} \cdot \frac{y \cdot \left(1 - z\right) - z \cdot t}{1 - z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r444228 = x;
        double r444229 = y;
        double r444230 = z;
        double r444231 = r444229 / r444230;
        double r444232 = t;
        double r444233 = 1.0;
        double r444234 = r444233 - r444230;
        double r444235 = r444232 / r444234;
        double r444236 = r444231 - r444235;
        double r444237 = r444228 * r444236;
        return r444237;
}

double f(double x, double y, double z, double t) {
        double r444238 = y;
        double r444239 = z;
        double r444240 = r444238 / r444239;
        double r444241 = t;
        double r444242 = 1.0;
        double r444243 = r444242 - r444239;
        double r444244 = r444241 / r444243;
        double r444245 = r444240 - r444244;
        double r444246 = -2.259262142395555e+306;
        bool r444247 = r444245 <= r444246;
        double r444248 = x;
        double r444249 = r444238 * r444243;
        double r444250 = r444239 * r444241;
        double r444251 = r444249 - r444250;
        double r444252 = r444248 * r444251;
        double r444253 = r444252 / r444239;
        double r444254 = r444253 / r444243;
        double r444255 = -4.753644178410092e-305;
        bool r444256 = r444245 <= r444255;
        double r444257 = 1.0;
        double r444258 = r444257 / r444243;
        double r444259 = r444241 * r444258;
        double r444260 = r444240 - r444259;
        double r444261 = r444248 * r444260;
        double r444262 = -0.0;
        bool r444263 = r444245 <= r444262;
        double r444264 = r444248 / r444239;
        double r444265 = r444251 / r444243;
        double r444266 = r444264 * r444265;
        double r444267 = 3.142039625581073e+257;
        bool r444268 = r444245 <= r444267;
        double r444269 = r444268 ? r444261 : r444254;
        double r444270 = r444263 ? r444266 : r444269;
        double r444271 = r444256 ? r444261 : r444270;
        double r444272 = r444247 ? r444254 : r444271;
        return r444272;
}

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
Herbie0.3
\[\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))) < -2.259262142395555e+306 or 3.142039625581073e+257 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 45.2

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

      \[\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/1.2

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

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

    if -2.259262142395555e+306 < (- (/ y z) (/ t (- 1.0 z))) < -4.753644178410092e-305 or -0.0 < (- (/ y z) (/ t (- 1.0 z))) < 3.142039625581073e+257

    1. Initial program 0.3

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

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

    if -4.753644178410092e-305 < (- (/ y z) (/ t (- 1.0 z))) < -0.0

    1. Initial program 21.9

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

      \[\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/20.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -2.2592621423955549 \cdot 10^{306}:\\ \;\;\;\;\frac{\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z}}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.7536441784100923 \cdot 10^{-305}:\\ \;\;\;\;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:\\ \;\;\;\;\frac{x}{z} \cdot \frac{y \cdot \left(1 - z\right) - z \cdot t}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 3.1420396255810733 \cdot 10^{257}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z}}{1 - z}\\ \end{array}\]

Reproduce

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