x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -3.7048441154199694 \cdot 10^{-33} \lor \neg \left(z \le 1.10443579609046836 \cdot 10^{-185}\right):\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \mathsf{fma}\left(0.5, \frac{{z}^{2} \cdot y}{t}, \frac{\log 1}{t}\right)\right)\\
\end{array}double f(double x, double y, double z, double t) {
double r322451 = x;
double r322452 = 1.0;
double r322453 = y;
double r322454 = r322452 - r322453;
double r322455 = z;
double r322456 = exp(r322455);
double r322457 = r322453 * r322456;
double r322458 = r322454 + r322457;
double r322459 = log(r322458);
double r322460 = t;
double r322461 = r322459 / r322460;
double r322462 = r322451 - r322461;
return r322462;
}
double f(double x, double y, double z, double t) {
double r322463 = z;
double r322464 = -3.7048441154199694e-33;
bool r322465 = r322463 <= r322464;
double r322466 = 1.1044357960904684e-185;
bool r322467 = r322463 <= r322466;
double r322468 = !r322467;
bool r322469 = r322465 || r322468;
double r322470 = x;
double r322471 = 1.0;
double r322472 = y;
double r322473 = expm1(r322463);
double r322474 = r322472 * r322473;
double r322475 = r322471 + r322474;
double r322476 = log(r322475);
double r322477 = t;
double r322478 = r322476 / r322477;
double r322479 = r322470 - r322478;
double r322480 = r322463 * r322472;
double r322481 = r322480 / r322477;
double r322482 = 0.5;
double r322483 = 2.0;
double r322484 = pow(r322463, r322483);
double r322485 = r322484 * r322472;
double r322486 = r322485 / r322477;
double r322487 = log(r322471);
double r322488 = r322487 / r322477;
double r322489 = fma(r322482, r322486, r322488);
double r322490 = fma(r322481, r322471, r322489);
double r322491 = r322470 - r322490;
double r322492 = r322469 ? r322479 : r322491;
return r322492;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 25.1 |
|---|---|
| Target | 16.8 |
| Herbie | 9.4 |
if z < -3.7048441154199694e-33 or 1.1044357960904684e-185 < z Initial program 19.9
rmApplied add-cube-cbrt18.1
Applied associate-*l*18.1
rmApplied sub-neg18.1
Applied associate-+l+17.1
Simplified12.6
if -3.7048441154199694e-33 < z < 1.1044357960904684e-185Initial program 31.1
rmApplied add-cube-cbrt26.2
Applied associate-*l*26.2
rmApplied sub-neg26.2
Applied associate-+l+23.4
Simplified11.2
Taylor expanded around 0 5.8
Simplified5.8
Final simplification9.4
herbie shell --seed 2020083 +o rules:numerics
(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)))