wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 5.769639389097466454165273082440798524395 \cdot 10^{-9}:\\
\;\;\;\;x + wj \cdot \left(wj - 2 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + \frac{\frac{x}{e^{wj}}}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r171927 = wj;
double r171928 = exp(r171927);
double r171929 = r171927 * r171928;
double r171930 = x;
double r171931 = r171929 - r171930;
double r171932 = r171928 + r171929;
double r171933 = r171931 / r171932;
double r171934 = r171927 - r171933;
return r171934;
}
double f(double wj, double x) {
double r171935 = wj;
double r171936 = 5.7696393890974665e-09;
bool r171937 = r171935 <= r171936;
double r171938 = x;
double r171939 = 2.0;
double r171940 = r171939 * r171938;
double r171941 = r171935 - r171940;
double r171942 = r171935 * r171941;
double r171943 = r171938 + r171942;
double r171944 = 1.0;
double r171945 = r171935 + r171944;
double r171946 = r171935 / r171945;
double r171947 = r171935 - r171946;
double r171948 = exp(r171935);
double r171949 = r171938 / r171948;
double r171950 = r171949 / r171945;
double r171951 = r171947 + r171950;
double r171952 = r171937 ? r171943 : r171951;
return r171952;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.0 |
|---|---|
| Target | 13.3 |
| Herbie | 0.9 |
if wj < 5.7696393890974665e-09Initial program 13.7
Simplified13.6
Taylor expanded around 0 0.9
Simplified0.9
if 5.7696393890974665e-09 < wj Initial program 25.4
Simplified2.3
rmApplied div-sub2.3
Applied associate--r-2.3
Final simplification0.9
herbie shell --seed 2019306
(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))))))