Average Error: 4.7 → 4.5
Time: 15.2s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le 5.365296890562927012540570559645221805139 \cdot 10^{-77}:\\ \;\;\;\;\frac{x \cdot y}{z} + \frac{x}{\sqrt{1 - z}} \cdot \frac{-t}{\sqrt{1 - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\frac{1 - z}{t}} + \frac{1}{\frac{\frac{z}{y}}{x}}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;z \le 5.365296890562927012540570559645221805139 \cdot 10^{-77}:\\
\;\;\;\;\frac{x \cdot y}{z} + \frac{x}{\sqrt{1 - z}} \cdot \frac{-t}{\sqrt{1 - z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-x}{\frac{1 - z}{t}} + \frac{1}{\frac{\frac{z}{y}}{x}}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r322710 = x;
        double r322711 = y;
        double r322712 = z;
        double r322713 = r322711 / r322712;
        double r322714 = t;
        double r322715 = 1.0;
        double r322716 = r322715 - r322712;
        double r322717 = r322714 / r322716;
        double r322718 = r322713 - r322717;
        double r322719 = r322710 * r322718;
        return r322719;
}

double f(double x, double y, double z, double t) {
        double r322720 = z;
        double r322721 = 5.365296890562927e-77;
        bool r322722 = r322720 <= r322721;
        double r322723 = x;
        double r322724 = y;
        double r322725 = r322723 * r322724;
        double r322726 = r322725 / r322720;
        double r322727 = 1.0;
        double r322728 = r322727 - r322720;
        double r322729 = sqrt(r322728);
        double r322730 = r322723 / r322729;
        double r322731 = t;
        double r322732 = -r322731;
        double r322733 = r322732 / r322729;
        double r322734 = r322730 * r322733;
        double r322735 = r322726 + r322734;
        double r322736 = -r322723;
        double r322737 = r322728 / r322731;
        double r322738 = r322736 / r322737;
        double r322739 = 1.0;
        double r322740 = r322720 / r322724;
        double r322741 = r322740 / r322723;
        double r322742 = r322739 / r322741;
        double r322743 = r322738 + r322742;
        double r322744 = r322722 ? r322735 : r322743;
        return r322744;
}

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.7
Target4.4
Herbie4.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 2 regimes
  2. if z < 5.365296890562927e-77

    1. Initial program 6.0

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

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

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

      \[\leadsto x \cdot \mathsf{fma}\left(y, \frac{1}{z}, \color{blue}{\frac{-t}{1 - z}}\right)\]
    6. Using strategy rm
    7. Applied fma-udef6.1

      \[\leadsto x \cdot \color{blue}{\left(y \cdot \frac{1}{z} + \frac{-t}{1 - z}\right)}\]
    8. Applied distribute-lft-in6.1

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + x \cdot \frac{-t}{1 - z}\]
    10. Simplified6.5

      \[\leadsto \frac{x \cdot y}{z} + \color{blue}{\frac{x \cdot \left(-t\right)}{1 - z}}\]
    11. Using strategy rm
    12. Applied add-sqr-sqrt6.6

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

      \[\leadsto \frac{x \cdot y}{z} + \color{blue}{\frac{x}{\sqrt{1 - z}} \cdot \frac{-t}{\sqrt{1 - z}}}\]

    if 5.365296890562927e-77 < z

    1. Initial program 2.3

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

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

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

      \[\leadsto x \cdot \mathsf{fma}\left(y, \frac{1}{z}, \color{blue}{\frac{-t}{1 - z}}\right)\]
    6. Using strategy rm
    7. Applied fma-udef2.3

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + x \cdot \frac{-t}{1 - z}\]
    10. Simplified8.6

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

      \[\leadsto \frac{x \cdot y}{z} + \frac{\color{blue}{-x \cdot t}}{1 - z}\]
    13. Applied distribute-frac-neg8.6

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

      \[\leadsto \frac{x \cdot y}{z} + \left(-\color{blue}{\frac{x}{\frac{1 - z}{t}}}\right)\]
    15. Using strategy rm
    16. Applied clear-num6.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le 5.365296890562927012540570559645221805139 \cdot 10^{-77}:\\ \;\;\;\;\frac{x \cdot y}{z} + \frac{x}{\sqrt{1 - z}} \cdot \frac{-t}{\sqrt{1 - z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\frac{1 - z}{t}} + \frac{1}{\frac{\frac{z}{y}}{x}}\\ \end{array}\]

Reproduce

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