x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -1.355985277760923721475726033060808414189 \cdot 10^{-91}:\\
\;\;\;\;x - \frac{1}{\frac{\frac{t}{\sqrt{\log \left(\mathsf{fma}\left(y, \mathsf{expm1}\left(z\right), 1\right)\right)}}}{\sqrt{\log \left(\mathsf{fma}\left(y, \mathsf{expm1}\left(z\right), 1\right)\right)}}}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \frac{\log 1}{t}\right)\\
\end{array}double f(double x, double y, double z, double t) {
double r9629034 = x;
double r9629035 = 1.0;
double r9629036 = y;
double r9629037 = r9629035 - r9629036;
double r9629038 = z;
double r9629039 = exp(r9629038);
double r9629040 = r9629036 * r9629039;
double r9629041 = r9629037 + r9629040;
double r9629042 = log(r9629041);
double r9629043 = t;
double r9629044 = r9629042 / r9629043;
double r9629045 = r9629034 - r9629044;
return r9629045;
}
double f(double x, double y, double z, double t) {
double r9629046 = z;
double r9629047 = -1.3559852777609237e-91;
bool r9629048 = r9629046 <= r9629047;
double r9629049 = x;
double r9629050 = 1.0;
double r9629051 = t;
double r9629052 = y;
double r9629053 = expm1(r9629046);
double r9629054 = 1.0;
double r9629055 = fma(r9629052, r9629053, r9629054);
double r9629056 = log(r9629055);
double r9629057 = sqrt(r9629056);
double r9629058 = r9629051 / r9629057;
double r9629059 = r9629058 / r9629057;
double r9629060 = r9629050 / r9629059;
double r9629061 = r9629049 - r9629060;
double r9629062 = r9629046 * r9629052;
double r9629063 = r9629062 / r9629051;
double r9629064 = log(r9629054);
double r9629065 = r9629064 / r9629051;
double r9629066 = fma(r9629063, r9629054, r9629065);
double r9629067 = r9629049 - r9629066;
double r9629068 = r9629048 ? r9629061 : r9629067;
return r9629068;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 25.0 |
|---|---|
| Target | 16.4 |
| Herbie | 9.0 |
if z < -1.3559852777609237e-91Initial program 15.6
Simplified11.9
rmApplied clear-num11.9
rmApplied add-sqr-sqrt12.8
Applied *-un-lft-identity12.8
Applied times-frac12.8
Applied *-un-lft-identity12.8
Applied times-frac12.8
rmApplied expm1-log1p-u12.8
rmApplied frac-times12.8
Simplified12.8
Simplified12.8
if -1.3559852777609237e-91 < z Initial program 30.9
Simplified11.6
Taylor expanded around 0 6.6
Simplified6.6
Final simplification9.0
herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))