Average Error: 4.3 → 4.6
Time: 24.4s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;t \le 2.036474574005987 \cdot 10^{-85}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{\frac{t}{\sqrt[3]{1.0 - z} \cdot \sqrt[3]{1.0 - z}}}{\sqrt[3]{1.0 - z}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \frac{t}{1.0 - z} \cdot \left(-x\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)
\begin{array}{l}
\mathbf{if}\;t \le 2.036474574005987 \cdot 10^{-85}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} - \frac{\frac{t}{\sqrt[3]{1.0 - z} \cdot \sqrt[3]{1.0 - z}}}{\sqrt[3]{1.0 - z}}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r19142544 = x;
        double r19142545 = y;
        double r19142546 = z;
        double r19142547 = r19142545 / r19142546;
        double r19142548 = t;
        double r19142549 = 1.0;
        double r19142550 = r19142549 - r19142546;
        double r19142551 = r19142548 / r19142550;
        double r19142552 = r19142547 - r19142551;
        double r19142553 = r19142544 * r19142552;
        return r19142553;
}

double f(double x, double y, double z, double t) {
        double r19142554 = t;
        double r19142555 = 2.036474574005987e-85;
        bool r19142556 = r19142554 <= r19142555;
        double r19142557 = x;
        double r19142558 = y;
        double r19142559 = z;
        double r19142560 = r19142558 / r19142559;
        double r19142561 = 1.0;
        double r19142562 = r19142561 - r19142559;
        double r19142563 = cbrt(r19142562);
        double r19142564 = r19142563 * r19142563;
        double r19142565 = r19142554 / r19142564;
        double r19142566 = r19142565 / r19142563;
        double r19142567 = r19142560 - r19142566;
        double r19142568 = r19142557 * r19142567;
        double r19142569 = r19142557 * r19142558;
        double r19142570 = r19142569 / r19142559;
        double r19142571 = r19142554 / r19142562;
        double r19142572 = -r19142557;
        double r19142573 = r19142571 * r19142572;
        double r19142574 = r19142570 + r19142573;
        double r19142575 = r19142556 ? r19142568 : r19142574;
        return r19142575;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.3
Target3.9
Herbie4.6
\[\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 < 2.036474574005987e-85

    1. Initial program 4.8

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \frac{t}{\color{blue}{\left(\sqrt[3]{1.0 - z} \cdot \sqrt[3]{1.0 - z}\right) \cdot \sqrt[3]{1.0 - z}}}\right)\]
    4. Applied associate-/r*5.0

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

    if 2.036474574005987e-85 < t

    1. Initial program 3.4

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} + x \cdot \left(-\frac{t}{1.0 - z}\right)\]
    9. Taylor expanded around 0 3.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le 2.036474574005987 \cdot 10^{-85}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - \frac{\frac{t}{\sqrt[3]{1.0 - z} \cdot \sqrt[3]{1.0 - z}}}{\sqrt[3]{1.0 - z}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \frac{t}{1.0 - z} \cdot \left(-x\right)\\ \end{array}\]

Reproduce

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