Average Error: 4.9 → 1.9
Time: 1.0m
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1.0 - z} \le -7.814721269168491 \cdot 10^{+262}:\\ \;\;\;\;\frac{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 3.6934964504565474 \cdot 10^{+254}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{y}{z}} \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{\frac{1}{z}}\right), \sqrt[3]{\frac{y}{z}}, t \cdot \frac{-1}{1.0 - z}\right) \cdot x + x \cdot \mathsf{fma}\left(\frac{-1}{1.0 - z}, t, t \cdot \frac{1}{1.0 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot z}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} - \frac{t}{1.0 - z} \le -7.814721269168491 \cdot 10^{+262}:\\
\;\;\;\;\frac{x \cdot \left(\left(1.0 - z\right) \cdot y - t \cdot z\right)}{\left(1.0 - z\right) \cdot z}\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 3.6934964504565474 \cdot 10^{+254}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{y}{z}} \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{\frac{1}{z}}\right), \sqrt[3]{\frac{y}{z}}, t \cdot \frac{-1}{1.0 - z}\right) \cdot x + x \cdot \mathsf{fma}\left(\frac{-1}{1.0 - z}, t, t \cdot \frac{1}{1.0 - z}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r15623582 = x;
        double r15623583 = y;
        double r15623584 = z;
        double r15623585 = r15623583 / r15623584;
        double r15623586 = t;
        double r15623587 = 1.0;
        double r15623588 = r15623587 - r15623584;
        double r15623589 = r15623586 / r15623588;
        double r15623590 = r15623585 - r15623589;
        double r15623591 = r15623582 * r15623590;
        return r15623591;
}

double f(double x, double y, double z, double t) {
        double r15623592 = y;
        double r15623593 = z;
        double r15623594 = r15623592 / r15623593;
        double r15623595 = t;
        double r15623596 = 1.0;
        double r15623597 = r15623596 - r15623593;
        double r15623598 = r15623595 / r15623597;
        double r15623599 = r15623594 - r15623598;
        double r15623600 = -7.814721269168491e+262;
        bool r15623601 = r15623599 <= r15623600;
        double r15623602 = x;
        double r15623603 = r15623597 * r15623592;
        double r15623604 = r15623595 * r15623593;
        double r15623605 = r15623603 - r15623604;
        double r15623606 = r15623602 * r15623605;
        double r15623607 = r15623597 * r15623593;
        double r15623608 = r15623606 / r15623607;
        double r15623609 = 3.6934964504565474e+254;
        bool r15623610 = r15623599 <= r15623609;
        double r15623611 = cbrt(r15623594);
        double r15623612 = cbrt(r15623592);
        double r15623613 = 1.0;
        double r15623614 = r15623613 / r15623593;
        double r15623615 = cbrt(r15623614);
        double r15623616 = r15623612 * r15623615;
        double r15623617 = r15623611 * r15623616;
        double r15623618 = -1.0;
        double r15623619 = r15623618 / r15623597;
        double r15623620 = r15623595 * r15623619;
        double r15623621 = fma(r15623617, r15623611, r15623620);
        double r15623622 = r15623621 * r15623602;
        double r15623623 = r15623613 / r15623597;
        double r15623624 = r15623595 * r15623623;
        double r15623625 = fma(r15623619, r15623595, r15623624);
        double r15623626 = r15623602 * r15623625;
        double r15623627 = r15623622 + r15623626;
        double r15623628 = r15623610 ? r15623627 : r15623608;
        double r15623629 = r15623601 ? r15623608 : r15623628;
        return r15623629;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.9
Target4.5
Herbie1.9
\[\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.0}{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.0}{1.0 - z}\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -7.814721269168491e+262 or 3.6934964504565474e+254 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 34.2

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

      \[\leadsto \color{blue}{\left(\frac{y}{z} - \frac{t}{1.0 - z}\right) \cdot x}\]
    4. Using strategy rm
    5. Applied frac-sub35.8

      \[\leadsto \color{blue}{\frac{y \cdot \left(1.0 - z\right) - z \cdot t}{z \cdot \left(1.0 - z\right)}} \cdot x\]
    6. Applied associate-*l/1.8

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

    if -7.814721269168491e+262 < (- (/ y z) (/ t (- 1.0 z))) < 3.6934964504565474e+254

    1. Initial program 1.4

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}, \sqrt[3]{\frac{y}{z}}, -\frac{1}{1.0 - z} \cdot t\right) + \mathsf{fma}\left(-\frac{1}{1.0 - z}, t, \frac{1}{1.0 - z} \cdot t\right)\right)}\]
    6. Applied distribute-rgt-in2.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}, \sqrt[3]{\frac{y}{z}}, -\frac{1}{1.0 - z} \cdot t\right) \cdot x + \mathsf{fma}\left(-\frac{1}{1.0 - z}, t, \frac{1}{1.0 - z} \cdot t\right) \cdot x}\]
    7. Using strategy rm
    8. Applied div-inv2.0

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

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

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

Reproduce

herbie shell --seed 2019165 +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.0 (- 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.0 (- 1.0 z)))))))

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