Average Error: 4.8 → 2.0
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 -2.21749489122410534 \cdot 10^{-247}:\\ \;\;\;\;\left(\left(\frac{y}{z} + \frac{t}{1 - z}\right) \cdot x\right) \cdot \frac{\frac{y}{z} - \frac{t}{1 - z}}{\frac{y}{z} + \frac{t}{1 - z}}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.06689610291439 \cdot 10^{-310}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 7.99981893666819769 \cdot 10^{301}:\\ \;\;\;\;\left(\left(\frac{y}{z} + \frac{t}{1 - z}\right) \cdot x\right) \cdot \frac{\frac{y}{z} - \frac{t}{1 - z}}{\frac{y}{z} + \frac{t}{1 - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\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}\;\frac{y}{z} - \frac{t}{1 - z} \le -2.21749489122410534 \cdot 10^{-247}:\\
\;\;\;\;\left(\left(\frac{y}{z} + \frac{t}{1 - z}\right) \cdot x\right) \cdot \frac{\frac{y}{z} - \frac{t}{1 - z}}{\frac{y}{z} + \frac{t}{1 - z}}\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.06689610291439 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r380616 = x;
        double r380617 = y;
        double r380618 = z;
        double r380619 = r380617 / r380618;
        double r380620 = t;
        double r380621 = 1.0;
        double r380622 = r380621 - r380618;
        double r380623 = r380620 / r380622;
        double r380624 = r380619 - r380623;
        double r380625 = r380616 * r380624;
        return r380625;
}

double f(double x, double y, double z, double t) {
        double r380626 = y;
        double r380627 = z;
        double r380628 = r380626 / r380627;
        double r380629 = t;
        double r380630 = 1.0;
        double r380631 = r380630 - r380627;
        double r380632 = r380629 / r380631;
        double r380633 = r380628 - r380632;
        double r380634 = -2.2174948912241053e-247;
        bool r380635 = r380633 <= r380634;
        double r380636 = r380628 + r380632;
        double r380637 = x;
        double r380638 = r380636 * r380637;
        double r380639 = r380633 / r380636;
        double r380640 = r380638 * r380639;
        double r380641 = 1.0668961029144e-310;
        bool r380642 = r380633 <= r380641;
        double r380643 = r380637 / r380627;
        double r380644 = r380629 * r380637;
        double r380645 = 2.0;
        double r380646 = pow(r380627, r380645);
        double r380647 = r380644 / r380646;
        double r380648 = r380644 / r380627;
        double r380649 = fma(r380630, r380647, r380648);
        double r380650 = fma(r380643, r380626, r380649);
        double r380651 = 7.999818936668198e+301;
        bool r380652 = r380633 <= r380651;
        double r380653 = r380626 * r380631;
        double r380654 = r380627 * r380629;
        double r380655 = r380653 - r380654;
        double r380656 = r380637 * r380655;
        double r380657 = r380627 * r380631;
        double r380658 = r380656 / r380657;
        double r380659 = r380652 ? r380640 : r380658;
        double r380660 = r380642 ? r380650 : r380659;
        double r380661 = r380635 ? r380640 : r380660;
        return r380661;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.8
Target4.4
Herbie2.0
\[\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 3 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -2.2174948912241053e-247 or 1.0668961029144e-310 < (- (/ y z) (/ t (- 1.0 z))) < 7.999818936668198e+301

    1. Initial program 2.2

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

      \[\leadsto x \cdot \color{blue}{\frac{\frac{y}{z} \cdot \frac{y}{z} - \frac{t}{1 - z} \cdot \frac{t}{1 - z}}{\frac{y}{z} + \frac{t}{1 - z}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity20.6

      \[\leadsto x \cdot \frac{\frac{y}{z} \cdot \frac{y}{z} - \frac{t}{1 - z} \cdot \frac{t}{1 - z}}{\color{blue}{1 \cdot \left(\frac{y}{z} + \frac{t}{1 - z}\right)}}\]
    6. Applied difference-of-squares20.6

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

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

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

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

    if -2.2174948912241053e-247 < (- (/ y z) (/ t (- 1.0 z))) < 1.0668961029144e-310

    1. Initial program 15.1

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt15.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-inv15.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-diff15.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. Simplified15.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. Simplified15.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 inf 0.2

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)}\]
    9. Simplified0.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{z}, y, \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\right)}\]

    if 7.999818936668198e+301 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 56.8

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

      \[\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.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -2.21749489122410534 \cdot 10^{-247}:\\ \;\;\;\;\left(\left(\frac{y}{z} + \frac{t}{1 - z}\right) \cdot x\right) \cdot \frac{\frac{y}{z} - \frac{t}{1 - z}}{\frac{y}{z} + \frac{t}{1 - z}}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.06689610291439 \cdot 10^{-310}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 7.99981893666819769 \cdot 10^{301}:\\ \;\;\;\;\left(\left(\frac{y}{z} + \frac{t}{1 - z}\right) \cdot x\right) \cdot \frac{\frac{y}{z} - \frac{t}{1 - z}}{\frac{y}{z} + \frac{t}{1 - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \end{array}\]

Reproduce

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