Average Error: 4.8 → 1.3
Time: 35.3s
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 -5.549198048342467961244486182463390374197 \cdot 10^{282}:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 2.36613445893600109511169929597533305758 \cdot 10^{272}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{1 - z} \cdot t\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}\;\frac{y}{z} - \frac{t}{1 - z} \le -5.549198048342467961244486182463390374197 \cdot 10^{282}:\\
\;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 2.36613445893600109511169929597533305758 \cdot 10^{272}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{1 - z} \cdot t\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 r21496448 = x;
        double r21496449 = y;
        double r21496450 = z;
        double r21496451 = r21496449 / r21496450;
        double r21496452 = t;
        double r21496453 = 1.0;
        double r21496454 = r21496453 - r21496450;
        double r21496455 = r21496452 / r21496454;
        double r21496456 = r21496451 - r21496455;
        double r21496457 = r21496448 * r21496456;
        return r21496457;
}

double f(double x, double y, double z, double t) {
        double r21496458 = y;
        double r21496459 = z;
        double r21496460 = r21496458 / r21496459;
        double r21496461 = t;
        double r21496462 = 1.0;
        double r21496463 = r21496462 - r21496459;
        double r21496464 = r21496461 / r21496463;
        double r21496465 = r21496460 - r21496464;
        double r21496466 = -5.549198048342468e+282;
        bool r21496467 = r21496465 <= r21496466;
        double r21496468 = x;
        double r21496469 = r21496463 * r21496458;
        double r21496470 = r21496461 * r21496459;
        double r21496471 = r21496469 - r21496470;
        double r21496472 = r21496468 * r21496471;
        double r21496473 = r21496463 * r21496459;
        double r21496474 = r21496472 / r21496473;
        double r21496475 = 2.366134458936001e+272;
        bool r21496476 = r21496465 <= r21496475;
        double r21496477 = 1.0;
        double r21496478 = r21496477 / r21496463;
        double r21496479 = r21496478 * r21496461;
        double r21496480 = r21496460 - r21496479;
        double r21496481 = r21496468 * r21496480;
        double r21496482 = r21496476 ? r21496481 : r21496474;
        double r21496483 = r21496467 ? r21496474 : r21496482;
        return r21496483;
}

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.4
Herbie1.3
\[\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 (- (/ y z) (/ t (- 1.0 z))) < -5.549198048342468e+282 or 2.366134458936001e+272 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 42.7

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied frac-sub43.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/0.8

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

    if -5.549198048342468e+282 < (- (/ y z) (/ t (- 1.0 z))) < 2.366134458936001e+272

    1. Initial program 1.3

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

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

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

      \[\leadsto \left(\frac{y}{z} - \frac{1}{\color{blue}{\left(1 - z\right) \cdot \frac{1}{t}}}\right) \cdot x\]
    8. Applied add-cube-cbrt1.5

      \[\leadsto \left(\frac{y}{z} - \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(1 - z\right) \cdot \frac{1}{t}}\right) \cdot x\]
    9. Applied times-frac1.4

      \[\leadsto \left(\frac{y}{z} - \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1 - z} \cdot \frac{\sqrt[3]{1}}{\frac{1}{t}}}\right) \cdot x\]
    10. Simplified1.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -5.549198048342467961244486182463390374197 \cdot 10^{282}:\\ \;\;\;\;\frac{x \cdot \left(\left(1 - z\right) \cdot y - t \cdot z\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 2.36613445893600109511169929597533305758 \cdot 10^{272}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{1 - z} \cdot t\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 2019168 
(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)))))