wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 2.32999755055536264 \cdot 10^{-7}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) \cdot \left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1}}{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) + \frac{wj}{wj + 1}}\\
\end{array}double f(double wj, double x) {
double r354836 = wj;
double r354837 = exp(r354836);
double r354838 = r354836 * r354837;
double r354839 = x;
double r354840 = r354838 - r354839;
double r354841 = r354837 + r354838;
double r354842 = r354840 / r354841;
double r354843 = r354836 - r354842;
return r354843;
}
double f(double wj, double x) {
double r354844 = wj;
double r354845 = 2.3299975505553626e-07;
bool r354846 = r354844 <= r354845;
double r354847 = x;
double r354848 = 2.0;
double r354849 = pow(r354844, r354848);
double r354850 = r354847 + r354849;
double r354851 = r354844 * r354847;
double r354852 = r354848 * r354851;
double r354853 = r354850 - r354852;
double r354854 = 1.0;
double r354855 = r354844 + r354854;
double r354856 = r354847 / r354855;
double r354857 = exp(r354844);
double r354858 = r354856 / r354857;
double r354859 = r354858 + r354844;
double r354860 = r354859 * r354859;
double r354861 = r354844 / r354855;
double r354862 = r354861 * r354861;
double r354863 = r354860 - r354862;
double r354864 = r354859 + r354861;
double r354865 = r354863 / r354864;
double r354866 = r354846 ? r354853 : r354865;
return r354866;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.6 |
|---|---|
| Target | 13.0 |
| Herbie | 1.2 |
if wj < 2.3299975505553626e-07Initial program 13.3
Simplified13.3
Taylor expanded around 0 0.9
if 2.3299975505553626e-07 < wj Initial program 25.7
Simplified2.2
rmApplied flip--13.1
Final simplification1.2
herbie shell --seed 2020065
(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))))))