Average Error: 5.1 → 4.2
Time: 9.4s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.7218364312970763 \cdot 10^{126}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \mathbf{elif}\;z \le 2.0835189858568739 \cdot 10^{-163}:\\ \;\;\;\;{\left(\mathsf{fma}\left(y, \frac{x}{z}, \left(-x\right) \cdot \frac{t}{1 - z}\right)\right)}^{1} + x \cdot \mathsf{fma}\left(-t, \frac{1}{1 - z}, t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -t \cdot \frac{1}{1 - z}\right) + x \cdot \mathsf{fma}\left(-t, \frac{1}{1 - z}, t \cdot \frac{1}{1 - z}\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;z \le -3.7218364312970763 \cdot 10^{126}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r403042 = x;
        double r403043 = y;
        double r403044 = z;
        double r403045 = r403043 / r403044;
        double r403046 = t;
        double r403047 = 1.0;
        double r403048 = r403047 - r403044;
        double r403049 = r403046 / r403048;
        double r403050 = r403045 - r403049;
        double r403051 = r403042 * r403050;
        return r403051;
}

double f(double x, double y, double z, double t) {
        double r403052 = z;
        double r403053 = -3.721836431297076e+126;
        bool r403054 = r403052 <= r403053;
        double r403055 = x;
        double r403056 = y;
        double r403057 = r403056 / r403052;
        double r403058 = 1.0;
        double r403059 = 1.0;
        double r403060 = r403059 - r403052;
        double r403061 = t;
        double r403062 = r403060 / r403061;
        double r403063 = r403058 / r403062;
        double r403064 = r403057 - r403063;
        double r403065 = r403055 * r403064;
        double r403066 = 2.083518985856874e-163;
        bool r403067 = r403052 <= r403066;
        double r403068 = r403055 / r403052;
        double r403069 = -r403055;
        double r403070 = r403061 / r403060;
        double r403071 = r403069 * r403070;
        double r403072 = fma(r403056, r403068, r403071);
        double r403073 = pow(r403072, r403058);
        double r403074 = -r403061;
        double r403075 = r403058 / r403060;
        double r403076 = r403061 * r403075;
        double r403077 = fma(r403074, r403075, r403076);
        double r403078 = r403055 * r403077;
        double r403079 = r403073 + r403078;
        double r403080 = r403058 / r403052;
        double r403081 = -r403076;
        double r403082 = fma(r403056, r403080, r403081);
        double r403083 = r403055 * r403082;
        double r403084 = r403083 + r403078;
        double r403085 = r403067 ? r403079 : r403084;
        double r403086 = r403054 ? r403065 : r403085;
        return r403086;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original5.1
Target4.6
Herbie4.2
\[\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 z < -3.721836431297076e+126

    1. Initial program 2.7

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

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

    if -3.721836431297076e+126 < z < 2.083518985856874e-163

    1. Initial program 7.7

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{1}{\frac{1 - z}{t}}}\right)\]
    4. Using strategy rm
    5. Applied add-cube-cbrt8.1

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\left(\sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right) \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}}\right)\]
    6. Applied div-inv8.1

      \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \left(\sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right) \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right)\]
    7. Applied prod-diff8.1

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

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

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

      \[\leadsto x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -t \cdot \frac{1}{1 - z}\right) + \color{blue}{x \cdot \mathsf{fma}\left(-t, \frac{1}{1 - z}, t \cdot \frac{1}{1 - z}\right)}\]
    11. Using strategy rm
    12. Applied pow17.7

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

      \[\leadsto \color{blue}{{x}^{1}} \cdot {\left(\mathsf{fma}\left(y, \frac{1}{z}, -t \cdot \frac{1}{1 - z}\right)\right)}^{1} + x \cdot \mathsf{fma}\left(-t, \frac{1}{1 - z}, t \cdot \frac{1}{1 - z}\right)\]
    14. Applied pow-prod-down7.7

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

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

    if 2.083518985856874e-163 < z

    1. Initial program 3.7

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{1}{\frac{1 - z}{t}}}\right)\]
    4. Using strategy rm
    5. Applied add-cube-cbrt4.2

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\left(\sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right) \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}}\right)\]
    6. Applied div-inv4.2

      \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \left(\sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right) \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right)\]
    7. Applied prod-diff4.2

      \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(y, \frac{1}{z}, -\sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \left(\sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{1}{\frac{1 - z}{t}}}, \sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}, \sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \left(\sqrt[3]{\frac{1}{\frac{1 - z}{t}}} \cdot \sqrt[3]{\frac{1}{\frac{1 - z}{t}}}\right)\right)\right)}\]
    8. Applied distribute-lft-in4.2

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

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

      \[\leadsto x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -t \cdot \frac{1}{1 - z}\right) + \color{blue}{x \cdot \mathsf{fma}\left(-t, \frac{1}{1 - z}, t \cdot \frac{1}{1 - z}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.7218364312970763 \cdot 10^{126}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right)\\ \mathbf{elif}\;z \le 2.0835189858568739 \cdot 10^{-163}:\\ \;\;\;\;{\left(\mathsf{fma}\left(y, \frac{x}{z}, \left(-x\right) \cdot \frac{t}{1 - z}\right)\right)}^{1} + x \cdot \mathsf{fma}\left(-t, \frac{1}{1 - z}, t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -t \cdot \frac{1}{1 - z}\right) + x \cdot \mathsf{fma}\left(-t, \frac{1}{1 - z}, t \cdot \frac{1}{1 - z}\right)\\ \end{array}\]

Reproduce

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