wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.381542263961784 \cdot 10^{-9}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj \cdot wj - 1} \cdot \left(wj - 1\right)\\
\end{array}double f(double wj, double x) {
double r395851 = wj;
double r395852 = exp(r395851);
double r395853 = r395851 * r395852;
double r395854 = x;
double r395855 = r395853 - r395854;
double r395856 = r395852 + r395853;
double r395857 = r395855 / r395856;
double r395858 = r395851 - r395857;
return r395858;
}
double f(double wj, double x) {
double r395859 = wj;
double r395860 = 6.381542263961784e-09;
bool r395861 = r395859 <= r395860;
double r395862 = x;
double r395863 = 2.0;
double r395864 = pow(r395859, r395863);
double r395865 = r395862 + r395864;
double r395866 = r395859 * r395862;
double r395867 = r395863 * r395866;
double r395868 = r395865 - r395867;
double r395869 = 1.0;
double r395870 = r395859 + r395869;
double r395871 = r395862 / r395870;
double r395872 = exp(r395859);
double r395873 = r395871 / r395872;
double r395874 = r395873 + r395859;
double r395875 = r395859 * r395859;
double r395876 = r395875 - r395869;
double r395877 = r395859 / r395876;
double r395878 = r395859 - r395869;
double r395879 = r395877 * r395878;
double r395880 = r395874 - r395879;
double r395881 = r395861 ? r395868 : r395880;
return r395881;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.4 |
|---|---|
| Target | 12.8 |
| Herbie | 1.0 |
if wj < 6.381542263961784e-09Initial program 13.1
Simplified13.1
Taylor expanded around 0 0.9
if 6.381542263961784e-09 < wj Initial program 24.3
Simplified3.2
rmApplied flip-+3.4
Applied associate-/r/3.3
Simplified3.3
Final simplification1.0
herbie shell --seed 2020034
(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))))))