wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;x \le 1.15551325306561863 \cdot 10^{-202}:\\
\;\;\;\;x + wj \cdot \left(wj - 2 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{\frac{\left(wj + 1\right) \cdot e^{wj}}{e^{wj}}}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}\\
\end{array}double f(double wj, double x) {
double r286846 = wj;
double r286847 = exp(r286846);
double r286848 = r286846 * r286847;
double r286849 = x;
double r286850 = r286848 - r286849;
double r286851 = r286847 + r286848;
double r286852 = r286850 / r286851;
double r286853 = r286846 - r286852;
return r286853;
}
double f(double wj, double x) {
double r286854 = x;
double r286855 = 1.1555132530656186e-202;
bool r286856 = r286854 <= r286855;
double r286857 = wj;
double r286858 = 2.0;
double r286859 = r286858 * r286854;
double r286860 = r286857 - r286859;
double r286861 = r286857 * r286860;
double r286862 = r286854 + r286861;
double r286863 = 1.0;
double r286864 = r286857 + r286863;
double r286865 = exp(r286857);
double r286866 = r286864 * r286865;
double r286867 = r286866 / r286865;
double r286868 = r286857 / r286867;
double r286869 = r286857 - r286868;
double r286870 = r286857 * r286865;
double r286871 = r286865 + r286870;
double r286872 = r286854 / r286871;
double r286873 = r286869 + r286872;
double r286874 = r286856 ? r286862 : r286873;
return r286874;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.4 |
|---|---|
| Target | 12.7 |
| Herbie | 2.7 |
if x < 1.1555132530656186e-202Initial program 17.9
Taylor expanded around 0 2.0
Simplified2.0
if 1.1555132530656186e-202 < x Initial program 6.9
rmApplied div-sub6.9
Applied associate--r-3.8
Simplified3.8
Final simplification2.7
herbie shell --seed 2020024
(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))))))