Average Error: 4.7 → 3.2
Time: 6.2s
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.0616893837286656 \cdot 10^{293}:\\ \;\;\;\;x \cdot \frac{y}{z} + x \cdot \frac{-t}{1 - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{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.0616893837286656 \cdot 10^{293}:\\
\;\;\;\;x \cdot \frac{y}{z} + x \cdot \frac{-t}{1 - z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r389261 = x;
        double r389262 = y;
        double r389263 = z;
        double r389264 = r389262 / r389263;
        double r389265 = t;
        double r389266 = 1.0;
        double r389267 = r389266 - r389263;
        double r389268 = r389265 / r389267;
        double r389269 = r389264 - r389268;
        double r389270 = r389261 * r389269;
        return r389270;
}

double f(double x, double y, double z, double t) {
        double r389271 = y;
        double r389272 = z;
        double r389273 = r389271 / r389272;
        double r389274 = t;
        double r389275 = 1.0;
        double r389276 = r389275 - r389272;
        double r389277 = r389274 / r389276;
        double r389278 = r389273 - r389277;
        double r389279 = 5.0616893837286656e+293;
        bool r389280 = r389278 <= r389279;
        double r389281 = x;
        double r389282 = r389281 * r389273;
        double r389283 = -r389274;
        double r389284 = r389283 / r389276;
        double r389285 = r389281 * r389284;
        double r389286 = r389282 + r389285;
        double r389287 = r389281 * r389271;
        double r389288 = r389287 / r389272;
        double r389289 = r389280 ? r389286 : r389288;
        return r389289;
}

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.2
Herbie3.2
\[\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))) < 5.0616893837286656e+293

    1. Initial program 3.1

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

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

      \[\leadsto x \cdot \left(\color{blue}{\left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right) \cdot \sqrt[3]{\frac{y}{z}}} - t \cdot \frac{1}{1 - z}\right)\]
    6. Applied fma-neg3.6

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}, \sqrt[3]{\frac{y}{z}}, -t \cdot \frac{1}{1 - z}\right)}\]
    7. Simplified3.6

      \[\leadsto x \cdot \mathsf{fma}\left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}, \sqrt[3]{\frac{y}{z}}, \color{blue}{\frac{-t}{1 - z}}\right)\]
    8. Using strategy rm
    9. Applied fma-udef3.6

      \[\leadsto x \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right) \cdot \sqrt[3]{\frac{y}{z}} + \frac{-t}{1 - z}\right)}\]
    10. Applied distribute-lft-in3.6

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

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

    if 5.0616893837286656e+293 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 51.1

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

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

      \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right) \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\]
    5. Applied prod-diff51.2

      \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(y, \frac{1}{z}, -\sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right)\right)}\]
    6. Simplified51.1

      \[\leadsto x \cdot \left(\color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right)} + \mathsf{fma}\left(-\sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right)\right)\]
    7. Simplified51.1

      \[\leadsto x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right) + \color{blue}{\frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)}\right)\]
    8. Taylor expanded around 0 4.7

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le 5.0616893837286656 \cdot 10^{293}:\\ \;\;\;\;x \cdot \frac{y}{z} + x \cdot \frac{-t}{1 - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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