x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} = -\infty:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\
\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le -1.78200783083627751 \cdot 10^{-208}:\\
\;\;\;\;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}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le 6.3743253054540378 \cdot 10^{-82}:\\
\;\;\;\;x - \left(1 \cdot \frac{z \cdot 1}{\frac{t}{y}} + \frac{\log 1}{t}\right)\\
\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le 2.1484987444557403 \cdot 10^{306}:\\
\;\;\;\;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{else}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\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 (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= -inf.0)) {
temp = (x - (log(fma(0.5, (pow(z, 2.0) * y), fma(z, y, 1.0))) / t));
} else {
double temp_1;
if (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= -1.7820078308362775e-208)) {
temp_1 = (x - ((log(sqrt(((1.0 - y) + (y * exp(z))))) + log(sqrt(((1.0 - y) + (y * exp(z)))))) / t));
} else {
double temp_2;
if (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= 6.374325305454038e-82)) {
temp_2 = (x - ((1.0 * ((z * 1.0) / (t / y))) + (log(1.0) / t)));
} else {
double temp_3;
if (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= 2.1484987444557403e+306)) {
temp_3 = (x - ((log(sqrt(((1.0 - y) + (y * exp(z))))) + log(sqrt(((1.0 - y) + (y * exp(z)))))) / t));
} else {
temp_3 = (x - (log(fma(0.5, (pow(z, 2.0) * y), fma(z, y, 1.0))) / 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.0 |
|---|---|
| Target | 16.6 |
| Herbie | 10.5 |
if (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < -inf.0 or 2.1484987444557403e+306 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) Initial program 63.7
Taylor expanded around 0 15.2
Simplified15.2
if -inf.0 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < -1.7820078308362775e-208 or 6.374325305454038e-82 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < 2.1484987444557403e+306Initial program 6.3
rmApplied add-sqr-sqrt6.3
Applied log-prod6.3
if -1.7820078308362775e-208 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < 6.374325305454038e-82Initial program 26.6
Taylor expanded around 0 22.5
rmApplied *-un-lft-identity22.5
Applied associate-*r*22.5
Applied associate-/l*17.3
Final simplification10.5
herbie shell --seed 2020066 +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)))