Average Error: 4.6 → 1.8
Time: 18.3s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) = -\infty:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 5.365114686245201147953029381740708786098 \cdot 10^{265}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) = -\infty:\\
\;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r22586315 = x;
        double r22586316 = y;
        double r22586317 = z;
        double r22586318 = r22586316 / r22586317;
        double r22586319 = t;
        double r22586320 = 1.0;
        double r22586321 = r22586320 - r22586317;
        double r22586322 = r22586319 / r22586321;
        double r22586323 = r22586318 - r22586322;
        double r22586324 = r22586315 * r22586323;
        return r22586324;
}

double f(double x, double y, double z, double t) {
        double r22586325 = x;
        double r22586326 = y;
        double r22586327 = z;
        double r22586328 = r22586326 / r22586327;
        double r22586329 = t;
        double r22586330 = 1.0;
        double r22586331 = r22586330 - r22586327;
        double r22586332 = r22586329 / r22586331;
        double r22586333 = r22586328 - r22586332;
        double r22586334 = r22586325 * r22586333;
        double r22586335 = -inf.0;
        bool r22586336 = r22586334 <= r22586335;
        double r22586337 = r22586331 * r22586326;
        double r22586338 = r22586329 * r22586327;
        double r22586339 = r22586337 - r22586338;
        double r22586340 = r22586325 * r22586339;
        double r22586341 = r22586331 * r22586327;
        double r22586342 = r22586340 / r22586341;
        double r22586343 = 5.365114686245201e+265;
        bool r22586344 = r22586334 <= r22586343;
        double r22586345 = r22586344 ? r22586334 : r22586342;
        double r22586346 = r22586336 ? r22586342 : r22586345;
        return r22586346;
}

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.6
Target4.2
Herbie1.8
\[\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 2 regimes
  2. if (* x (- (/ y z) (/ t (- 1.0 z)))) < -inf.0 or 5.365114686245201e+265 < (* x (- (/ y z) (/ t (- 1.0 z))))

    1. Initial program 43.1

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

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

      \[\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 < (* x (- (/ y z) (/ t (- 1.0 z)))) < 5.365114686245201e+265

    1. Initial program 1.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) = -\infty:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 5.365114686245201147953029381740708786098 \cdot 10^{265}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))

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