Average Error: 4.7 → 2.4
Time: 9.7s
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 -7.31267970557807446 \cdot 10^{-154} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 0.0 \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 6.8697710503443832 \cdot 10^{163}\right)\right):\\ \;\;\;\;\frac{1}{\frac{\frac{z}{y}}{x}} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} + \frac{\left(-t\right) \cdot x}{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 -7.31267970557807446 \cdot 10^{-154} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 0.0 \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 6.8697710503443832 \cdot 10^{163}\right)\right):\\
\;\;\;\;\frac{1}{\frac{\frac{z}{y}}{x}} + \left(-\frac{t}{1 - z}\right) \cdot x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r414118 = x;
        double r414119 = y;
        double r414120 = z;
        double r414121 = r414119 / r414120;
        double r414122 = t;
        double r414123 = 1.0;
        double r414124 = r414123 - r414120;
        double r414125 = r414122 / r414124;
        double r414126 = r414121 - r414125;
        double r414127 = r414118 * r414126;
        return r414127;
}

double f(double x, double y, double z, double t) {
        double r414128 = y;
        double r414129 = z;
        double r414130 = r414128 / r414129;
        double r414131 = t;
        double r414132 = 1.0;
        double r414133 = r414132 - r414129;
        double r414134 = r414131 / r414133;
        double r414135 = r414130 - r414134;
        double r414136 = -7.312679705578074e-154;
        bool r414137 = r414135 <= r414136;
        double r414138 = 0.0;
        bool r414139 = r414135 <= r414138;
        double r414140 = 6.869771050344383e+163;
        bool r414141 = r414135 <= r414140;
        double r414142 = !r414141;
        bool r414143 = r414139 || r414142;
        double r414144 = !r414143;
        bool r414145 = r414137 || r414144;
        double r414146 = 1.0;
        double r414147 = r414129 / r414128;
        double r414148 = x;
        double r414149 = r414147 / r414148;
        double r414150 = r414146 / r414149;
        double r414151 = -r414134;
        double r414152 = r414151 * r414148;
        double r414153 = r414150 + r414152;
        double r414154 = r414148 / r414129;
        double r414155 = r414128 * r414154;
        double r414156 = -r414131;
        double r414157 = r414156 * r414148;
        double r414158 = r414157 / r414133;
        double r414159 = r414155 + r414158;
        double r414160 = r414145 ? r414153 : r414159;
        return r414160;
}

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.3
Herbie2.4
\[\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 2 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -7.312679705578074e-154 or 0.0 < (- (/ y z) (/ t (- 1.0 z))) < 6.869771050344383e+163

    1. Initial program 2.5

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

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

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

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

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

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

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

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

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

    if -7.312679705578074e-154 < (- (/ y z) (/ t (- 1.0 z))) < 0.0 or 6.869771050344383e+163 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 12.0

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

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

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

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

      \[\leadsto y \cdot \frac{x}{z} + \color{blue}{\left(-\frac{t}{1 - z}\right) \cdot x}\]
    7. Using strategy rm
    8. Applied distribute-neg-frac3.4

      \[\leadsto y \cdot \frac{x}{z} + \color{blue}{\frac{-t}{1 - z}} \cdot x\]
    9. Applied associate-*l/2.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -7.31267970557807446 \cdot 10^{-154} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 0.0 \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 6.8697710503443832 \cdot 10^{163}\right)\right):\\ \;\;\;\;\frac{1}{\frac{\frac{z}{y}}{x}} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} + \frac{\left(-t\right) \cdot x}{1 - z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 +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.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)))))