Average Error: 24.6 → 8.4
Time: 24.9s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -45345376.066928721964359283447265625:\\ \;\;\;\;x - \frac{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}{t}\\ \mathbf{elif}\;z \le -7.24128778827560918094582322562071502946 \cdot 10^{-136}:\\ \;\;\;\;x - \frac{\log \left(1 - \left(-\left(y \cdot \left({z}^{2} \cdot \left(\frac{1}{2} + z \cdot \frac{1}{6}\right)\right) + z \cdot y\right)\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -45345376.066928721964359283447265625:\\
\;\;\;\;x - \frac{\log \left(1 - y \cdot \left(1 - e^{z}\right)\right)}{t}\\

\mathbf{elif}\;z \le -7.24128778827560918094582322562071502946 \cdot 10^{-136}:\\
\;\;\;\;x - \frac{\log \left(1 - \left(-\left(y \cdot \left({z}^{2} \cdot \left(\frac{1}{2} + z \cdot \frac{1}{6}\right)\right) + z \cdot y\right)\right)\right)}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r252490 = x;
        double r252491 = 1.0;
        double r252492 = y;
        double r252493 = r252491 - r252492;
        double r252494 = z;
        double r252495 = exp(r252494);
        double r252496 = r252492 * r252495;
        double r252497 = r252493 + r252496;
        double r252498 = log(r252497);
        double r252499 = t;
        double r252500 = r252498 / r252499;
        double r252501 = r252490 - r252500;
        return r252501;
}

double f(double x, double y, double z, double t) {
        double r252502 = z;
        double r252503 = -45345376.06692872;
        bool r252504 = r252502 <= r252503;
        double r252505 = x;
        double r252506 = 1.0;
        double r252507 = y;
        double r252508 = 1.0;
        double r252509 = exp(r252502);
        double r252510 = r252508 - r252509;
        double r252511 = r252507 * r252510;
        double r252512 = r252506 - r252511;
        double r252513 = log(r252512);
        double r252514 = t;
        double r252515 = r252513 / r252514;
        double r252516 = r252505 - r252515;
        double r252517 = -7.241287788275609e-136;
        bool r252518 = r252502 <= r252517;
        double r252519 = 2.0;
        double r252520 = pow(r252502, r252519);
        double r252521 = 0.5;
        double r252522 = 0.16666666666666666;
        double r252523 = r252502 * r252522;
        double r252524 = r252521 + r252523;
        double r252525 = r252520 * r252524;
        double r252526 = r252507 * r252525;
        double r252527 = r252502 * r252507;
        double r252528 = r252526 + r252527;
        double r252529 = -r252528;
        double r252530 = r252506 - r252529;
        double r252531 = log(r252530);
        double r252532 = r252531 / r252514;
        double r252533 = r252505 - r252532;
        double r252534 = log(r252506);
        double r252535 = 0.5;
        double r252536 = r252535 * r252520;
        double r252537 = r252506 * r252502;
        double r252538 = r252536 + r252537;
        double r252539 = r252507 * r252538;
        double r252540 = r252534 + r252539;
        double r252541 = r252540 / r252514;
        double r252542 = r252505 - r252541;
        double r252543 = r252518 ? r252533 : r252542;
        double r252544 = r252504 ? r252516 : r252543;
        return r252544;
}

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

Original24.6
Target16.1
Herbie8.4
\[\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 3 regimes
  2. if z < -45345376.06692872

    1. Initial program 11.4

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

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

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

    if -45345376.06692872 < z < -7.241287788275609e-136

    1. Initial program 28.0

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

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

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

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

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

    if -7.241287788275609e-136 < z

    1. Initial program 30.4

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019323 
(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.8874623088207947e+119) (- (- 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)))