wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 2.1380709412627531 \cdot 10^{-13}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{wj + 1}}{e^{wj}} + \frac{{wj}^{3} - {\left(\frac{wj}{wj + 1}\right)}^{3}}{\frac{wj}{wj + 1} \cdot \left(\frac{wj}{wj + 1} + wj\right) + {wj}^{2}}\\
\end{array}double f(double wj, double x) {
double r128908 = wj;
double r128909 = exp(r128908);
double r128910 = r128908 * r128909;
double r128911 = x;
double r128912 = r128910 - r128911;
double r128913 = r128909 + r128910;
double r128914 = r128912 / r128913;
double r128915 = r128908 - r128914;
return r128915;
}
double f(double wj, double x) {
double r128916 = wj;
double r128917 = 2.138070941262753e-13;
bool r128918 = r128916 <= r128917;
double r128919 = x;
double r128920 = 2.0;
double r128921 = pow(r128916, r128920);
double r128922 = r128919 + r128921;
double r128923 = r128916 * r128919;
double r128924 = r128920 * r128923;
double r128925 = r128922 - r128924;
double r128926 = 1.0;
double r128927 = r128916 + r128926;
double r128928 = r128919 / r128927;
double r128929 = exp(r128916);
double r128930 = r128928 / r128929;
double r128931 = 3.0;
double r128932 = pow(r128916, r128931);
double r128933 = r128916 / r128927;
double r128934 = pow(r128933, r128931);
double r128935 = r128932 - r128934;
double r128936 = r128933 + r128916;
double r128937 = r128933 * r128936;
double r128938 = r128937 + r128921;
double r128939 = r128935 / r128938;
double r128940 = r128930 + r128939;
double r128941 = r128918 ? r128925 : r128940;
return r128941;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.4 |
|---|---|
| Target | 12.7 |
| Herbie | 0.9 |
if wj < 2.138070941262753e-13Initial program 13.0
Simplified13.0
Taylor expanded around 0 0.8
if 2.138070941262753e-13 < wj Initial program 23.1
Simplified5.0
rmApplied associate--l+5.0
rmApplied flip3--5.2
Simplified5.2
Final simplification0.9
herbie shell --seed 2020064
(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))))))