Average Error: 4.5 → 3.7
Time: 5.8s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.5170262571629159 \cdot 10^{-246} \lor \neg \left(z \le 1.0972486773535519 \cdot 10^{-62}\right):\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right) + x \cdot \left(\frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\ \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}\;z \le -4.5170262571629159 \cdot 10^{-246} \lor \neg \left(z \le 1.0972486773535519 \cdot 10^{-62}\right):\\
\;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right) + x \cdot \left(\frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\

\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 r345775 = x;
        double r345776 = y;
        double r345777 = z;
        double r345778 = r345776 / r345777;
        double r345779 = t;
        double r345780 = 1.0;
        double r345781 = r345780 - r345777;
        double r345782 = r345779 / r345781;
        double r345783 = r345778 - r345782;
        double r345784 = r345775 * r345783;
        return r345784;
}

double f(double x, double y, double z, double t) {
        double r345785 = z;
        double r345786 = -4.517026257162916e-246;
        bool r345787 = r345785 <= r345786;
        double r345788 = 1.097248677353552e-62;
        bool r345789 = r345785 <= r345788;
        double r345790 = !r345789;
        bool r345791 = r345787 || r345790;
        double r345792 = x;
        double r345793 = y;
        double r345794 = 1.0;
        double r345795 = r345794 / r345785;
        double r345796 = t;
        double r345797 = 1.0;
        double r345798 = r345797 - r345785;
        double r345799 = r345796 / r345798;
        double r345800 = r345799 * r345794;
        double r345801 = -r345800;
        double r345802 = fma(r345793, r345795, r345801);
        double r345803 = r345792 * r345802;
        double r345804 = -r345794;
        double r345805 = r345804 + r345794;
        double r345806 = r345799 * r345805;
        double r345807 = r345792 * r345806;
        double r345808 = r345803 + r345807;
        double r345809 = r345793 * r345798;
        double r345810 = r345785 * r345796;
        double r345811 = r345809 - r345810;
        double r345812 = r345792 * r345811;
        double r345813 = r345785 * r345798;
        double r345814 = r345812 / r345813;
        double r345815 = r345791 ? r345808 : r345814;
        return r345815;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target4.0
Herbie3.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 z < -4.517026257162916e-246 or 1.097248677353552e-62 < z

    1. Initial program 3.1

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

      \[\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-diff3.6

      \[\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. Applied distribute-lft-in3.6

      \[\leadsto \color{blue}{x \cdot \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) + x \cdot \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)}\]
    7. Simplified3.1

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right)} + x \cdot \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)\]
    8. Simplified3.1

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

    if -4.517026257162916e-246 < z < 1.097248677353552e-62

    1. Initial program 10.8

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

      \[\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/6.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 2 regimes into one program.
  4. Final simplification3.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.5170262571629159 \cdot 10^{-246} \lor \neg \left(z \le 1.0972486773535519 \cdot 10^{-62}\right):\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right) + x \cdot \left(\frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\ \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 2020018 +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)))))