Average Error: 4.6 → 0.8
Time: 48.9s
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 \mathsf{fma}\left(1 - z, y, \left(-z\right) \cdot t\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.366221236771887487690780301547077348915 \cdot 10^{-172}:\\ \;\;\;\;x \cdot \left(\left(\left(-\frac{t}{1 - z}\right) + \frac{t}{1 - z}\right) + \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 8.63239208884550581769054490808218501241 \cdot 10^{-259}:\\ \;\;\;\;\frac{x \cdot y}{z} + \mathsf{fma}\left(1, \frac{t \cdot x}{z \cdot z}, \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.205961360970320375354820605320501146436 \cdot 10^{224}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \mathsf{fma}\left(1 - z, y, \left(-z\right) \cdot t\right)}{\left(1 - z\right) \cdot 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} = -\infty:\\
\;\;\;\;\frac{x \cdot \mathsf{fma}\left(1 - z, y, \left(-z\right) \cdot t\right)}{\left(1 - z\right) \cdot z}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r421610 = x;
        double r421611 = y;
        double r421612 = z;
        double r421613 = r421611 / r421612;
        double r421614 = t;
        double r421615 = 1.0;
        double r421616 = r421615 - r421612;
        double r421617 = r421614 / r421616;
        double r421618 = r421613 - r421617;
        double r421619 = r421610 * r421618;
        return r421619;
}

double f(double x, double y, double z, double t) {
        double r421620 = y;
        double r421621 = z;
        double r421622 = r421620 / r421621;
        double r421623 = t;
        double r421624 = 1.0;
        double r421625 = r421624 - r421621;
        double r421626 = r421623 / r421625;
        double r421627 = r421622 - r421626;
        double r421628 = -inf.0;
        bool r421629 = r421627 <= r421628;
        double r421630 = x;
        double r421631 = -r421621;
        double r421632 = r421631 * r421623;
        double r421633 = fma(r421625, r421620, r421632);
        double r421634 = r421630 * r421633;
        double r421635 = r421625 * r421621;
        double r421636 = r421634 / r421635;
        double r421637 = -1.3662212367718875e-172;
        bool r421638 = r421627 <= r421637;
        double r421639 = -r421626;
        double r421640 = r421639 + r421626;
        double r421641 = 1.0;
        double r421642 = r421641 / r421621;
        double r421643 = fma(r421620, r421642, r421639);
        double r421644 = r421640 + r421643;
        double r421645 = r421630 * r421644;
        double r421646 = 8.632392088845506e-259;
        bool r421647 = r421627 <= r421646;
        double r421648 = r421630 * r421620;
        double r421649 = r421648 / r421621;
        double r421650 = r421623 * r421630;
        double r421651 = r421621 * r421621;
        double r421652 = r421650 / r421651;
        double r421653 = r421650 / r421621;
        double r421654 = fma(r421624, r421652, r421653);
        double r421655 = r421649 + r421654;
        double r421656 = 1.2059613609703204e+224;
        bool r421657 = r421627 <= r421656;
        double r421658 = r421625 / r421623;
        double r421659 = r421641 / r421658;
        double r421660 = r421622 - r421659;
        double r421661 = r421660 * r421630;
        double r421662 = r421657 ? r421661 : r421636;
        double r421663 = r421647 ? r421655 : r421662;
        double r421664 = r421638 ? r421645 : r421663;
        double r421665 = r421629 ? r421636 : r421664;
        return r421665;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.6
Target4.3
Herbie0.8
\[\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 4 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -inf.0 or 1.2059613609703204e+224 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 34.4

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

      \[\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/3.3

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

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

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

    1. Initial program 0.2

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

      \[\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-inv0.8

      \[\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-diff0.8

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

      \[\leadsto x \cdot \left(\color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, \frac{-t}{1 - z}\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. Simplified0.3

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

    if -1.3662212367718875e-172 < (- (/ y z) (/ t (- 1.0 z))) < 8.632392088845506e-259

    1. Initial program 9.1

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{1}{\frac{1 - z}{t}}}\right)\]
    4. Taylor expanded around inf 1.9

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

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

    if 8.632392088845506e-259 < (- (/ y z) (/ t (- 1.0 z))) < 1.2059613609703204e+224

    1. Initial program 0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} = -\infty:\\ \;\;\;\;\frac{x \cdot \mathsf{fma}\left(1 - z, y, \left(-z\right) \cdot t\right)}{\left(1 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.366221236771887487690780301547077348915 \cdot 10^{-172}:\\ \;\;\;\;x \cdot \left(\left(\left(-\frac{t}{1 - z}\right) + \frac{t}{1 - z}\right) + \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 8.63239208884550581769054490808218501241 \cdot 10^{-259}:\\ \;\;\;\;\frac{x \cdot y}{z} + \mathsf{fma}\left(1, \frac{t \cdot x}{z \cdot z}, \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.205961360970320375354820605320501146436 \cdot 10^{224}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \mathsf{fma}\left(1 - z, y, \left(-z\right) \cdot t\right)}{\left(1 - z\right) \cdot z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(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)))))