x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \leq -3.3566486846414096 \cdot 10^{-19}:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \sqrt[3]{y \cdot e^{z}} \cdot \left(\sqrt[3]{y \cdot e^{z}} \cdot \sqrt[3]{y \cdot e^{z}}\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)\right)}{t}\\
\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 -3.3566486846414096e-19)
(-
x
(/
(log
(+
(- 1.0 y)
(* (cbrt (* y (exp z))) (* (cbrt (* y (exp z))) (cbrt (* y (exp z)))))))
t))
(-
x
(/
(log (+ 1.0 (* y (+ z (* (* z z) (+ 0.5 (* z 0.16666666666666666)))))))
t))))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 <= -3.3566486846414096e-19) {
tmp = x - (log((1.0 - y) + (cbrt(y * exp(z)) * (cbrt(y * exp(z)) * cbrt(y * exp(z))))) / t);
} else {
tmp = x - (log(1.0 + (y * (z + ((z * z) * (0.5 + (z * 0.16666666666666666)))))) / t);
}
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 | 11.4 |
if z < -3.35664868464140962e-19Initial program 12.7
rmApplied add-cube-cbrt_binary64_1043412.6
if -3.35664868464140962e-19 < z Initial program 30.9
rmApplied associate-+l-_binary64_1033416.0
Taylor expanded around 0 10.9
Simplified10.9
Final simplification11.4
herbie shell --seed 2020289
(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)))