x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -3.61247754966531634 \cdot 10^{-6}:\\
\;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\
\mathbf{elif}\;z \le 3.44462763878247732 \cdot 10^{-225}:\\
\;\;\;\;x - \mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right) \cdot \frac{1}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(1 + y \cdot \mathsf{expm1}\left(z\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 <= -3.6124775496653163e-06)) {
temp = (x - (log((1.0 + (y * expm1(z)))) * (1.0 / t)));
} else {
double temp_1;
if ((z <= 3.4446276387824773e-225)) {
temp_1 = (x - (fma(0.5, (pow(z, 2.0) * y), fma(1.0, (z * y), log(1.0))) * (1.0 / t)));
} else {
temp_1 = (x - (1.0 / (t / log((1.0 + (y * expm1(z)))))));
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.5 |
|---|---|
| Target | 16.5 |
| Herbie | 9.3 |
if z < -3.6124775496653163e-06Initial program 11.9
rmApplied sub-neg11.9
Applied associate-+l+11.9
Simplified11.8
rmApplied div-inv11.9
if -3.6124775496653163e-06 < z < 3.4446276387824773e-225Initial program 31.7
rmApplied sub-neg31.7
Applied associate-+l+16.0
Simplified11.9
rmApplied div-inv11.9
Taylor expanded around 0 6.1
Simplified6.1
if 3.4446276387824773e-225 < z Initial program 31.1
rmApplied sub-neg31.1
Applied associate-+l+18.1
Simplified11.9
rmApplied clear-num11.9
Final simplification9.3
herbie shell --seed 2020060 +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)))