Average Error: 4.6 → 1.4
Time: 6.1s
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 -1.4982403066329325 \cdot 10^{303} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 1.7050128120904795 \cdot 10^{243}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(x \cdot y, 1 - z, z \cdot \left(x \cdot \left(-t\right)\right)\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\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 -1.4982403066329325 \cdot 10^{303} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 1.7050128120904795 \cdot 10^{243}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot y, 1 - z, z \cdot \left(x \cdot \left(-t\right)\right)\right)}{z \cdot \left(1 - z\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r460724 = x;
        double r460725 = y;
        double r460726 = z;
        double r460727 = r460725 / r460726;
        double r460728 = t;
        double r460729 = 1.0;
        double r460730 = r460729 - r460726;
        double r460731 = r460728 / r460730;
        double r460732 = r460727 - r460731;
        double r460733 = r460724 * r460732;
        return r460733;
}

double f(double x, double y, double z, double t) {
        double r460734 = y;
        double r460735 = z;
        double r460736 = r460734 / r460735;
        double r460737 = t;
        double r460738 = 1.0;
        double r460739 = r460738 - r460735;
        double r460740 = r460737 / r460739;
        double r460741 = r460736 - r460740;
        double r460742 = -1.4982403066329325e+303;
        bool r460743 = r460741 <= r460742;
        double r460744 = 1.7050128120904795e+243;
        bool r460745 = r460741 <= r460744;
        double r460746 = !r460745;
        bool r460747 = r460743 || r460746;
        double r460748 = x;
        double r460749 = r460748 * r460734;
        double r460750 = -r460737;
        double r460751 = r460748 * r460750;
        double r460752 = r460735 * r460751;
        double r460753 = fma(r460749, r460739, r460752);
        double r460754 = r460735 * r460739;
        double r460755 = r460753 / r460754;
        double r460756 = 1.0;
        double r460757 = r460756 / r460735;
        double r460758 = r460740 * r460756;
        double r460759 = -r460758;
        double r460760 = fma(r460734, r460757, r460759);
        double r460761 = -r460756;
        double r460762 = r460761 + r460756;
        double r460763 = r460740 * r460762;
        double r460764 = r460760 + r460763;
        double r460765 = r460748 * r460764;
        double r460766 = r460747 ? r460755 : r460765;
        return r460766;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.6
Target4.2
Herbie1.4
\[\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))) < -1.4982403066329325e+303 or 1.7050128120904795e+243 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 38.8

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-lft-in38.8

      \[\leadsto \color{blue}{x \cdot \frac{y}{z} + x \cdot \left(-\frac{t}{1 - z}\right)}\]
    5. Using strategy rm
    6. Applied distribute-neg-frac38.8

      \[\leadsto x \cdot \frac{y}{z} + x \cdot \color{blue}{\frac{-t}{1 - z}}\]
    7. Applied associate-*r/38.8

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

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

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

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

    if -1.4982403066329325e+303 < (- (/ y z) (/ t (- 1.0 z))) < 1.7050128120904795e+243

    1. Initial program 1.4

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

      \[\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-inv1.9

      \[\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-diff1.9

      \[\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. Simplified1.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. Simplified1.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)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.4982403066329325 \cdot 10^{303} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 1.7050128120904795 \cdot 10^{243}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(x \cdot y, 1 - z, z \cdot \left(x \cdot \left(-t\right)\right)\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z} \cdot 1\right) + \frac{t}{1 - z} \cdot \left(\left(-1\right) + 1\right)\right)\\ \end{array}\]

Reproduce

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