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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.0 |
|---|---|
| Target | 16.7 |
| Herbie | 8.3 |
if z < -0.0607638090012894497Initial program 11.6
rmApplied clear-num_binary6411.6
Simplified11.6
if -0.0607638090012894497 < z < 2.48544200919749139e-145Initial program 31.1
Taylor expanded around 0 6.1
Simplified8.6
rmApplied div-inv_binary648.6
Applied associate-*l*_binary645.1
if 2.48544200919749139e-145 < z Initial program 29.8
Taylor expanded around 0 13.2
Simplified13.2
Final simplification8.3
herbie shell --seed 2021105
(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)))