Average Error: 4.7 → 5.0
Time: 13.1s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;t \le -2.692629455353721771426919610288423852643 \cdot 10^{-296} \lor \neg \left(t \le 3.577593254447571090065528336385446638853 \cdot 10^{-116}\right):\\ \;\;\;\;\frac{1}{z} \cdot \left(y \cdot x\right) + \left(-\frac{x}{\frac{1 - z}{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{y}}{x}} + \left(-\frac{x \cdot t}{1 - z}\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;t \le -2.692629455353721771426919610288423852643 \cdot 10^{-296} \lor \neg \left(t \le 3.577593254447571090065528336385446638853 \cdot 10^{-116}\right):\\
\;\;\;\;\frac{1}{z} \cdot \left(y \cdot x\right) + \left(-\frac{x}{\frac{1 - z}{t}}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r386961 = x;
        double r386962 = y;
        double r386963 = z;
        double r386964 = r386962 / r386963;
        double r386965 = t;
        double r386966 = 1.0;
        double r386967 = r386966 - r386963;
        double r386968 = r386965 / r386967;
        double r386969 = r386964 - r386968;
        double r386970 = r386961 * r386969;
        return r386970;
}

double f(double x, double y, double z, double t) {
        double r386971 = t;
        double r386972 = -2.692629455353722e-296;
        bool r386973 = r386971 <= r386972;
        double r386974 = 3.577593254447571e-116;
        bool r386975 = r386971 <= r386974;
        double r386976 = !r386975;
        bool r386977 = r386973 || r386976;
        double r386978 = 1.0;
        double r386979 = z;
        double r386980 = r386978 / r386979;
        double r386981 = y;
        double r386982 = x;
        double r386983 = r386981 * r386982;
        double r386984 = r386980 * r386983;
        double r386985 = 1.0;
        double r386986 = r386985 - r386979;
        double r386987 = r386986 / r386971;
        double r386988 = r386982 / r386987;
        double r386989 = -r386988;
        double r386990 = r386984 + r386989;
        double r386991 = r386979 / r386981;
        double r386992 = r386991 / r386982;
        double r386993 = r386978 / r386992;
        double r386994 = r386982 * r386971;
        double r386995 = r386994 / r386986;
        double r386996 = -r386995;
        double r386997 = r386993 + r386996;
        double r386998 = r386977 ? r386990 : r386997;
        return r386998;
}

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
Herbie5.0
\[\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.692629455353722e-296 or 3.577593254447571e-116 < t

    1. Initial program 4.6

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

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

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\frac{-t \cdot x}{1 - z}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity7.4

      \[\leadsto \frac{y \cdot x}{z} + \frac{-t \cdot x}{\color{blue}{1 \cdot \left(1 - z\right)}}\]
    9. Applied neg-mul-17.4

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\frac{-1}{1} \cdot \frac{t \cdot x}{1 - z}}\]
    11. Simplified7.4

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{-1} \cdot \frac{t \cdot x}{1 - z}\]
    12. Simplified5.0

      \[\leadsto \frac{y \cdot x}{z} + -1 \cdot \color{blue}{\frac{x}{\frac{1 - z}{t}}}\]
    13. Using strategy rm
    14. Applied div-inv5.1

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

    if -2.692629455353722e-296 < t < 3.577593254447571e-116

    1. Initial program 5.1

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

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

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

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

      \[\leadsto \frac{y \cdot x}{z} + \color{blue}{\frac{-t \cdot x}{1 - z}}\]
    7. Using strategy rm
    8. Applied clear-num6.9

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{y \cdot x}}} + \frac{-t \cdot x}{1 - z}\]
    9. Simplified4.8

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

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

Reproduce

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