Average Error: 4.8 → 0.5
Time: 16.6s
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} = -\infty:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-x\right) \cdot \frac{t}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -9.919168302961412809853444956495048310677 \cdot 10^{-197}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 2.753856498748946612709405774000811681652 \cdot 10^{-286}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \left(\frac{1}{z} + 1\right) \cdot \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 6.289758256242324172285873340578120865516 \cdot 10^{161}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-x\right) \cdot \frac{t}{1 - z}\\ \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} = -\infty:\\
\;\;\;\;\frac{x \cdot y}{z} + \left(-x\right) \cdot \frac{t}{1 - z}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r246290 = x;
        double r246291 = y;
        double r246292 = z;
        double r246293 = r246291 / r246292;
        double r246294 = t;
        double r246295 = 1.0;
        double r246296 = r246295 - r246292;
        double r246297 = r246294 / r246296;
        double r246298 = r246293 - r246297;
        double r246299 = r246290 * r246298;
        return r246299;
}

double f(double x, double y, double z, double t) {
        double r246300 = y;
        double r246301 = z;
        double r246302 = r246300 / r246301;
        double r246303 = t;
        double r246304 = 1.0;
        double r246305 = r246304 - r246301;
        double r246306 = r246303 / r246305;
        double r246307 = r246302 - r246306;
        double r246308 = -inf.0;
        bool r246309 = r246307 <= r246308;
        double r246310 = x;
        double r246311 = r246310 * r246300;
        double r246312 = r246311 / r246301;
        double r246313 = -r246310;
        double r246314 = r246313 * r246306;
        double r246315 = r246312 + r246314;
        double r246316 = -9.919168302961413e-197;
        bool r246317 = r246307 <= r246316;
        double r246318 = 1.0;
        double r246319 = r246318 / r246301;
        double r246320 = -r246306;
        double r246321 = fma(r246300, r246319, r246320);
        double r246322 = r246310 * r246321;
        double r246323 = 2.7538564987489466e-286;
        bool r246324 = r246307 <= r246323;
        double r246325 = r246310 / r246301;
        double r246326 = r246304 / r246301;
        double r246327 = r246326 + r246318;
        double r246328 = r246303 * r246310;
        double r246329 = r246328 / r246301;
        double r246330 = r246327 * r246329;
        double r246331 = fma(r246325, r246300, r246330);
        double r246332 = 6.289758256242324e+161;
        bool r246333 = r246307 <= r246332;
        double r246334 = r246333 ? r246322 : r246315;
        double r246335 = r246324 ? r246331 : r246334;
        double r246336 = r246317 ? r246322 : r246335;
        double r246337 = r246309 ? r246315 : r246336;
        return r246337;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.8
Target4.3
Herbie0.5
\[\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 (- (/ y z) (/ t (- 1.0 z))) < -inf.0 or 6.289758256242324e+161 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 23.9

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

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \frac{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}{\left(\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}\right) \cdot \sqrt[3]{1 - z}}\right)\]
    5. Applied times-frac24.2

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{1 - z}}}\right)\]
    6. Using strategy rm
    7. Applied sub-neg24.2

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{1 - z}}\right)\right)}\]
    8. Applied distribute-rgt-in24.2

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + \left(-\frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{\sqrt[3]{1 - z} \cdot \sqrt[3]{1 - z}} \cdot \frac{\sqrt[3]{t}}{\sqrt[3]{1 - z}}\right) \cdot x}\]
    9. Simplified1.6

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

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

    if -inf.0 < (- (/ y z) (/ t (- 1.0 z))) < -9.919168302961413e-197 or 2.7538564987489466e-286 < (- (/ y z) (/ t (- 1.0 z))) < 6.289758256242324e+161

    1. Initial program 0.2

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

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

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

    if -9.919168302961413e-197 < (- (/ y z) (/ t (- 1.0 z))) < 2.7538564987489466e-286

    1. Initial program 12.0

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

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

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)}\]
    5. Taylor expanded around inf 0.7

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)}\]
    6. Simplified0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} = -\infty:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-x\right) \cdot \frac{t}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le -9.919168302961412809853444956495048310677 \cdot 10^{-197}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 2.753856498748946612709405774000811681652 \cdot 10^{-286}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \left(\frac{1}{z} + 1\right) \cdot \frac{t \cdot x}{z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \le 6.289758256242324172285873340578120865516 \cdot 10^{161}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(-x\right) \cdot \frac{t}{1 - z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019305 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1 z)))) -7.62322630331204244e-196) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 1.41339449277023022e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z)))))))

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