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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.4 |
|---|---|
| Target | 15.8 |
| Herbie | 9.1 |
if z < -1.69270411962892723e-7Initial program 11.5
rmApplied add-cube-cbrt_binary6411.5
Applied associate-*l*_binary6411.5
Simplified11.5
if -1.69270411962892723e-7 < z Initial program 31.2
Taylor expanded around 0 14.6
Simplified8.1
rmApplied div-inv_binary648.1
Final simplification9.1
herbie shell --seed 2020224
(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)))