Average Error: 25.1 → 8.1
Time: 20.0s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6916256.2101914919912815093994140625:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{z}{t} \cdot \left(1 \cdot y\right) + \frac{\log 1}{t}\right)\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -6916256.2101914919912815093994140625:\\
\;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r299406 = x;
        double r299407 = 1.0;
        double r299408 = y;
        double r299409 = r299407 - r299408;
        double r299410 = z;
        double r299411 = exp(r299410);
        double r299412 = r299408 * r299411;
        double r299413 = r299409 + r299412;
        double r299414 = log(r299413);
        double r299415 = t;
        double r299416 = r299414 / r299415;
        double r299417 = r299406 - r299416;
        return r299417;
}

double f(double x, double y, double z, double t) {
        double r299418 = z;
        double r299419 = -6916256.210191492;
        bool r299420 = r299418 <= r299419;
        double r299421 = x;
        double r299422 = 1.0;
        double r299423 = y;
        double r299424 = r299422 - r299423;
        double r299425 = exp(r299418);
        double r299426 = r299423 * r299425;
        double r299427 = r299424 + r299426;
        double r299428 = log(r299427);
        double r299429 = 1.0;
        double r299430 = t;
        double r299431 = r299429 / r299430;
        double r299432 = r299428 * r299431;
        double r299433 = r299421 - r299432;
        double r299434 = r299418 / r299430;
        double r299435 = r299422 * r299423;
        double r299436 = r299434 * r299435;
        double r299437 = log(r299422);
        double r299438 = r299437 / r299430;
        double r299439 = r299436 + r299438;
        double r299440 = r299421 - r299439;
        double r299441 = r299420 ? r299433 : r299440;
        return r299441;
}

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.1
Target16.6
Herbie8.1
\[\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 < -6916256.210191492

    1. Initial program 11.7

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Simplified11.7

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

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

    if -6916256.210191492 < z

    1. Initial program 30.7

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Simplified30.7

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

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

      \[\leadsto x - \frac{\color{blue}{\log 1 + y \cdot \left(z \cdot 1 + \left(0.5 \cdot z\right) \cdot z\right)}}{t}\]
    5. Taylor expanded around 0 7.7

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

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

      \[\leadsto x - \left(\frac{z \cdot 1}{\color{blue}{t \cdot \frac{1}{y}}} + \frac{\log 1}{t}\right)\]
    9. Applied times-frac6.7

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

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

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

Reproduce

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

  :herbie-target
  (if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))

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