x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \leq -136.41029037088336:\\
\;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\
\mathbf{elif}\;z \leq 1.752020864510689 \cdot 10^{-241}:\\
\;\;\;\;x - \frac{\log 1 + y \cdot \left(z \cdot 1\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\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 -136.41029037088336)
(-
x
(/
(+
(log (sqrt (+ (- 1.0 y) (* y (exp z)))))
(log (sqrt (+ (- 1.0 y) (* y (exp z))))))
t))
(if (<= z 1.752020864510689e-241)
(- x (/ (+ (log 1.0) (* y (* z 1.0))) t))
(- x (/ (log (+ 1.0 (* y (+ z (* (* z z) 0.5))))) t)))))double code(double x, double y, double z, double t) {
return ((double) (x - (((double) log(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))) / t)));
}
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -136.41029037088336)) {
tmp = ((double) (x - (((double) (((double) log(((double) sqrt(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))))) + ((double) log(((double) sqrt(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))))))) / t)));
} else {
double tmp_1;
if ((z <= 1.752020864510689e-241)) {
tmp_1 = ((double) (x - (((double) (((double) log(1.0)) + ((double) (y * ((double) (z * 1.0)))))) / t)));
} else {
tmp_1 = ((double) (x - (((double) log(((double) (1.0 + ((double) (y * ((double) (z + ((double) (((double) (z * z)) * 0.5)))))))))) / t)));
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.4 |
|---|---|
| Target | 16.4 |
| Herbie | 9.6 |
if z < -136.410290370883359Initial program 12.3
rmApplied add-sqr-sqrt_binary6412.3
Applied log-prod_binary6412.3
if -136.410290370883359 < z < 1.75202086451068903e-241Initial program 31.1
Taylor expanded around 0 6.2
Simplified6.2
Taylor expanded around 0 6.3
Simplified6.3
if 1.75202086451068903e-241 < z Initial program 30.7
Taylor expanded around 0 11.9
Simplified11.9
Final simplification9.6
herbie shell --seed 2020205
(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)))