x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;y \le -4.05769711647860406 \cdot 10^{59}:\\
\;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\
\mathbf{elif}\;y \le -4.7416200176225476 \cdot 10^{-244}:\\
\;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\
\mathbf{elif}\;y \le 0.00692258192467827983:\\
\;\;\;\;x - \left(\frac{\log \left({\left(1 - y\right)}^{3} + {\left(y \cdot e^{z}\right)}^{3}\right)}{t} - \frac{\log \left(\left(1 - y\right) \cdot \left(1 - y\right) + \left(\left(y \cdot e^{z}\right) \cdot \left(y \cdot e^{z}\right) - \left(1 - y\right) \cdot \left(y \cdot e^{z}\right)\right)\right)}{t}\right)\\
\mathbf{elif}\;y \le 4.86668684225561475 \cdot 10^{116}:\\
\;\;\;\;x - \mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right) \cdot \frac{1}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + \mathsf{fma}\left(\frac{1}{6}, {z}^{3} \cdot y, \mathsf{fma}\left(z, y, \frac{1}{2} \cdot \left({z}^{2} \cdot y\right)\right)\right)\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 temp;
if ((y <= -4.057697116478604e+59)) {
temp = (x - (log((1.0 + (y * expm1(z)))) * (1.0 / t)));
} else {
double temp_1;
if ((y <= -4.7416200176225476e-244)) {
temp_1 = (x - ((1.0 * ((z * y) / t)) + (log(1.0) / t)));
} else {
double temp_2;
if ((y <= 0.00692258192467828)) {
temp_2 = (x - ((log((pow((1.0 - y), 3.0) + pow((y * exp(z)), 3.0))) / t) - (log((((1.0 - y) * (1.0 - y)) + (((y * exp(z)) * (y * exp(z))) - ((1.0 - y) * (y * exp(z)))))) / t)));
} else {
double temp_3;
if ((y <= 4.866686842255615e+116)) {
temp_3 = (x - (fma(0.5, (pow(z, 2.0) * y), fma(1.0, (z * y), log(1.0))) * (1.0 / t)));
} else {
temp_3 = (x - (log((1.0 + fma(0.16666666666666666, (pow(z, 3.0) * y), fma(z, y, (0.5 * (pow(z, 2.0) * y)))))) / t));
}
temp_2 = temp_3;
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.2 |
|---|---|
| Target | 15.6 |
| Herbie | 10.2 |
if y < -4.057697116478604e+59Initial program 36.1
rmApplied sub-neg36.1
Applied associate-+l+15.5
Simplified6.4
rmApplied div-inv6.4
if -4.057697116478604e+59 < y < -4.7416200176225476e-244Initial program 17.7
rmApplied sub-neg17.7
Applied associate-+l+13.8
Simplified13.6
Taylor expanded around 0 13.1
if -4.7416200176225476e-244 < y < 0.00692258192467828Initial program 10.6
rmApplied flip3-+10.7
Applied log-div10.7
Applied div-sub10.7
if 0.00692258192467828 < y < 4.866686842255615e+116Initial program 54.4
rmApplied sub-neg54.4
Applied associate-+l+20.3
Simplified16.8
rmApplied div-inv16.8
Taylor expanded around 0 5.0
Simplified5.0
if 4.866686842255615e+116 < y Initial program 62.1
rmApplied sub-neg62.1
Applied associate-+l+29.7
Simplified12.5
Taylor expanded around 0 11.8
Simplified11.8
Final simplification10.2
herbie shell --seed 2020049 +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)))