Average Error: 4.4 → 2.7
Time: 13.6s
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} = -\infty:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - 1 \cdot \frac{1}{\frac{1 - z}{t}}\right)\\ \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} = -\infty:\\
\;\;\;\;\frac{x \cdot y}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r402439 = x;
        double r402440 = y;
        double r402441 = z;
        double r402442 = r402440 / r402441;
        double r402443 = t;
        double r402444 = 1.0;
        double r402445 = r402444 - r402441;
        double r402446 = r402443 / r402445;
        double r402447 = r402442 - r402446;
        double r402448 = r402439 * r402447;
        return r402448;
}

double f(double x, double y, double z, double t) {
        double r402449 = y;
        double r402450 = z;
        double r402451 = r402449 / r402450;
        double r402452 = t;
        double r402453 = 1.0;
        double r402454 = r402453 - r402450;
        double r402455 = r402452 / r402454;
        double r402456 = r402451 - r402455;
        double r402457 = -inf.0;
        bool r402458 = r402456 <= r402457;
        double r402459 = x;
        double r402460 = r402459 * r402449;
        double r402461 = r402460 / r402450;
        double r402462 = 1.0;
        double r402463 = r402454 / r402452;
        double r402464 = r402462 / r402463;
        double r402465 = r402462 * r402464;
        double r402466 = r402451 - r402465;
        double r402467 = r402459 * r402466;
        double r402468 = r402458 ? r402461 : r402467;
        return r402468;
}

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.4
Target4.0
Herbie2.7
\[\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))) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    4. Applied associate-*l*64.0

      \[\leadsto \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\right)}\]
    5. Taylor expanded around 0 0.2

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 2.7

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \frac{t}{\color{blue}{1 \cdot \left(1 - z\right)}}\right)\]
    4. Applied *-un-lft-identity2.7

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

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

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

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

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

Reproduce

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