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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 24.6 |
|---|---|
| Target | 16.3 |
| Herbie | 10.1 |
if (exp.f64 z) < 0.0Initial program 12.1
rmApplied div-inv_binary6412.1
if 0.0 < (exp.f64 z) Initial program 30.2
Taylor expanded around 0 14.2
Simplified8.4
rmApplied add-log-exp_binary649.9
Simplified9.1
Final simplification10.1
herbie shell --seed 2020219
(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)))