x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -1.14862408819170439042412611602290218832 \cdot 10^{-69}:\\
\;\;\;\;x - \frac{\left(\sqrt[3]{\log \left(\sqrt{\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)}\right) + \log \left(\sqrt{\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)}\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt[3]{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{fma}\left(y, \mathsf{fma}\left({z}^{2}, 0.5, 1 \cdot z\right), \log 1\right)}{t}\\
\end{array}double f(double x, double y, double z, double t) {
double r185750 = x;
double r185751 = 1.0;
double r185752 = y;
double r185753 = r185751 - r185752;
double r185754 = z;
double r185755 = exp(r185754);
double r185756 = r185752 * r185755;
double r185757 = r185753 + r185756;
double r185758 = log(r185757);
double r185759 = t;
double r185760 = r185758 / r185759;
double r185761 = r185750 - r185760;
return r185761;
}
double f(double x, double y, double z, double t) {
double r185762 = z;
double r185763 = -1.1486240881917044e-69;
bool r185764 = r185762 <= r185763;
double r185765 = x;
double r185766 = expm1(r185762);
double r185767 = y;
double r185768 = 1.0;
double r185769 = fma(r185766, r185767, r185768);
double r185770 = sqrt(r185769);
double r185771 = log(r185770);
double r185772 = r185771 + r185771;
double r185773 = cbrt(r185772);
double r185774 = log(r185769);
double r185775 = cbrt(r185774);
double r185776 = r185773 * r185775;
double r185777 = log1p(r185775);
double r185778 = expm1(r185777);
double r185779 = r185776 * r185778;
double r185780 = t;
double r185781 = r185779 / r185780;
double r185782 = r185765 - r185781;
double r185783 = 2.0;
double r185784 = pow(r185762, r185783);
double r185785 = 0.5;
double r185786 = r185768 * r185762;
double r185787 = fma(r185784, r185785, r185786);
double r185788 = log(r185768);
double r185789 = fma(r185767, r185787, r185788);
double r185790 = r185789 / r185780;
double r185791 = r185765 - r185790;
double r185792 = r185764 ? r185782 : r185791;
return r185792;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 25.2 |
|---|---|
| Target | 16.4 |
| Herbie | 8.9 |
if z < -1.1486240881917044e-69Initial program 15.2
Simplified12.4
rmApplied add-cube-cbrt12.5
rmApplied expm1-log1p-u12.5
rmApplied add-sqr-sqrt12.5
Applied log-prod12.5
if -1.1486240881917044e-69 < z Initial program 31.0
Simplified11.4
Taylor expanded around 0 6.9
Simplified6.9
Final simplification8.9
herbie shell --seed 2019322 +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)))