Average Error: 25.0 → 9.1
Time: 7.2s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.88873909658542886 \cdot 10^{-22}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 1.5385876821971491 \cdot 10^{-106}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{\log \left(e^{{z}^{2} \cdot y}\right)}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\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 -2.88873909658542886 \cdot 10^{-22}:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r309316 = x;
        double r309317 = 1.0;
        double r309318 = y;
        double r309319 = r309317 - r309318;
        double r309320 = z;
        double r309321 = exp(r309320);
        double r309322 = r309318 * r309321;
        double r309323 = r309319 + r309322;
        double r309324 = log(r309323);
        double r309325 = t;
        double r309326 = r309324 / r309325;
        double r309327 = r309316 - r309326;
        return r309327;
}

double f(double x, double y, double z, double t) {
        double r309328 = z;
        double r309329 = -2.888739096585429e-22;
        bool r309330 = r309328 <= r309329;
        double r309331 = x;
        double r309332 = 1.0;
        double r309333 = y;
        double r309334 = r309332 - r309333;
        double r309335 = exp(r309328);
        double r309336 = r309333 * r309335;
        double r309337 = cbrt(r309336);
        double r309338 = r309337 * r309337;
        double r309339 = r309338 * r309337;
        double r309340 = r309334 + r309339;
        double r309341 = log(r309340);
        double r309342 = t;
        double r309343 = r309341 / r309342;
        double r309344 = r309331 - r309343;
        double r309345 = 1.538587682197149e-106;
        bool r309346 = r309328 <= r309345;
        double r309347 = r309328 * r309333;
        double r309348 = r309347 / r309342;
        double r309349 = r309332 * r309348;
        double r309350 = log(r309332);
        double r309351 = r309350 / r309342;
        double r309352 = 0.5;
        double r309353 = 2.0;
        double r309354 = pow(r309328, r309353);
        double r309355 = r309354 * r309333;
        double r309356 = exp(r309355);
        double r309357 = log(r309356);
        double r309358 = r309357 / r309342;
        double r309359 = r309352 * r309358;
        double r309360 = r309351 + r309359;
        double r309361 = r309349 + r309360;
        double r309362 = r309331 - r309361;
        double r309363 = 0.5;
        double r309364 = r309363 * r309354;
        double r309365 = r309364 + r309328;
        double r309366 = r309333 * r309365;
        double r309367 = r309332 + r309366;
        double r309368 = log(r309367);
        double r309369 = r309368 / r309342;
        double r309370 = r309331 - r309369;
        double r309371 = r309346 ? r309362 : r309370;
        double r309372 = r309330 ? r309344 : r309371;
        return r309372;
}

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.0
Target16.2
Herbie9.1
\[\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 3 regimes
  2. if z < -2.888739096585429e-22

    1. Initial program 12.5

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

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

    if -2.888739096585429e-22 < z < 1.538587682197149e-106

    1. Initial program 31.3

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

      \[\leadsto x - \color{blue}{\left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)}\]
    3. Using strategy rm
    4. Applied add-log-exp6.4

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

    if 1.538587682197149e-106 < z

    1. Initial program 29.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.88873909658542886 \cdot 10^{-22}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right) \cdot \sqrt[3]{y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 1.5385876821971491 \cdot 10^{-106}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{\log \left(e^{{z}^{2} \cdot y}\right)}{t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{2} \cdot {z}^{2} + z\right)\right)}{t}\\ \end{array}\]

Reproduce

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