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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.1 |
|---|---|
| Target | 16.1 |
| Herbie | 9.3 |
if z < -1.04678783076977627e-4Initial program 12.0
rmApplied div-inv_binary6412.0
if -1.04678783076977627e-4 < z < -1.912739541623214e-268Initial program 30.3
Taylor expanded around 0 11.4
Simplified11.4
rmApplied clear-num_binary6411.4
Taylor expanded around 0 5.4
Simplified5.4
if -1.912739541623214e-268 < z Initial program 31.3
Taylor expanded around 0 10.2
Simplified10.2
rmApplied clear-num_binary6410.2
Final simplification9.3
herbie shell --seed 2020253
(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)))