Average Error: 25.4 → 8.6
Time: 23.4s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -0.3115017031960372051457852649036794900894:\\ \;\;\;\;x - \frac{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{t}{y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right) + \log 1}}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -0.3115017031960372051457852649036794900894:\\
\;\;\;\;x - \frac{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r891927 = x;
        double r891928 = 1.0;
        double r891929 = y;
        double r891930 = r891928 - r891929;
        double r891931 = z;
        double r891932 = exp(r891931);
        double r891933 = r891929 * r891932;
        double r891934 = r891930 + r891933;
        double r891935 = log(r891934);
        double r891936 = t;
        double r891937 = r891935 / r891936;
        double r891938 = r891927 - r891937;
        return r891938;
}

double f(double x, double y, double z, double t) {
        double r891939 = z;
        double r891940 = -0.3115017031960372;
        bool r891941 = r891939 <= r891940;
        double r891942 = x;
        double r891943 = 1.0;
        double r891944 = y;
        double r891945 = 1.0;
        double r891946 = exp(r891939);
        double r891947 = r891945 - r891946;
        double r891948 = r891944 * r891947;
        double r891949 = r891943 - r891948;
        double r891950 = log(r891949);
        double r891951 = t;
        double r891952 = r891950 / r891951;
        double r891953 = r891942 - r891952;
        double r891954 = 0.5;
        double r891955 = 2.0;
        double r891956 = pow(r891939, r891955);
        double r891957 = r891954 * r891956;
        double r891958 = r891943 * r891939;
        double r891959 = r891957 + r891958;
        double r891960 = r891944 * r891959;
        double r891961 = log(r891943);
        double r891962 = r891960 + r891961;
        double r891963 = r891951 / r891962;
        double r891964 = r891945 / r891963;
        double r891965 = r891942 - r891964;
        double r891966 = r891941 ? r891953 : r891965;
        return r891966;
}

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

Original25.4
Target16.5
Herbie8.6
\[\begin{array}{l} \mathbf{if}\;z \lt -2.887462308820794658905265984545350618896 \cdot 10^{119}:\\ \;\;\;\;\left(x - \frac{\frac{-0.5}{y \cdot t}}{z \cdot z}\right) - \frac{-0.5}{y \cdot t} \cdot \frac{\frac{2}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -0.3115017031960372

    1. Initial program 10.9

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied associate-+l-10.9

      \[\leadsto x - \frac{\log \color{blue}{\left(1 - \left(y - y \cdot e^{z}\right)\right)}}{t}\]
    4. Simplified10.9

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

    if -0.3115017031960372 < z

    1. Initial program 31.3

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied associate-+l-16.8

      \[\leadsto x - \frac{\log \color{blue}{\left(1 - \left(y - y \cdot e^{z}\right)\right)}}{t}\]
    4. Simplified16.7

      \[\leadsto x - \frac{\log \left(1 - \color{blue}{y \cdot \left(1 - e^{z}\right)}\right)}{t}\]
    5. Using strategy rm
    6. Applied clear-num16.7

      \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}}}\]
    7. Taylor expanded around 0 7.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -0.3115017031960372051457852649036794900894:\\ \;\;\;\;x - \frac{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{t}{y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right) + \log 1}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 
(FPCore (x y z t)
  :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
  :precision binary64

  :herbie-target
  (if (< z -2.88746230882079466e119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2 z) (* z z)))) (- x (/ (log (+ 1 (* z y))) t)))

  (- x (/ (log (+ (- 1 y) (* y (exp z)))) t)))