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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 24.6 |
|---|---|
| Target | 16.1 |
| Herbie | 7.9 |
if y < -10.53818023093515Initial program 35.1
Taylor expanded around inf 35.1
Simplified14.3
if -10.53818023093515 < y < 1.8632665276419243e247Initial program 19.9
rmApplied clear-num_binary64_1098919.9
Simplified14.1
Taylor expanded around 0 11.1
Simplified11.1
Taylor expanded around 0 11.1
Simplified5.9
if 1.8632665276419243e247 < y Initial program 62.1
rmApplied clear-num_binary64_1098962.1
Simplified30.6
Taylor expanded around 0 2.9
Final simplification7.9
herbie shell --seed 2021024
(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)))