wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 3.10884342589449778 \cdot 10^{-6}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} \cdot \frac{\frac{x}{wj + 1}}{e^{wj}} - wj \cdot wj\right) \cdot \left(wj + 1\right) - \left(\frac{\frac{x}{wj + 1}}{e^{wj}} - wj\right) \cdot wj}{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} - wj\right) \cdot \left(wj + 1\right)}\\
\end{array}double f(double wj, double x) {
double r285911 = wj;
double r285912 = exp(r285911);
double r285913 = r285911 * r285912;
double r285914 = x;
double r285915 = r285913 - r285914;
double r285916 = r285912 + r285913;
double r285917 = r285915 / r285916;
double r285918 = r285911 - r285917;
return r285918;
}
double f(double wj, double x) {
double r285919 = wj;
double r285920 = 3.1088434258944978e-06;
bool r285921 = r285919 <= r285920;
double r285922 = x;
double r285923 = 2.0;
double r285924 = pow(r285919, r285923);
double r285925 = r285922 + r285924;
double r285926 = r285919 * r285922;
double r285927 = r285923 * r285926;
double r285928 = r285925 - r285927;
double r285929 = 1.0;
double r285930 = r285919 + r285929;
double r285931 = r285922 / r285930;
double r285932 = exp(r285919);
double r285933 = r285931 / r285932;
double r285934 = r285933 * r285933;
double r285935 = r285919 * r285919;
double r285936 = r285934 - r285935;
double r285937 = r285936 * r285930;
double r285938 = r285933 - r285919;
double r285939 = r285938 * r285919;
double r285940 = r285937 - r285939;
double r285941 = r285938 * r285930;
double r285942 = r285940 / r285941;
double r285943 = r285921 ? r285928 : r285942;
return r285943;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.4 |
|---|---|
| Target | 12.8 |
| Herbie | 1.2 |
if wj < 3.1088434258944978e-06Initial program 13.1
Simplified13.1
Taylor expanded around 0 1.0
if 3.1088434258944978e-06 < wj Initial program 27.7
Simplified1.7
rmApplied flip-+10.6
Applied frac-sub10.7
Final simplification1.2
herbie shell --seed 2020039 +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))))))