Average Error: 4.7 → 1.9
Time: 7.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 -9.646790149877547554526139637147119808939 \cdot 10^{281} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 1.007109693799832358104777617759847004729 \cdot 10^{193}\right):\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\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 -9.646790149877547554526139637147119808939 \cdot 10^{281} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 1.007109693799832358104777617759847004729 \cdot 10^{193}\right):\\
\;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\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 r387994 = x;
        double r387995 = y;
        double r387996 = z;
        double r387997 = r387995 / r387996;
        double r387998 = t;
        double r387999 = 1.0;
        double r388000 = r387999 - r387996;
        double r388001 = r387998 / r388000;
        double r388002 = r387997 - r388001;
        double r388003 = r387994 * r388002;
        return r388003;
}

double f(double x, double y, double z, double t) {
        double r388004 = y;
        double r388005 = z;
        double r388006 = r388004 / r388005;
        double r388007 = t;
        double r388008 = 1.0;
        double r388009 = r388008 - r388005;
        double r388010 = r388007 / r388009;
        double r388011 = r388006 - r388010;
        double r388012 = -9.646790149877548e+281;
        bool r388013 = r388011 <= r388012;
        double r388014 = 1.0071096937998324e+193;
        bool r388015 = r388011 <= r388014;
        double r388016 = !r388015;
        bool r388017 = r388013 || r388016;
        double r388018 = x;
        double r388019 = r388004 * r388009;
        double r388020 = r388005 * r388007;
        double r388021 = r388019 - r388020;
        double r388022 = r388018 * r388021;
        double r388023 = r388005 * r388009;
        double r388024 = r388022 / r388023;
        double r388025 = 1.0;
        double r388026 = r388025 / r388005;
        double r388027 = r388010 * r388025;
        double r388028 = -r388027;
        double r388029 = fma(r388004, r388026, r388028);
        double r388030 = -r388025;
        double r388031 = r388030 + r388025;
        double r388032 = r388010 * r388031;
        double r388033 = r388029 + r388032;
        double r388034 = r388018 * r388033;
        double r388035 = r388017 ? r388024 : r388034;
        return r388035;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.7
Target4.4
Herbie1.9
\[\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 2 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -9.646790149877548e+281 or 1.0071096937998324e+193 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 27.6

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

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

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

    if -9.646790149877548e+281 < (- (/ y z) (/ t (- 1.0 z))) < 1.0071096937998324e+193

    1. Initial program 1.3

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

      \[\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.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. Simplified1.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -9.646790149877547554526139637147119808939 \cdot 10^{281} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 1.007109693799832358104777617759847004729 \cdot 10^{193}\right):\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\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 2020002 +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)))))