x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -1.63783683020029204 \cdot 10^{-19}:\\
\;\;\;\;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 r284791 = x;
double r284792 = 1.0;
double r284793 = y;
double r284794 = r284792 - r284793;
double r284795 = z;
double r284796 = exp(r284795);
double r284797 = r284793 * r284796;
double r284798 = r284794 + r284797;
double r284799 = log(r284798);
double r284800 = t;
double r284801 = r284799 / r284800;
double r284802 = r284791 - r284801;
return r284802;
}
double f(double x, double y, double z, double t) {
double r284803 = z;
double r284804 = -1.637836830200292e-19;
bool r284805 = r284803 <= r284804;
double r284806 = x;
double r284807 = 1.0;
double r284808 = y;
double r284809 = expm1(r284803);
double r284810 = r284808 * r284809;
double r284811 = r284807 + r284810;
double r284812 = log(r284811);
double r284813 = t;
double r284814 = r284812 / r284813;
double r284815 = r284806 - r284814;
double r284816 = r284803 * r284808;
double r284817 = r284816 / r284813;
double r284818 = 0.5;
double r284819 = 2.0;
double r284820 = pow(r284803, r284819);
double r284821 = r284820 * r284808;
double r284822 = r284821 / r284813;
double r284823 = log(r284807);
double r284824 = r284823 / r284813;
double r284825 = fma(r284818, r284822, r284824);
double r284826 = fma(r284817, r284807, r284825);
double r284827 = r284806 - r284826;
double r284828 = r284805 ? r284815 : r284827;
return r284828;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 25.1 |
|---|---|
| Target | 16.3 |
| Herbie | 8.4 |
if z < -1.637836830200292e-19Initial program 11.6
rmApplied sub-neg11.6
Applied associate-+l+11.5
Simplified11.3
if -1.637836830200292e-19 < z Initial program 31.4
rmApplied sub-neg31.4
Applied associate-+l+16.4
Simplified11.8
rmApplied div-inv11.8
Taylor expanded around 0 7.1
Simplified7.1
Final simplification8.4
herbie shell --seed 2020062 +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)))