Average Error: 25.3 → 8.5
Time: 25.2s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.788149422936711126217649570543650854038 \cdot 10^{-10}:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;z \le 1.548199489295338911120653686915655113605 \cdot 10^{-142}:\\ \;\;\;\;x - \frac{\log 1 + \left(\left(z \cdot 0.5\right) \cdot z + 1 \cdot z\right) \cdot y}{t}\\ \mathbf{elif}\;z \le 4.70552617509855223204263570258364278042 \cdot 10^{-18}:\\ \;\;\;\;x - \frac{\log \left(\left(1 + y \cdot z\right) + \left(\left(z \cdot z\right) \cdot y\right) \cdot \frac{1}{2}\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{\left(z \cdot 0.5\right) \cdot z}{\frac{t}{y}} + \frac{1 \cdot z}{\frac{t}{y}}\right)\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -1.788149422936711126217649570543650854038 \cdot 10^{-10}:\\
\;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\

\mathbf{elif}\;z \le 1.548199489295338911120653686915655113605 \cdot 10^{-142}:\\
\;\;\;\;x - \frac{\log 1 + \left(\left(z \cdot 0.5\right) \cdot z + 1 \cdot z\right) \cdot y}{t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r223485 = x;
        double r223486 = 1.0;
        double r223487 = y;
        double r223488 = r223486 - r223487;
        double r223489 = z;
        double r223490 = exp(r223489);
        double r223491 = r223487 * r223490;
        double r223492 = r223488 + r223491;
        double r223493 = log(r223492);
        double r223494 = t;
        double r223495 = r223493 / r223494;
        double r223496 = r223485 - r223495;
        return r223496;
}

double f(double x, double y, double z, double t) {
        double r223497 = z;
        double r223498 = -1.788149422936711e-10;
        bool r223499 = r223497 <= r223498;
        double r223500 = x;
        double r223501 = 1.0;
        double r223502 = y;
        double r223503 = r223501 - r223502;
        double r223504 = exp(r223497);
        double r223505 = r223502 * r223504;
        double r223506 = r223503 + r223505;
        double r223507 = log(r223506);
        double r223508 = 1.0;
        double r223509 = t;
        double r223510 = r223508 / r223509;
        double r223511 = r223507 * r223510;
        double r223512 = r223500 - r223511;
        double r223513 = 1.548199489295339e-142;
        bool r223514 = r223497 <= r223513;
        double r223515 = log(r223501);
        double r223516 = 0.5;
        double r223517 = r223497 * r223516;
        double r223518 = r223517 * r223497;
        double r223519 = r223501 * r223497;
        double r223520 = r223518 + r223519;
        double r223521 = r223520 * r223502;
        double r223522 = r223515 + r223521;
        double r223523 = r223522 / r223509;
        double r223524 = r223500 - r223523;
        double r223525 = 4.705526175098552e-18;
        bool r223526 = r223497 <= r223525;
        double r223527 = r223502 * r223497;
        double r223528 = r223501 + r223527;
        double r223529 = r223497 * r223497;
        double r223530 = r223529 * r223502;
        double r223531 = 0.5;
        double r223532 = r223530 * r223531;
        double r223533 = r223528 + r223532;
        double r223534 = log(r223533);
        double r223535 = r223534 / r223509;
        double r223536 = r223500 - r223535;
        double r223537 = r223509 / r223502;
        double r223538 = r223518 / r223537;
        double r223539 = r223519 / r223537;
        double r223540 = r223538 + r223539;
        double r223541 = r223500 - r223540;
        double r223542 = r223526 ? r223536 : r223541;
        double r223543 = r223514 ? r223524 : r223542;
        double r223544 = r223499 ? r223512 : r223543;
        return r223544;
}

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.3
Target16.1
Herbie8.5
\[\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 4 regimes
  2. if z < -1.788149422936711e-10

    1. Initial program 11.1

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

      \[\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.1

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

    if -1.788149422936711e-10 < z < 1.548199489295339e-142

    1. Initial program 31.9

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

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

      \[\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. Simplified5.8

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

    if 1.548199489295339e-142 < z < 4.705526175098552e-18

    1. Initial program 31.5

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

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

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

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

    if 4.705526175098552e-18 < z

    1. Initial program 24.3

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

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

      \[\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. Simplified20.0

      \[\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 inf 20.0

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

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

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

Reproduce

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