wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 8.133938014656618390032425086177275685984 \cdot 10^{-9}:\\
\;\;\;\;x + wj \cdot \left(wj - x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{\frac{x}{\sqrt{e^{wj}}}}{\sqrt{e^{wj}}}}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r167932 = wj;
double r167933 = exp(r167932);
double r167934 = r167932 * r167933;
double r167935 = x;
double r167936 = r167934 - r167935;
double r167937 = r167933 + r167934;
double r167938 = r167936 / r167937;
double r167939 = r167932 - r167938;
return r167939;
}
double f(double wj, double x) {
double r167940 = wj;
double r167941 = 8.133938014656618e-09;
bool r167942 = r167940 <= r167941;
double r167943 = x;
double r167944 = 2.0;
double r167945 = r167943 * r167944;
double r167946 = r167940 - r167945;
double r167947 = r167940 * r167946;
double r167948 = r167943 + r167947;
double r167949 = exp(r167940);
double r167950 = sqrt(r167949);
double r167951 = r167943 / r167950;
double r167952 = r167951 / r167950;
double r167953 = r167940 - r167952;
double r167954 = 1.0;
double r167955 = r167940 + r167954;
double r167956 = r167953 / r167955;
double r167957 = r167940 - r167956;
double r167958 = r167942 ? r167948 : r167957;
return r167958;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.9 |
|---|---|
| Target | 13.2 |
| Herbie | 1.0 |
if wj < 8.133938014656618e-09Initial program 13.5
Simplified13.5
Taylor expanded around 0 1.0
Simplified1.0
if 8.133938014656618e-09 < wj Initial program 27.6
Simplified2.3
rmApplied add-sqr-sqrt2.4
Applied associate-/r*2.3
Final simplification1.0
herbie shell --seed 2019325
(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))))))