Average Error: 24.8 → 8.3
Time: 9.5s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.050049854843210856672648667586855708578 \cdot 10^{-6}:\\ \;\;\;\;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.826438159913990508737942027076897606014 \cdot 10^{-113}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{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 -5.050049854843210856672648667586855708578 \cdot 10^{-6}:\\
\;\;\;\;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.826438159913990508737942027076897606014 \cdot 10^{-113}:\\
\;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{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 r401341 = x;
        double r401342 = 1.0;
        double r401343 = y;
        double r401344 = r401342 - r401343;
        double r401345 = z;
        double r401346 = exp(r401345);
        double r401347 = r401343 * r401346;
        double r401348 = r401344 + r401347;
        double r401349 = log(r401348);
        double r401350 = t;
        double r401351 = r401349 / r401350;
        double r401352 = r401341 - r401351;
        return r401352;
}

double f(double x, double y, double z, double t) {
        double r401353 = z;
        double r401354 = -5.050049854843211e-06;
        bool r401355 = r401353 <= r401354;
        double r401356 = x;
        double r401357 = 1.0;
        double r401358 = y;
        double r401359 = r401357 - r401358;
        double r401360 = exp(r401353);
        double r401361 = r401358 * r401360;
        double r401362 = cbrt(r401361);
        double r401363 = r401362 * r401362;
        double r401364 = r401363 * r401362;
        double r401365 = r401359 + r401364;
        double r401366 = log(r401365);
        double r401367 = t;
        double r401368 = r401366 / r401367;
        double r401369 = r401356 - r401368;
        double r401370 = 1.8264381599139905e-113;
        bool r401371 = r401353 <= r401370;
        double r401372 = r401353 * r401358;
        double r401373 = r401372 / r401367;
        double r401374 = r401357 * r401373;
        double r401375 = log(r401357);
        double r401376 = r401375 / r401367;
        double r401377 = 0.5;
        double r401378 = 2.0;
        double r401379 = pow(r401353, r401378);
        double r401380 = r401379 * r401358;
        double r401381 = r401380 / r401367;
        double r401382 = r401377 * r401381;
        double r401383 = r401376 + r401382;
        double r401384 = r401374 + r401383;
        double r401385 = r401356 - r401384;
        double r401386 = 0.5;
        double r401387 = r401386 * r401379;
        double r401388 = r401387 + r401353;
        double r401389 = r401358 * r401388;
        double r401390 = r401357 + r401389;
        double r401391 = log(r401390);
        double r401392 = r401391 / r401367;
        double r401393 = r401356 - r401392;
        double r401394 = r401371 ? r401385 : r401393;
        double r401395 = r401355 ? r401369 : r401394;
        return r401395;
}

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.8
Target15.8
Herbie8.3
\[\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 < -5.050049854843211e-06

    1. Initial program 11.9

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

      \[\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 -5.050049854843211e-06 < z < 1.8264381599139905e-113

    1. Initial program 30.6

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

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

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

      \[\leadsto x - \frac{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}\]
    6. Applied *-un-lft-identity5.9

      \[\leadsto x - \frac{\color{blue}{1 \cdot \left(\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)\right)}}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}\]
    7. Applied times-frac5.9

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

      \[\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)}\]

    if 1.8264381599139905e-113 < z

    1. Initial program 28.7

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

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

      \[\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 simplification8.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.050049854843210856672648667586855708578 \cdot 10^{-6}:\\ \;\;\;\;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.826438159913990508737942027076897606014 \cdot 10^{-113}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \left(\frac{\log 1}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{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 2019353 
(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)))