Average Error: 25.4 → 8.0
Time: 8.3s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;e^{z} \le 0.99999622539885324:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \frac{1}{\frac{\frac{t}{z}}{y}} + \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}\;e^{z} \le 0.99999622539885324:\\
\;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r263327 = x;
        double r263328 = 1.0;
        double r263329 = y;
        double r263330 = r263328 - r263329;
        double r263331 = z;
        double r263332 = exp(r263331);
        double r263333 = r263329 * r263332;
        double r263334 = r263330 + r263333;
        double r263335 = log(r263334);
        double r263336 = t;
        double r263337 = r263335 / r263336;
        double r263338 = r263327 - r263337;
        return r263338;
}

double f(double x, double y, double z, double t) {
        double r263339 = z;
        double r263340 = exp(r263339);
        double r263341 = 0.9999962253988532;
        bool r263342 = r263340 <= r263341;
        double r263343 = x;
        double r263344 = 1.0;
        double r263345 = y;
        double r263346 = r263344 - r263345;
        double r263347 = r263345 * r263340;
        double r263348 = r263346 + r263347;
        double r263349 = log(r263348);
        double r263350 = 1.0;
        double r263351 = t;
        double r263352 = r263350 / r263351;
        double r263353 = r263349 * r263352;
        double r263354 = r263343 - r263353;
        double r263355 = r263351 / r263339;
        double r263356 = r263355 / r263345;
        double r263357 = r263350 / r263356;
        double r263358 = r263344 * r263357;
        double r263359 = log(r263344);
        double r263360 = r263359 / r263351;
        double r263361 = r263358 + r263360;
        double r263362 = r263343 - r263361;
        double r263363 = r263342 ? r263354 : r263362;
        return r263363;
}

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.0
\[\begin{array}{l} \mathbf{if}\;z \lt -2.88746230882079466 \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 (exp z) < 0.9999962253988532

    1. Initial program 11.3

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

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

    if 0.9999962253988532 < (exp z)

    1. Initial program 31.4

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Taylor expanded around 0 7.1

      \[\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}\]
    3. Simplified7.1

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

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

      \[\leadsto x - \left(1 \cdot \color{blue}{\frac{1}{\frac{t}{z \cdot y}}} + \frac{\log 1}{t}\right)\]
    7. Using strategy rm
    8. Applied associate-/r*6.5

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

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

Reproduce

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