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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.7 |
|---|---|
| Target | 17.0 |
| Herbie | 9.6 |
if z < -2.88667025498127572e-93Initial program 16.1
rmApplied associate-+l-_binary64_887913.9
if -2.88667025498127572e-93 < z Initial program 32.0
Taylor expanded around 0 14.1
Simplified7.7
rmApplied clear-num_binary64_89437.7
Simplified7.7
rmApplied *-un-lft-identity_binary64_89447.7
Applied add-sqr-sqrt_binary64_89667.7
Applied times-frac_binary64_89507.7
Simplified7.7
Simplified6.7
Final simplification9.6
herbie shell --seed 2020355
(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)))