Average Error: 5.0 → 4.6
Time: 18.8s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;t \le -2.227422004855874146391385985611685572535 \cdot 10^{-75} \lor \neg \left(t \le 7.709782318648622879459717225518452107143 \cdot 10^{-38}\right):\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + \frac{x}{1 - z} \cdot \left(-t\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;t \le -2.227422004855874146391385985611685572535 \cdot 10^{-75} \lor \neg \left(t \le 7.709782318648622879459717225518452107143 \cdot 10^{-38}\right):\\
\;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \frac{t}{1 - z}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r277926 = x;
        double r277927 = y;
        double r277928 = z;
        double r277929 = r277927 / r277928;
        double r277930 = t;
        double r277931 = 1.0;
        double r277932 = r277931 - r277928;
        double r277933 = r277930 / r277932;
        double r277934 = r277929 - r277933;
        double r277935 = r277926 * r277934;
        return r277935;
}

double f(double x, double y, double z, double t) {
        double r277936 = t;
        double r277937 = -2.227422004855874e-75;
        bool r277938 = r277936 <= r277937;
        double r277939 = 7.709782318648623e-38;
        bool r277940 = r277936 <= r277939;
        double r277941 = !r277940;
        bool r277942 = r277938 || r277941;
        double r277943 = y;
        double r277944 = x;
        double r277945 = z;
        double r277946 = r277944 / r277945;
        double r277947 = r277943 * r277946;
        double r277948 = 1.0;
        double r277949 = r277948 - r277945;
        double r277950 = r277936 / r277949;
        double r277951 = r277944 * r277950;
        double r277952 = -r277951;
        double r277953 = r277947 + r277952;
        double r277954 = r277943 / r277945;
        double r277955 = r277954 * r277944;
        double r277956 = r277944 / r277949;
        double r277957 = -r277936;
        double r277958 = r277956 * r277957;
        double r277959 = r277955 + r277958;
        double r277960 = r277942 ? r277953 : r277959;
        return r277960;
}

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

Original5.0
Target4.4
Herbie4.6
\[\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 t < -2.227422004855874e-75 or 7.709782318648623e-38 < t

    1. Initial program 3.9

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

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

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

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

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

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

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

    if -2.227422004855874e-75 < t < 7.709782318648623e-38

    1. Initial program 6.4

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -2.227422004855874146391385985611685572535 \cdot 10^{-75} \lor \neg \left(t \le 7.709782318648622879459717225518452107143 \cdot 10^{-38}\right):\\ \;\;\;\;y \cdot \frac{x}{z} + \left(-x \cdot \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + \frac{x}{1 - z} \cdot \left(-t\right)\\ \end{array}\]

Reproduce

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