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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 24.8 |
|---|---|
| Target | 16.4 |
| Herbie | 8.1 |
if (exp.f64 z) < 0.99999999999998845Initial program 12.1
rmApplied clear-num_binary6412.1
Simplified12.1
if 0.99999999999998845 < (exp.f64 z) Initial program 30.9
Taylor expanded around 0 7.0
Simplified7.0
rmApplied *-un-lft-identity_binary647.0
Applied times-frac_binary646.2
Simplified6.2
Final simplification8.1
herbie shell --seed 2020233
(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)))