wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.06252678575455972 \cdot 10^{-9}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj \cdot wj - 1} \cdot \left(wj - 1\right)\\
\end{array}double f(double wj, double x) {
double r183500 = wj;
double r183501 = exp(r183500);
double r183502 = r183500 * r183501;
double r183503 = x;
double r183504 = r183502 - r183503;
double r183505 = r183501 + r183502;
double r183506 = r183504 / r183505;
double r183507 = r183500 - r183506;
return r183507;
}
double f(double wj, double x) {
double r183508 = wj;
double r183509 = 9.06252678575456e-09;
bool r183510 = r183508 <= r183509;
double r183511 = x;
double r183512 = 2.0;
double r183513 = pow(r183508, r183512);
double r183514 = r183511 + r183513;
double r183515 = r183508 * r183511;
double r183516 = r183512 * r183515;
double r183517 = r183514 - r183516;
double r183518 = 1.0;
double r183519 = r183508 + r183518;
double r183520 = r183511 / r183519;
double r183521 = exp(r183508);
double r183522 = r183520 / r183521;
double r183523 = r183522 + r183508;
double r183524 = r183508 * r183508;
double r183525 = r183524 - r183518;
double r183526 = r183508 / r183525;
double r183527 = r183508 - r183518;
double r183528 = r183526 * r183527;
double r183529 = r183523 - r183528;
double r183530 = r183510 ? r183517 : r183529;
return r183530;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.2 |
|---|---|
| Target | 13.5 |
| Herbie | 1.1 |
if wj < 9.06252678575456e-09Initial program 13.9
Simplified13.9
Taylor expanded around 0 1.0
if 9.06252678575456e-09 < wj Initial program 26.3
Simplified3.1
rmApplied flip-+3.2
Applied associate-/r/3.0
Simplified3.0
Final simplification1.1
herbie shell --seed 2020035
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))