x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \leq -2.7393459773838706 \cdot 10^{-11}:\\
\;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot y + \left(0.5 \cdot \left(z \cdot \left(z \cdot y\right)\right)\right) \cdot \left(1 - y\right)}{t}\\
\end{array}(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
(FPCore (x y z t) :precision binary64 (if (<= z -2.7393459773838706e-11) (- x (/ (log (- 1.0 (- y (* y (exp z))))) t)) (- x (/ (+ (* z y) (* (* 0.5 (* z (* z y))) (- 1.0 y))) t))))
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 tmp;
if (z <= -2.7393459773838706e-11) {
tmp = x - (log(1.0 - (y - (y * exp(z)))) / t);
} else {
tmp = x - (((z * y) + ((0.5 * (z * (z * y))) * (1.0 - y))) / t);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.2 |
|---|---|
| Target | 15.9 |
| Herbie | 9.4 |
if z < -2.7393459773838706e-11Initial program 11.9
rmApplied associate-+l-_binary64_853811.9
if -2.7393459773838706e-11 < z Initial program 31.0
Taylor expanded around 0 14.4
Simplified8.1
rmApplied associate-*r*_binary64_85438.2
Final simplification9.4
herbie shell --seed 2020342
(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.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))