Average Error: 25.6 → 9.2
Time: 24.0s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.027925937619608113800553059516376490686 \cdot 10^{-16}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 9.201792392959989263626906567590577352864 \cdot 10^{-201}:\\ \;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \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 -1.027925937619608113800553059516376490686 \cdot 10^{-16}:\\
\;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\

\mathbf{elif}\;z \le 9.201792392959989263626906567590577352864 \cdot 10^{-201}:\\
\;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \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 r181309 = x;
        double r181310 = 1.0;
        double r181311 = y;
        double r181312 = r181310 - r181311;
        double r181313 = z;
        double r181314 = exp(r181313);
        double r181315 = r181311 * r181314;
        double r181316 = r181312 + r181315;
        double r181317 = log(r181316);
        double r181318 = t;
        double r181319 = r181317 / r181318;
        double r181320 = r181309 - r181319;
        return r181320;
}

double f(double x, double y, double z, double t) {
        double r181321 = z;
        double r181322 = -1.0279259376196081e-16;
        bool r181323 = r181321 <= r181322;
        double r181324 = x;
        double r181325 = 1.0;
        double r181326 = y;
        double r181327 = r181325 - r181326;
        double r181328 = exp(r181321);
        double r181329 = r181326 * r181328;
        double r181330 = r181327 + r181329;
        double r181331 = sqrt(r181330);
        double r181332 = log(r181331);
        double r181333 = r181332 + r181332;
        double r181334 = t;
        double r181335 = r181333 / r181334;
        double r181336 = r181324 - r181335;
        double r181337 = 9.201792392959989e-201;
        bool r181338 = r181321 <= r181337;
        double r181339 = r181321 * r181326;
        double r181340 = 1.0;
        double r181341 = r181340 / r181334;
        double r181342 = r181339 * r181341;
        double r181343 = r181325 * r181342;
        double r181344 = log(r181325);
        double r181345 = r181344 / r181334;
        double r181346 = 0.5;
        double r181347 = 2.0;
        double r181348 = pow(r181321, r181347);
        double r181349 = r181348 * r181326;
        double r181350 = r181349 / r181334;
        double r181351 = r181346 * r181350;
        double r181352 = r181345 + r181351;
        double r181353 = r181343 + r181352;
        double r181354 = r181324 - r181353;
        double r181355 = 0.5;
        double r181356 = r181355 * r181348;
        double r181357 = r181356 + r181321;
        double r181358 = r181326 * r181357;
        double r181359 = r181325 + r181358;
        double r181360 = log(r181359);
        double r181361 = r181360 / r181334;
        double r181362 = r181324 - r181361;
        double r181363 = r181338 ? r181354 : r181362;
        double r181364 = r181323 ? r181336 : r181363;
        return r181364;
}

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.6
Target16.3
Herbie9.2
\[\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 < -1.0279259376196081e-16

    1. Initial program 12.2

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

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

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

    if -1.0279259376196081e-16 < z < 9.201792392959989e-201

    1. Initial program 32.3

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Taylor expanded around 0 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)}\]
    3. Using strategy rm
    4. Applied div-inv5.8

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

    if 9.201792392959989e-201 < z

    1. Initial program 30.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.027925937619608113800553059516376490686 \cdot 10^{-16}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \le 9.201792392959989263626906567590577352864 \cdot 10^{-201}:\\ \;\;\;\;x - \left(1 \cdot \left(\left(z \cdot y\right) \cdot \frac{1}{t}\right) + \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 2019294 
(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.88746230882079466e119) (- (- 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)))