Average Error: 24.6 → 8.7
Time: 9.2s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.45841499849459182 \cdot 10^{-14}:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;z \le 2.8024882738168282 \cdot 10^{-74}:\\ \;\;\;\;x - \frac{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}{t}\\ \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.45841499849459182 \cdot 10^{-14}:\\
\;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\

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

\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 r820284 = x;
        double r820285 = 1.0;
        double r820286 = y;
        double r820287 = r820285 - r820286;
        double r820288 = z;
        double r820289 = exp(r820288);
        double r820290 = r820286 * r820289;
        double r820291 = r820287 + r820290;
        double r820292 = log(r820291);
        double r820293 = t;
        double r820294 = r820292 / r820293;
        double r820295 = r820284 - r820294;
        return r820295;
}

double f(double x, double y, double z, double t) {
        double r820296 = z;
        double r820297 = -5.458414998494592e-14;
        bool r820298 = r820296 <= r820297;
        double r820299 = x;
        double r820300 = 1.0;
        double r820301 = y;
        double r820302 = r820300 - r820301;
        double r820303 = exp(r820296);
        double r820304 = r820301 * r820303;
        double r820305 = r820302 + r820304;
        double r820306 = log(r820305);
        double r820307 = 1.0;
        double r820308 = t;
        double r820309 = r820307 / r820308;
        double r820310 = r820306 * r820309;
        double r820311 = r820299 - r820310;
        double r820312 = 2.802488273816828e-74;
        bool r820313 = r820296 <= r820312;
        double r820314 = log(r820300);
        double r820315 = 0.5;
        double r820316 = 2.0;
        double r820317 = pow(r820296, r820316);
        double r820318 = r820315 * r820317;
        double r820319 = r820300 * r820296;
        double r820320 = r820318 + r820319;
        double r820321 = r820301 * r820320;
        double r820322 = r820314 + r820321;
        double r820323 = r820322 / r820308;
        double r820324 = r820299 - r820323;
        double r820325 = 0.5;
        double r820326 = r820325 * r820317;
        double r820327 = r820326 + r820296;
        double r820328 = r820301 * r820327;
        double r820329 = r820300 + r820328;
        double r820330 = log(r820329);
        double r820331 = r820330 / r820308;
        double r820332 = r820299 - r820331;
        double r820333 = r820313 ? r820324 : r820332;
        double r820334 = r820298 ? r820311 : r820333;
        return r820334;
}

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.3
Herbie8.7
\[\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 < -5.458414998494592e-14

    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 div-inv11.4

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

    if -5.458414998494592e-14 < z < 2.802488273816828e-74

    1. Initial program 30.9

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

      \[\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. Simplified6.5

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

    if 2.802488273816828e-74 < z

    1. Initial program 29.8

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

      \[\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. Simplified14.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.45841499849459182 \cdot 10^{-14}:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;z \le 2.8024882738168282 \cdot 10^{-74}:\\ \;\;\;\;x - \frac{\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)}{t}\\ \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 2020065 
(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)))