Average Error: 4.6 → 5.2
Time: 19.3s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;t \le -5.033586041953549 \cdot 10^{-298}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{x \cdot y}{z}} \cdot \sqrt[3]{\frac{x \cdot y}{z}}, \sqrt[3]{\frac{x \cdot y}{z}}, \left(-x\right) \cdot \frac{t}{1.0 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1.0 - z}{t}}\right) \cdot x\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)
\begin{array}{l}
\mathbf{if}\;t \le -5.033586041953549 \cdot 10^{-298}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{x \cdot y}{z}} \cdot \sqrt[3]{\frac{x \cdot y}{z}}, \sqrt[3]{\frac{x \cdot y}{z}}, \left(-x\right) \cdot \frac{t}{1.0 - z}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1.0 - z}{t}}\right) \cdot x\\

\end{array}
double f(double x, double y, double z, double t) {
        double r6651193 = x;
        double r6651194 = y;
        double r6651195 = z;
        double r6651196 = r6651194 / r6651195;
        double r6651197 = t;
        double r6651198 = 1.0;
        double r6651199 = r6651198 - r6651195;
        double r6651200 = r6651197 / r6651199;
        double r6651201 = r6651196 - r6651200;
        double r6651202 = r6651193 * r6651201;
        return r6651202;
}

double f(double x, double y, double z, double t) {
        double r6651203 = t;
        double r6651204 = -5.033586041953549e-298;
        bool r6651205 = r6651203 <= r6651204;
        double r6651206 = x;
        double r6651207 = y;
        double r6651208 = r6651206 * r6651207;
        double r6651209 = z;
        double r6651210 = r6651208 / r6651209;
        double r6651211 = cbrt(r6651210);
        double r6651212 = r6651211 * r6651211;
        double r6651213 = -r6651206;
        double r6651214 = 1.0;
        double r6651215 = r6651214 - r6651209;
        double r6651216 = r6651203 / r6651215;
        double r6651217 = r6651213 * r6651216;
        double r6651218 = fma(r6651212, r6651211, r6651217);
        double r6651219 = r6651207 / r6651209;
        double r6651220 = 1.0;
        double r6651221 = r6651215 / r6651203;
        double r6651222 = r6651220 / r6651221;
        double r6651223 = r6651219 - r6651222;
        double r6651224 = r6651223 * r6651206;
        double r6651225 = r6651205 ? r6651218 : r6651224;
        return r6651225;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.6
Target4.2
Herbie5.2
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \lt -7.623226303312042 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1.0 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \lt 1.4133944927702302 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1.0 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1.0 - z}\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -5.033586041953549e-298

    1. Initial program 4.5

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)\]
    2. Using strategy rm
    3. Applied div-inv4.6

      \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \frac{t}{1.0 - z}\right)\]
    4. Applied fma-neg4.6

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1.0 - z}\right)}\]
    5. Using strategy rm
    6. Applied fma-udef4.6

      \[\leadsto x \cdot \color{blue}{\left(y \cdot \frac{1}{z} + \left(-\frac{t}{1.0 - z}\right)\right)}\]
    7. Applied distribute-lft-in4.6

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + x \cdot \left(-\frac{t}{1.0 - z}\right)\]
    9. Using strategy rm
    10. Applied add-cube-cbrt5.7

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x \cdot y}{z}} \cdot \sqrt[3]{\frac{x \cdot y}{z}}\right) \cdot \sqrt[3]{\frac{x \cdot y}{z}}} + x \cdot \left(-\frac{t}{1.0 - z}\right)\]
    11. Applied fma-def5.7

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

    if -5.033586041953549e-298 < t

    1. Initial program 4.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.033586041953549 \cdot 10^{-298}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{x \cdot y}{z}} \cdot \sqrt[3]{\frac{x \cdot y}{z}}, \sqrt[3]{\frac{x \cdot y}{z}}, \left(-x\right) \cdot \frac{t}{1.0 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1.0 - z}{t}}\right) \cdot x\\ \end{array}\]

Reproduce

herbie shell --seed 2019156 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1 (- 1.0 z)))))))

  (* x (- (/ y z) (/ t (- 1.0 z)))))