Average Error: 4.7 → 2.2
Time: 16.4s
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(y \cdot \left(1 - z\right) - t \cdot z\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \le 1.593236886321844752796035591518825767997 \cdot 10^{249}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{1 - z} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - t \cdot z\right)}{z \cdot \left(1 - z\right)}\\ \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(y \cdot \left(1 - z\right) - t \cdot z\right)}{z \cdot \left(1 - z\right)}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r24217047 = x;
        double r24217048 = y;
        double r24217049 = z;
        double r24217050 = r24217048 / r24217049;
        double r24217051 = t;
        double r24217052 = 1.0;
        double r24217053 = r24217052 - r24217049;
        double r24217054 = r24217051 / r24217053;
        double r24217055 = r24217050 - r24217054;
        double r24217056 = r24217047 * r24217055;
        return r24217056;
}

double f(double x, double y, double z, double t) {
        double r24217057 = x;
        double r24217058 = y;
        double r24217059 = z;
        double r24217060 = r24217058 / r24217059;
        double r24217061 = t;
        double r24217062 = 1.0;
        double r24217063 = r24217062 - r24217059;
        double r24217064 = r24217061 / r24217063;
        double r24217065 = r24217060 - r24217064;
        double r24217066 = r24217057 * r24217065;
        double r24217067 = -inf.0;
        bool r24217068 = r24217066 <= r24217067;
        double r24217069 = r24217058 * r24217063;
        double r24217070 = r24217061 * r24217059;
        double r24217071 = r24217069 - r24217070;
        double r24217072 = r24217057 * r24217071;
        double r24217073 = r24217059 * r24217063;
        double r24217074 = r24217072 / r24217073;
        double r24217075 = 1.5932368863218448e+249;
        bool r24217076 = r24217066 <= r24217075;
        double r24217077 = 1.0;
        double r24217078 = r24217077 / r24217063;
        double r24217079 = r24217078 * r24217061;
        double r24217080 = r24217060 - r24217079;
        double r24217081 = r24217057 * r24217080;
        double r24217082 = r24217076 ? r24217081 : r24217074;
        double r24217083 = r24217068 ? r24217074 : r24217082;
        return r24217083;
}

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.7
Target4.4
Herbie2.2
\[\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 1.5932368863218448e+249 < (* x (- (/ y z) (/ t (- 1.0 z))))

    1. Initial program 38.1

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

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

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

      \[\leadsto x \cdot \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)\]
    8. Applied times-frac38.1

      \[\leadsto x \cdot \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)\]
    9. Simplified38.1

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \frac{1}{1 - z} \cdot \color{blue}{t}\right)\]
    11. Using strategy rm
    12. Applied associate-*l/38.1

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

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

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

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

    if -inf.0 < (* x (- (/ y z) (/ t (- 1.0 z)))) < 1.5932368863218448e+249

    1. Initial program 1.3

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

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

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

      \[\leadsto x \cdot \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)\]
    8. Applied times-frac1.4

      \[\leadsto x \cdot \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)\]
    9. Simplified1.4

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

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

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

Reproduce

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