x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;e^{z} \le 0.992563156827188764:\\
\;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\
\end{array}double code(double x, double y, double z, double t) {
return (x - (log(((1.0 - y) + (y * exp(z)))) / t));
}
double code(double x, double y, double z, double t) {
double VAR;
if ((exp(z) <= 0.9925631568271888)) {
VAR = (x - (log((1.0 + (y * expm1(z)))) * (1.0 / t)));
} else {
VAR = (x - ((1.0 * ((z * y) / t)) + (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.5 |
| Herbie | 8.8 |
if (exp z) < 0.9925631568271888Initial program 11.9
rmApplied sub-neg11.9
Applied associate-+l+11.9
Simplified11.9
rmApplied div-inv11.9
if 0.9925631568271888 < (exp z) Initial program 31.0
rmApplied sub-neg31.0
Applied associate-+l+16.3
Simplified11.6
Taylor expanded around 0 7.4
Final simplification8.8
herbie shell --seed 2020079 +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)))