x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -3.2314583272364048 \cdot 10^{-62}:\\
\;\;\;\;x - \left(\sqrt[3]{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)} \cdot \sqrt[3]{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}\right) \cdot \frac{\sqrt[3]{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5 \cdot z, z, 1 \cdot z\right), y, \log 1\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 <= -3.2314583272364048e-62)) {
VAR = (x - ((cbrt(log(fma(expm1(z), y, 1.0))) * cbrt(log(fma(expm1(z), y, 1.0)))) * (cbrt(log(fma(expm1(z), y, 1.0))) / t)));
} else {
VAR = (x - (fma(fma((0.5 * z), z, (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.1 |
|---|---|
| Target | 16.3 |
| Herbie | 8.6 |
if z < -3.2314583272364048e-62Initial program 14.8
rmApplied sub-neg14.8
Applied associate-+l+13.5
Simplified12.0
rmApplied add-log-exp12.0
Simplified12.0
rmApplied *-un-lft-identity12.0
Applied add-cube-cbrt12.1
Applied times-frac12.1
Simplified12.1
if -3.2314583272364048e-62 < z Initial program 30.9
rmApplied sub-neg30.9
Applied associate-+l+15.3
Simplified10.9
rmApplied add-log-exp10.9
Simplified10.9
Taylor expanded around 0 6.6
Simplified6.6
Final simplification8.6
herbie shell --seed 2020105 +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)))