Average Error: 4.5 → 1.4
Time: 18.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 -3.295011470001874160122657109542375033068 \cdot 10^{275}:\\ \;\;\;\;\left(\left(-\frac{x \cdot t}{1 - z}\right) + \frac{y \cdot x}{z}\right) + \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 4.862861552770296825237343335186305099433 \cdot 10^{206}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x + \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(\left(-\frac{x \cdot t}{1 - z}\right) + \frac{y \cdot x}{z}\right) + \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right) \cdot x\\ \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 -3.295011470001874160122657109542375033068 \cdot 10^{275}:\\
\;\;\;\;\left(\left(-\frac{x \cdot t}{1 - z}\right) + \frac{y \cdot x}{z}\right) + \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right) \cdot x\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r15697283 = x;
        double r15697284 = y;
        double r15697285 = z;
        double r15697286 = r15697284 / r15697285;
        double r15697287 = t;
        double r15697288 = 1.0;
        double r15697289 = r15697288 - r15697285;
        double r15697290 = r15697287 / r15697289;
        double r15697291 = r15697286 - r15697290;
        double r15697292 = r15697283 * r15697291;
        return r15697292;
}

double f(double x, double y, double z, double t) {
        double r15697293 = y;
        double r15697294 = z;
        double r15697295 = r15697293 / r15697294;
        double r15697296 = t;
        double r15697297 = 1.0;
        double r15697298 = r15697297 - r15697294;
        double r15697299 = r15697296 / r15697298;
        double r15697300 = r15697295 - r15697299;
        double r15697301 = -3.295011470001874e+275;
        bool r15697302 = r15697300 <= r15697301;
        double r15697303 = x;
        double r15697304 = r15697303 * r15697296;
        double r15697305 = r15697304 / r15697298;
        double r15697306 = -r15697305;
        double r15697307 = r15697293 * r15697303;
        double r15697308 = r15697307 / r15697294;
        double r15697309 = r15697306 + r15697308;
        double r15697310 = -1.0;
        double r15697311 = fma(r15697299, r15697310, r15697299);
        double r15697312 = r15697311 * r15697303;
        double r15697313 = r15697309 + r15697312;
        double r15697314 = 4.862861552770297e+206;
        bool r15697315 = r15697300 <= r15697314;
        double r15697316 = r15697300 * r15697303;
        double r15697317 = r15697316 + r15697312;
        double r15697318 = r15697315 ? r15697317 : r15697313;
        double r15697319 = r15697302 ? r15697313 : r15697318;
        return r15697319;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target4.2
Herbie1.4
\[\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))) < -3.295011470001874e+275 or 4.862861552770297e+206 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 26.3

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

      \[\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-inv26.6

      \[\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-diff26.6

      \[\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. Applied distribute-lft-in26.6

      \[\leadsto \color{blue}{x \cdot \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) + x \cdot \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)}\]
    7. Simplified26.6

      \[\leadsto x \cdot \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) + \color{blue}{x \cdot \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right)}\]
    8. Using strategy rm
    9. Applied fma-udef26.6

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

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

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

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

    if -3.295011470001874e+275 < (- (/ y z) (/ t (- 1.0 z))) < 4.862861552770297e+206

    1. Initial program 1.4

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

      \[\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-inv2.0

      \[\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-diff2.0

      \[\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. Applied distribute-lft-in2.0

      \[\leadsto \color{blue}{x \cdot \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) + x \cdot \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)}\]
    7. Simplified2.0

      \[\leadsto x \cdot \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) + \color{blue}{x \cdot \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right)}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity2.0

      \[\leadsto \color{blue}{\left(1 \cdot x\right)} \cdot \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) + x \cdot \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right)\]
    10. Applied associate-*l*2.0

      \[\leadsto \color{blue}{1 \cdot \left(x \cdot \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)\right)} + x \cdot \mathsf{fma}\left(\frac{t}{1 - z}, -1, \frac{t}{1 - z}\right)\]
    11. Simplified1.4

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

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

Reproduce

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