Average Error: 4.6 → 4.2
Time: 26.2s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;t \le -4.043646312429584731783001984190946143985 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{elif}\;t \le -5.644334214871667133940564901624960200236 \cdot 10^{-258}:\\ \;\;\;\;\frac{y}{z} \cdot x + \left(-\frac{x \cdot t}{1 - z}\right)\\ \mathbf{elif}\;t \le 3.337564406318943742689084959731461824083 \cdot 10^{-259}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + \frac{-\sqrt{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \left(\frac{\sqrt{t}}{\sqrt[3]{1 - z}} \cdot x\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;t \le -4.043646312429584731783001984190946143985 \cdot 10^{-60}:\\
\;\;\;\;y \cdot \frac{x}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\

\mathbf{elif}\;t \le -5.644334214871667133940564901624960200236 \cdot 10^{-258}:\\
\;\;\;\;\frac{y}{z} \cdot x + \left(-\frac{x \cdot t}{1 - z}\right)\\

\mathbf{elif}\;t \le 3.337564406318943742689084959731461824083 \cdot 10^{-259}:\\
\;\;\;\;y \cdot \frac{x}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x + \frac{-\sqrt{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \left(\frac{\sqrt{t}}{\sqrt[3]{1 - z}} \cdot x\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r23346266 = x;
        double r23346267 = y;
        double r23346268 = z;
        double r23346269 = r23346267 / r23346268;
        double r23346270 = t;
        double r23346271 = 1.0;
        double r23346272 = r23346271 - r23346268;
        double r23346273 = r23346270 / r23346272;
        double r23346274 = r23346269 - r23346273;
        double r23346275 = r23346266 * r23346274;
        return r23346275;
}

double f(double x, double y, double z, double t) {
        double r23346276 = t;
        double r23346277 = -4.043646312429585e-60;
        bool r23346278 = r23346276 <= r23346277;
        double r23346279 = y;
        double r23346280 = x;
        double r23346281 = z;
        double r23346282 = r23346280 / r23346281;
        double r23346283 = r23346279 * r23346282;
        double r23346284 = 1.0;
        double r23346285 = r23346284 - r23346281;
        double r23346286 = r23346276 / r23346285;
        double r23346287 = -r23346286;
        double r23346288 = r23346287 * r23346280;
        double r23346289 = r23346283 + r23346288;
        double r23346290 = -5.644334214871667e-258;
        bool r23346291 = r23346276 <= r23346290;
        double r23346292 = r23346279 / r23346281;
        double r23346293 = r23346292 * r23346280;
        double r23346294 = r23346280 * r23346276;
        double r23346295 = r23346294 / r23346285;
        double r23346296 = -r23346295;
        double r23346297 = r23346293 + r23346296;
        double r23346298 = 3.337564406318944e-259;
        bool r23346299 = r23346276 <= r23346298;
        double r23346300 = sqrt(r23346276);
        double r23346301 = -r23346300;
        double r23346302 = cbrt(r23346285);
        double r23346303 = r23346302 * r23346302;
        double r23346304 = r23346301 / r23346303;
        double r23346305 = r23346300 / r23346302;
        double r23346306 = r23346305 * r23346280;
        double r23346307 = r23346304 * r23346306;
        double r23346308 = r23346293 + r23346307;
        double r23346309 = r23346299 ? r23346289 : r23346308;
        double r23346310 = r23346291 ? r23346297 : r23346309;
        double r23346311 = r23346278 ? r23346289 : r23346310;
        return r23346311;
}

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.6
Target4.1
Herbie4.2
\[\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 3 regimes
  2. if t < -4.043646312429585e-60 or -5.644334214871667e-258 < t < 3.337564406318944e-259

    1. Initial program 4.5

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-rgt-in4.5

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + \left(-\frac{t}{1 - z}\right) \cdot x}\]
    5. Using strategy rm
    6. Applied div-inv4.5

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{z}\right)} \cdot x + \left(-\frac{t}{1 - z}\right) \cdot x\]
    7. Applied associate-*l*4.2

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

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

    if -4.043646312429585e-60 < t < -5.644334214871667e-258

    1. Initial program 5.0

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied sub-neg5.0

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-rgt-in5.0

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + \left(-\frac{t}{1 - z}\right) \cdot x}\]
    5. Using strategy rm
    6. Applied distribute-neg-frac5.0

      \[\leadsto \frac{y}{z} \cdot x + \color{blue}{\frac{-t}{1 - z}} \cdot x\]
    7. Applied associate-*l/3.8

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

    if 3.337564406318944e-259 < t

    1. Initial program 4.7

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

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

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + \left(-\frac{t}{1 - z}\right) \cdot x}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt4.9

      \[\leadsto \frac{y}{z} \cdot x + \left(-\frac{t}{\color{blue}{\left(\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}\right) \cdot \sqrt[3]{1 - z}}}\right) \cdot x\]
    7. Applied add-sqr-sqrt5.0

      \[\leadsto \frac{y}{z} \cdot x + \left(-\frac{\color{blue}{\sqrt{t} \cdot \sqrt{t}}}{\left(\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}\right) \cdot \sqrt[3]{1 - z}}\right) \cdot x\]
    8. Applied times-frac5.0

      \[\leadsto \frac{y}{z} \cdot x + \left(-\color{blue}{\frac{\sqrt{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \frac{\sqrt{t}}{\sqrt[3]{1 - z}}}\right) \cdot x\]
    9. Applied distribute-rgt-neg-in5.0

      \[\leadsto \frac{y}{z} \cdot x + \color{blue}{\left(\frac{\sqrt{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \left(-\frac{\sqrt{t}}{\sqrt[3]{1 - z}}\right)\right)} \cdot x\]
    10. Applied associate-*l*4.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -4.043646312429584731783001984190946143985 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{elif}\;t \le -5.644334214871667133940564901624960200236 \cdot 10^{-258}:\\ \;\;\;\;\frac{y}{z} \cdot x + \left(-\frac{x \cdot t}{1 - z}\right)\\ \mathbf{elif}\;t \le 3.337564406318943742689084959731461824083 \cdot 10^{-259}:\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-\frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + \frac{-\sqrt{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \left(\frac{\sqrt{t}}{\sqrt[3]{1 - z}} \cdot x\right)\\ \end{array}\]

Reproduce

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