x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -7.6731932909166638 \cdot 10^{-25}:\\
\;\;\;\;x - \sqrt{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)} \cdot \frac{\sqrt{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right)}{t}\\
\end{array}double code(double x, double y, double z, double t) {
return ((double) (x - ((double) (((double) log(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))) / t))));
}
double code(double x, double y, double z, double t) {
double VAR;
if ((z <= -7.673193290916664e-25)) {
VAR = ((double) (x - ((double) (((double) sqrt(((double) log(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))) * ((double) (((double) sqrt(((double) log(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))) / t))))));
} else {
VAR = ((double) (x - ((double) (((double) fma(0.5, ((double) (((double) pow(z, 2.0)) * y)), ((double) fma(1.0, ((double) (z * y)), ((double) log(1.0)))))) / t))));
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.2 |
|---|---|
| Target | 16.3 |
| Herbie | 8.8 |
if z < -7.673193290916664e-25Initial program 12.1
rmApplied sub-neg12.1
Applied associate-+l+11.9
Simplified11.5
rmApplied *-un-lft-identity11.5
Applied add-sqr-sqrt12.6
Applied times-frac12.6
Simplified12.6
if -7.673193290916664e-25 < z Initial program 31.4
Taylor expanded around 0 7.0
Simplified7.0
Final simplification8.8
herbie shell --seed 2020120 +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)))