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}:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot x, -2, \mathsf{fma}\left(wj, wj, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{\frac{x}{\sqrt{e^{wj}}}}{\sqrt{e^{wj}}}}{1 + wj}\\
\end{array}double f(double wj, double x) {
double r126075 = wj;
double r126076 = exp(r126075);
double r126077 = r126075 * r126076;
double r126078 = x;
double r126079 = r126077 - r126078;
double r126080 = r126076 + r126077;
double r126081 = r126079 / r126080;
double r126082 = r126075 - r126081;
return r126082;
}
double f(double wj, double x) {
double r126083 = wj;
double r126084 = 8.133938014656618e-09;
bool r126085 = r126083 <= r126084;
double r126086 = x;
double r126087 = r126083 * r126086;
double r126088 = -2.0;
double r126089 = fma(r126083, r126083, r126086);
double r126090 = fma(r126087, r126088, r126089);
double r126091 = exp(r126083);
double r126092 = sqrt(r126091);
double r126093 = r126086 / r126092;
double r126094 = r126093 / r126092;
double r126095 = r126083 - r126094;
double r126096 = 1.0;
double r126097 = r126096 + r126083;
double r126098 = r126095 / r126097;
double r126099 = r126083 - r126098;
double r126100 = r126085 ? r126090 : r126099;
return r126100;
}




Bits error versus wj




Bits error versus x
| 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 +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))))))