x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -1.31107669511558345 \cdot 10^{-82}:\\
\;\;\;\;x - \frac{1}{t} \cdot \log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right)}{t}\\
\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 VAR;
if ((z <= -1.3110766951155834e-82)) {
VAR = (x - ((1.0 / t) * log(fma(expm1(z), y, 1.0))));
} else {
VAR = (x - (fma(0.5, (pow(z, 2.0) * y), fma(1.0, (z * y), log(1.0))) / t));
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.0 |
|---|---|
| Target | 16.5 |
| Herbie | 8.5 |
if z < -1.3110766951155834e-82Initial program 15.7
rmApplied sub-neg15.7
Applied associate-+l+13.8
Simplified11.9
rmApplied clear-num11.9
rmApplied div-inv11.9
Applied add-cube-cbrt11.9
Applied times-frac11.9
Simplified11.9
Simplified11.9
if -1.3110766951155834e-82 < z Initial program 31.0
Taylor expanded around 0 6.3
Simplified6.3
Final simplification8.5
herbie shell --seed 2020103 +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)))