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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.0 |
|---|---|
| Target | 15.9 |
| Herbie | 8.2 |
if (exp.f64 z) < 0.0Initial program 12.0
rmApplied add-cube-cbrt_binary64_1034312.0
Applied cancel-sign-sub-inv_binary64_1027412.0
Applied associate-+l+_binary64_1024112.0
if 0.0 < (exp.f64 z) Initial program 30.6
Taylor expanded around 0 7.5
Simplified9.5
rmApplied div-inv_binary64_103059.6
Applied associate-*l*_binary64_102496.6
Simplified6.6
Final simplification8.2
herbie shell --seed 2021093
(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)))