Average Error: 4.9 → 0.6
Time: 6.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 y}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.0158122322120207 \cdot 10^{-256}:\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{\frac{t}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}}}{\sqrt[3]{1 - z}} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.45300871450105099 \cdot 10^{-232}:\\ \;\;\;\;\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 3.17634291254000495 \cdot 10^{305}:\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{\frac{t}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}}}{\sqrt[3]{1 - z}} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\ \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} = -\infty:\\
\;\;\;\;\frac{x \cdot y}{z}\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.0158122322120207 \cdot 10^{-256}:\\
\;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{\frac{t}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}}}{\sqrt[3]{1 - z}} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.45300871450105099 \cdot 10^{-232}:\\
\;\;\;\;\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 3.17634291254000495 \cdot 10^{305}:\\
\;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{\frac{t}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}}}{\sqrt[3]{1 - z}} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r420799 = x;
        double r420800 = y;
        double r420801 = z;
        double r420802 = r420800 / r420801;
        double r420803 = t;
        double r420804 = 1.0;
        double r420805 = r420804 - r420801;
        double r420806 = r420803 / r420805;
        double r420807 = r420802 - r420806;
        double r420808 = r420799 * r420807;
        return r420808;
}

double f(double x, double y, double z, double t) {
        double r420809 = y;
        double r420810 = z;
        double r420811 = r420809 / r420810;
        double r420812 = t;
        double r420813 = 1.0;
        double r420814 = r420813 - r420810;
        double r420815 = r420812 / r420814;
        double r420816 = r420811 - r420815;
        double r420817 = -inf.0;
        bool r420818 = r420816 <= r420817;
        double r420819 = x;
        double r420820 = r420819 * r420809;
        double r420821 = r420820 / r420810;
        double r420822 = -4.015812232212021e-256;
        bool r420823 = r420816 <= r420822;
        double r420824 = 1.0;
        double r420825 = r420824 / r420810;
        double r420826 = cbrt(r420814);
        double r420827 = r420826 * r420826;
        double r420828 = r420812 / r420827;
        double r420829 = r420828 / r420826;
        double r420830 = r420829 * r420824;
        double r420831 = -r420830;
        double r420832 = fma(r420809, r420825, r420831);
        double r420833 = -r420824;
        double r420834 = r420833 + r420824;
        double r420835 = r420815 * r420834;
        double r420836 = r420832 + r420835;
        double r420837 = r420819 * r420836;
        double r420838 = 1.453008714501051e-232;
        bool r420839 = r420816 <= r420838;
        double r420840 = r420819 / r420810;
        double r420841 = r420812 * r420819;
        double r420842 = 2.0;
        double r420843 = pow(r420810, r420842);
        double r420844 = r420841 / r420843;
        double r420845 = r420841 / r420810;
        double r420846 = fma(r420813, r420844, r420845);
        double r420847 = fma(r420840, r420809, r420846);
        double r420848 = 3.176342912540005e+305;
        bool r420849 = r420816 <= r420848;
        double r420850 = r420849 ? r420837 : r420821;
        double r420851 = r420839 ? r420847 : r420850;
        double r420852 = r420823 ? r420837 : r420851;
        double r420853 = r420818 ? r420821 : r420852;
        return r420853;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.9
Target4.4
Herbie0.6
\[\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))) < -inf.0 or 3.176342912540005e+305 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 62.5

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

      \[\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-inv62.5

      \[\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-diff62.5

      \[\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. Simplified62.5

      \[\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. Simplified62.5

      \[\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 0.9

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

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < -4.015812232212021e-256 or 1.453008714501051e-232 < (- (/ y z) (/ t (- 1.0 z))) < 3.176342912540005e+305

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

      \[\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. Using strategy rm
    9. Applied add-cube-cbrt0.5

      \[\leadsto x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{\color{blue}{\left(\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}\right) \cdot \sqrt[3]{1 - z}}} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\]
    10. Applied associate-/r*0.5

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

    if -4.015812232212021e-256 < (- (/ y z) (/ t (- 1.0 z))) < 1.453008714501051e-232

    1. Initial program 12.1

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt12.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-inv12.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-diff12.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. Simplified12.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. Simplified12.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.6

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

      \[\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)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} = -\infty:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -4.0158122322120207 \cdot 10^{-256}:\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{\frac{t}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}}}{\sqrt[3]{1 - z}} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 1.45300871450105099 \cdot 10^{-232}:\\ \;\;\;\;\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 3.17634291254000495 \cdot 10^{305}:\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{\frac{t}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}}}{\sqrt[3]{1 - z}} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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