x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;y \leq -3.45751945873103 \cdot 10^{-65} \lor \neg \left(y \leq 2.6222458264973705 \cdot 10^{-138}\right):\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{\frac{t}{y}}\\
\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 (or (<= y -3.45751945873103e-65) (not (<= y 2.6222458264973705e-138))) (- x (/ (log1p (* y (expm1 z))) t)) (- x (/ (expm1 z) (/ t y)))))
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 ((y <= -3.45751945873103e-65) || !(y <= 2.6222458264973705e-138)) {
tmp = x - (log1p(y * expm1(z)) / t);
} else {
tmp = x - (expm1(z) / (t / y));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.0 |
|---|---|
| Target | 16.1 |
| Herbie | 0.4 |
if y < -3.45751945873103e-65 or 2.62224582649737052e-138 < y Initial program 35.4
Simplified0.6
if -3.45751945873103e-65 < y < 2.62224582649737052e-138Initial program 9.1
Simplified1.8
Applied clear-num_binary641.9
Taylor expanded in y around 0 4.4
Simplified0.3
Final simplification0.4
herbie shell --seed 2021313
(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)))