x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -2.77926232449136807 \cdot 10^{44}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\sqrt{1 - y}, \sqrt{1 - y}, y \cdot e^{z}\right)\right)}{t}\\
\mathbf{elif}\;z \le -8.89077092915690779 \cdot 10^{-119}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \mathsf{fma}\left(0.5, \frac{{z}^{2} \cdot y}{t}, \frac{\log 1}{t}\right)\right)\\
\end{array}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 temp;
if ((z <= -2.779262324491368e+44)) {
temp = (x - (log(fma(sqrt((1.0 - y)), sqrt((1.0 - y)), (y * exp(z)))) / t));
} else {
double temp_1;
if ((z <= -8.890770929156908e-119)) {
temp_1 = (x - (log(fma(0.5, (pow(z, 2.0) * y), fma(z, y, 1.0))) / t));
} else {
temp_1 = (x - fma(((z * y) / t), 1.0, fma(0.5, ((pow(z, 2.0) * y) / t), (log(1.0) / t))));
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.0 |
|---|---|
| Target | 16.6 |
| Herbie | 10.2 |
if z < -2.779262324491368e+44Initial program 12.2
rmApplied add-sqr-sqrt12.2
Applied fma-def12.2
if -2.779262324491368e+44 < z < -8.890770929156908e-119Initial program 25.1
Taylor expanded around 0 18.6
Simplified18.6
if -8.890770929156908e-119 < z Initial program 30.7
Taylor expanded around 0 6.9
Simplified6.9
Final simplification10.2
herbie shell --seed 2020066 +o rules:numerics
(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 z) (* z z)))) (- x (/ (log (+ 1 (* z y))) t)))
(- x (/ (log (+ (- 1 y) (* y (exp z)))) t)))