x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -6.310119903545574434291526250400899439411 \cdot 10^{-134}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \mathsf{fma}\left(\frac{{z}^{2} \cdot y}{t}, 0.5, \frac{\log 1}{t}\right)\right)\\
\end{array}double f(double x, double y, double z, double t) {
double r146724 = x;
double r146725 = 1.0;
double r146726 = y;
double r146727 = r146725 - r146726;
double r146728 = z;
double r146729 = exp(r146728);
double r146730 = r146726 * r146729;
double r146731 = r146727 + r146730;
double r146732 = log(r146731);
double r146733 = t;
double r146734 = r146732 / r146733;
double r146735 = r146724 - r146734;
return r146735;
}
double f(double x, double y, double z, double t) {
double r146736 = z;
double r146737 = -6.310119903545574e-134;
bool r146738 = r146736 <= r146737;
double r146739 = x;
double r146740 = expm1(r146736);
double r146741 = y;
double r146742 = 1.0;
double r146743 = fma(r146740, r146741, r146742);
double r146744 = log(r146743);
double r146745 = t;
double r146746 = r146744 / r146745;
double r146747 = r146739 - r146746;
double r146748 = r146736 * r146741;
double r146749 = r146748 / r146745;
double r146750 = 2.0;
double r146751 = pow(r146736, r146750);
double r146752 = r146751 * r146741;
double r146753 = r146752 / r146745;
double r146754 = 0.5;
double r146755 = log(r146742);
double r146756 = r146755 / r146745;
double r146757 = fma(r146753, r146754, r146756);
double r146758 = fma(r146749, r146742, r146757);
double r146759 = r146739 - r146758;
double r146760 = r146738 ? r146747 : r146759;
return r146760;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 24.6 |
|---|---|
| Target | 16.1 |
| Herbie | 8.4 |
if z < -6.310119903545574e-134Initial program 16.9
Simplified11.6
rmApplied div-inv11.6
rmApplied pow111.6
Applied pow111.6
Applied pow-prod-down11.6
Simplified11.6
if -6.310119903545574e-134 < z Initial program 30.4
Simplified11.2
rmApplied div-inv11.2
rmApplied pow111.2
Applied pow111.2
Applied pow-prod-down11.2
Simplified11.2
Taylor expanded around 0 6.0
Simplified6.0
Final simplification8.4
herbie shell --seed 2019323 +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)))