Average Error: 4.5 → 0.7
Time: 25.0s
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} = -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le -1.8815398856819596 \cdot 10^{-223}:\\ \;\;\;\;\left(\frac{y}{z} - \sqrt[3]{\frac{t}{1.0 - z}} \cdot \left(\sqrt[3]{\frac{t}{1.0 - z}} \cdot \sqrt[3]{\frac{t}{1.0 - z}}\right)\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 5.632888446083138 \cdot 10^{-266}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(\frac{-1}{1.0 - z}, t, t \cdot \frac{1}{1.0 - z}\right) + \mathsf{fma}\left(\frac{x}{z}, y, \mathsf{fma}\left(\frac{1.0}{z}, \frac{x \cdot t}{z}, \frac{x \cdot t}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 2.4899172613549185 \cdot 10^{+301}:\\ \;\;\;\;\left(\sqrt{\frac{y}{z} - \frac{t}{1.0 - z}} \cdot x\right) \cdot \sqrt{\frac{y}{z} - \frac{t}{1.0 - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{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} = -\infty:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le -1.8815398856819596 \cdot 10^{-223}:\\
\;\;\;\;\left(\frac{y}{z} - \sqrt[3]{\frac{t}{1.0 - z}} \cdot \left(\sqrt[3]{\frac{t}{1.0 - z}} \cdot \sqrt[3]{\frac{t}{1.0 - z}}\right)\right) \cdot x\\

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

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 2.4899172613549185 \cdot 10^{+301}:\\
\;\;\;\;\left(\sqrt{\frac{y}{z} - \frac{t}{1.0 - z}} \cdot x\right) \cdot \sqrt{\frac{y}{z} - \frac{t}{1.0 - z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r19284296 = x;
        double r19284297 = y;
        double r19284298 = z;
        double r19284299 = r19284297 / r19284298;
        double r19284300 = t;
        double r19284301 = 1.0;
        double r19284302 = r19284301 - r19284298;
        double r19284303 = r19284300 / r19284302;
        double r19284304 = r19284299 - r19284303;
        double r19284305 = r19284296 * r19284304;
        return r19284305;
}

double f(double x, double y, double z, double t) {
        double r19284306 = y;
        double r19284307 = z;
        double r19284308 = r19284306 / r19284307;
        double r19284309 = t;
        double r19284310 = 1.0;
        double r19284311 = r19284310 - r19284307;
        double r19284312 = r19284309 / r19284311;
        double r19284313 = r19284308 - r19284312;
        double r19284314 = -inf.0;
        bool r19284315 = r19284313 <= r19284314;
        double r19284316 = x;
        double r19284317 = r19284306 * r19284316;
        double r19284318 = r19284317 / r19284307;
        double r19284319 = -1.8815398856819596e-223;
        bool r19284320 = r19284313 <= r19284319;
        double r19284321 = cbrt(r19284312);
        double r19284322 = r19284321 * r19284321;
        double r19284323 = r19284321 * r19284322;
        double r19284324 = r19284308 - r19284323;
        double r19284325 = r19284324 * r19284316;
        double r19284326 = 5.632888446083138e-266;
        bool r19284327 = r19284313 <= r19284326;
        double r19284328 = -1.0;
        double r19284329 = r19284328 / r19284311;
        double r19284330 = 1.0;
        double r19284331 = r19284330 / r19284311;
        double r19284332 = r19284309 * r19284331;
        double r19284333 = fma(r19284329, r19284309, r19284332);
        double r19284334 = r19284316 * r19284333;
        double r19284335 = r19284316 / r19284307;
        double r19284336 = r19284310 / r19284307;
        double r19284337 = r19284316 * r19284309;
        double r19284338 = r19284337 / r19284307;
        double r19284339 = fma(r19284336, r19284338, r19284338);
        double r19284340 = fma(r19284335, r19284306, r19284339);
        double r19284341 = r19284334 + r19284340;
        double r19284342 = 2.4899172613549185e+301;
        bool r19284343 = r19284313 <= r19284342;
        double r19284344 = sqrt(r19284313);
        double r19284345 = r19284344 * r19284316;
        double r19284346 = r19284345 * r19284344;
        double r19284347 = r19284343 ? r19284346 : r19284318;
        double r19284348 = r19284327 ? r19284341 : r19284347;
        double r19284349 = r19284320 ? r19284325 : r19284348;
        double r19284350 = r19284315 ? r19284318 : r19284349;
        return r19284350;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target4.0
Herbie0.7
\[\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 4 regimes
  2. if (- (/ y z) (/ t (- 1.0 z))) < -inf.0 or 2.4899172613549185e+301 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 56.4

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1.0 - z}\right)\]
    2. Taylor expanded around 0 1.4

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}}\]

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < -1.8815398856819596e-223

    1. Initial program 0.2

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

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

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

    if -1.8815398856819596e-223 < (- (/ y z) (/ t (- 1.0 z))) < 5.632888446083138e-266

    1. Initial program 11.3

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

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

      \[\leadsto x \cdot \left(\frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} - t \cdot \frac{1}{1.0 - z}\right)\]
    5. Applied *-un-lft-identity11.4

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

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

      \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}, \frac{y}{\sqrt[3]{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)}\]
    8. Applied distribute-lft-in11.4

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}, \frac{y}{\sqrt[3]{z}}, -\frac{1}{1.0 - z} \cdot t\right) + x \cdot \mathsf{fma}\left(-\frac{1}{1.0 - z}, t, \frac{1}{1.0 - z} \cdot t\right)}\]
    9. Taylor expanded around inf 0.8

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

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

    if 5.632888446083138e-266 < (- (/ y z) (/ t (- 1.0 z))) < 2.4899172613549185e+301

    1. Initial program 0.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1.0 - z} = -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le -1.8815398856819596 \cdot 10^{-223}:\\ \;\;\;\;\left(\frac{y}{z} - \sqrt[3]{\frac{t}{1.0 - z}} \cdot \left(\sqrt[3]{\frac{t}{1.0 - z}} \cdot \sqrt[3]{\frac{t}{1.0 - z}}\right)\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 5.632888446083138 \cdot 10^{-266}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(\frac{-1}{1.0 - z}, t, t \cdot \frac{1}{1.0 - z}\right) + \mathsf{fma}\left(\frac{x}{z}, y, \mathsf{fma}\left(\frac{1.0}{z}, \frac{x \cdot t}{z}, \frac{x \cdot t}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1.0 - z} \le 2.4899172613549185 \cdot 10^{+301}:\\ \;\;\;\;\left(\sqrt{\frac{y}{z} - \frac{t}{1.0 - z}} \cdot x\right) \cdot \sqrt{\frac{y}{z} - \frac{t}{1.0 - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Reproduce

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