wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 4.160404689641216852166604763104892916736 \cdot 10^{-9}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + wj\right) - \frac{wj}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r246911 = wj;
double r246912 = exp(r246911);
double r246913 = r246911 * r246912;
double r246914 = x;
double r246915 = r246913 - r246914;
double r246916 = r246912 + r246913;
double r246917 = r246915 / r246916;
double r246918 = r246911 - r246917;
return r246918;
}
double f(double wj, double x) {
double r246919 = wj;
double r246920 = 4.160404689641217e-09;
bool r246921 = r246919 <= r246920;
double r246922 = x;
double r246923 = 2.0;
double r246924 = pow(r246919, r246923);
double r246925 = r246922 + r246924;
double r246926 = r246919 * r246922;
double r246927 = r246923 * r246926;
double r246928 = r246925 - r246927;
double r246929 = exp(r246919);
double r246930 = 1.0;
double r246931 = r246919 + r246930;
double r246932 = r246929 * r246931;
double r246933 = r246922 / r246932;
double r246934 = r246933 + r246919;
double r246935 = r246919 / r246931;
double r246936 = r246934 - r246935;
double r246937 = r246921 ? r246928 : r246936;
return r246937;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 0.9 |
if wj < 4.160404689641217e-09Initial program 13.4
Simplified13.4
Taylor expanded around 0 0.8
if 4.160404689641217e-09 < wj Initial program 26.7
Simplified2.9
rmApplied div-inv2.9
Applied associate-/l*2.9
Simplified2.9
Final simplification0.9
herbie shell --seed 2020001 +o rules:numerics
(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))))))