x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -1.355985277760923721475726033060808414189 \cdot 10^{-91}:\\
\;\;\;\;x - \frac{1}{\frac{\frac{t}{\sqrt{\log \left(\mathsf{fma}\left(y, \mathsf{expm1}\left(z\right), 1\right)\right)}}}{\sqrt{\log \left(\mathsf{fma}\left(y, \mathsf{expm1}\left(z\right), 1\right)\right)}}}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(\frac{z \cdot y}{t}, 1, \frac{\log 1}{t}\right)\\
\end{array}double f(double x, double y, double z, double t) {
double r12364401 = x;
double r12364402 = 1.0;
double r12364403 = y;
double r12364404 = r12364402 - r12364403;
double r12364405 = z;
double r12364406 = exp(r12364405);
double r12364407 = r12364403 * r12364406;
double r12364408 = r12364404 + r12364407;
double r12364409 = log(r12364408);
double r12364410 = t;
double r12364411 = r12364409 / r12364410;
double r12364412 = r12364401 - r12364411;
return r12364412;
}
double f(double x, double y, double z, double t) {
double r12364413 = z;
double r12364414 = -1.3559852777609237e-91;
bool r12364415 = r12364413 <= r12364414;
double r12364416 = x;
double r12364417 = 1.0;
double r12364418 = t;
double r12364419 = y;
double r12364420 = expm1(r12364413);
double r12364421 = 1.0;
double r12364422 = fma(r12364419, r12364420, r12364421);
double r12364423 = log(r12364422);
double r12364424 = sqrt(r12364423);
double r12364425 = r12364418 / r12364424;
double r12364426 = r12364425 / r12364424;
double r12364427 = r12364417 / r12364426;
double r12364428 = r12364416 - r12364427;
double r12364429 = r12364413 * r12364419;
double r12364430 = r12364429 / r12364418;
double r12364431 = log(r12364421);
double r12364432 = r12364431 / r12364418;
double r12364433 = fma(r12364430, r12364421, r12364432);
double r12364434 = r12364416 - r12364433;
double r12364435 = r12364415 ? r12364428 : r12364434;
return r12364435;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 25.0 |
|---|---|
| Target | 16.4 |
| Herbie | 9.0 |
if z < -1.3559852777609237e-91Initial program 15.6
Simplified11.9
rmApplied clear-num11.9
rmApplied add-sqr-sqrt12.8
Applied *-un-lft-identity12.8
Applied times-frac12.8
Applied *-un-lft-identity12.8
Applied times-frac12.8
rmApplied expm1-log1p-u12.8
rmApplied frac-times12.8
Simplified12.8
Simplified12.8
if -1.3559852777609237e-91 < z Initial program 30.9
Simplified11.6
Taylor expanded around 0 6.6
Simplified6.6
Final simplification9.0
herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
: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)))