x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;y \le -2045829589.78826594:\\
\;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\
\mathbf{elif}\;y \le -2.33715474181218539 \cdot 10^{-79}:\\
\;\;\;\;x - \frac{\mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right)}{t}\\
\mathbf{elif}\;y \le 0.509833754303126052:\\
\;\;\;\;x - \frac{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}{t}\\
\mathbf{elif}\;y \le 3.45567648289861118 \cdot 10^{68}:\\
\;\;\;\;x - \frac{\mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{2 \cdot \log \left(\sqrt[3]{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \log \left(\sqrt[3]{1 + y \cdot \mathsf{expm1}\left(z\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 VAR;
if ((y <= -2045829589.788266)) {
VAR = (x - (log((1.0 + (y * expm1(z)))) * (1.0 / t)));
} else {
double VAR_1;
if ((y <= -2.3371547418121854e-79)) {
VAR_1 = (x - (fma(0.5, (pow(z, 2.0) * y), fma(1.0, (z * y), log(1.0))) / t));
} else {
double VAR_2;
if ((y <= 0.509833754303126)) {
VAR_2 = (x - ((log(sqrt((1.0 + (y * expm1(z))))) + log(sqrt((1.0 + (y * expm1(z)))))) / t));
} else {
double VAR_3;
if ((y <= 3.455676482898611e+68)) {
VAR_3 = (x - (fma(0.5, (pow(z, 2.0) * y), fma(1.0, (z * y), log(1.0))) / t));
} else {
VAR_3 = (x - (((2.0 * log(cbrt((1.0 + (y * expm1(z)))))) + log(cbrt((1.0 + (y * expm1(z)))))) / t));
}
VAR_2 = VAR_3;
}
VAR_1 = VAR_2;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.5 |
|---|---|
| Target | 16.6 |
| Herbie | 11.1 |
if y < -2045829589.788266Initial program 37.3
rmApplied sub-neg37.3
Applied associate-+l+15.6
Simplified9.0
rmApplied div-inv9.0
if -2045829589.788266 < y < -2.3371547418121854e-79 or 0.509833754303126 < y < 3.455676482898611e+68Initial program 28.6
Taylor expanded around 0 11.7
Simplified11.7
if -2.3371547418121854e-79 < y < 0.509833754303126Initial program 11.7
rmApplied sub-neg11.7
Applied associate-+l+11.7
Simplified11.7
rmApplied add-sqr-sqrt11.7
Applied log-prod11.7
if 3.455676482898611e+68 < y Initial program 61.7
rmApplied sub-neg61.7
Applied associate-+l+28.3
Simplified12.5
rmApplied add-cube-cbrt12.7
Applied log-prod12.7
Simplified12.7
Final simplification11.1
herbie shell --seed 2020092 +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)))