x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -2.4006361517684793 \cdot 10^{-172}:\\
\;\;\;\;x - \frac{\frac{1}{t}}{\frac{1}{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}\\
\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 r227153 = x;
double r227154 = 1.0;
double r227155 = y;
double r227156 = r227154 - r227155;
double r227157 = z;
double r227158 = exp(r227157);
double r227159 = r227155 * r227158;
double r227160 = r227156 + r227159;
double r227161 = log(r227160);
double r227162 = t;
double r227163 = r227161 / r227162;
double r227164 = r227153 - r227163;
return r227164;
}
double f(double x, double y, double z, double t) {
double r227165 = z;
double r227166 = -2.4006361517684793e-172;
bool r227167 = r227165 <= r227166;
double r227168 = x;
double r227169 = 1.0;
double r227170 = t;
double r227171 = r227169 / r227170;
double r227172 = 1.0;
double r227173 = y;
double r227174 = expm1(r227165);
double r227175 = r227173 * r227174;
double r227176 = r227172 + r227175;
double r227177 = log(r227176);
double r227178 = r227169 / r227177;
double r227179 = r227171 / r227178;
double r227180 = r227168 - r227179;
double r227181 = r227165 * r227173;
double r227182 = r227181 / r227170;
double r227183 = 0.5;
double r227184 = 2.0;
double r227185 = pow(r227165, r227184);
double r227186 = r227185 * r227173;
double r227187 = r227186 / r227170;
double r227188 = log(r227172);
double r227189 = r227188 / r227170;
double r227190 = fma(r227183, r227187, r227189);
double r227191 = fma(r227182, r227172, r227190);
double r227192 = r227168 - r227191;
double r227193 = r227167 ? r227180 : r227192;
return r227193;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 25.4 |
|---|---|
| Target | 16.5 |
| Herbie | 9.1 |
if z < -2.4006361517684793e-172Initial program 18.9
rmApplied sub-neg18.9
Applied associate-+l+14.8
Simplified12.3
rmApplied clear-num12.3
rmApplied div-inv12.3
Applied associate-/r*12.3
if -2.4006361517684793e-172 < z Initial program 31.3
rmApplied sub-neg31.3
Applied associate-+l+15.2
Simplified11.4
Taylor expanded around 0 6.2
Simplified6.2
Final simplification9.1
herbie shell --seed 2020034 +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)))