x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \leq -4.583227701693125 \cdot 10^{-26}:\\
\;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\
\mathbf{elif}\;z \leq -1.566036451166551 \cdot 10^{-278}:\\
\;\;\;\;x - \frac{z \cdot y + \left(0.5 \cdot \left(z \cdot z\right)\right) \cdot \left(y - y \cdot y\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 -4.583227701693125e-26)
(- x (/ (log (- 1.0 (- y (* y (exp z))))) t))
(if (<= z -1.566036451166551e-278)
(- x (/ (+ (* z y) (* (* 0.5 (* z z)) (- y (* y y)))) 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 <= -4.583227701693125e-26) {
tmp = x - (log(1.0 - (y - (y * exp(z)))) / t);
} else if (z <= -1.566036451166551e-278) {
tmp = x - (((z * y) + ((0.5 * (z * z)) * (y - (y * y)))) / 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.8 |
|---|---|
| Target | 16.3 |
| Herbie | 12.2 |
if z < -4.58322770169312487e-26Initial program 12.0
rmApplied associate-+l-_binary64_1046111.7
if -4.58322770169312487e-26 < z < -1.56603645116655093e-278Initial program 32.1
Taylor expanded around 0 13.3
Simplified13.3
if -1.56603645116655093e-278 < z Initial program 32.3
rmApplied associate-+l-_binary64_1046115.9
Taylor expanded around 0 11.8
Simplified11.8
Final simplification12.2
herbie shell --seed 2020292
(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)))