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 r127764 = wj;
double r127765 = exp(r127764);
double r127766 = r127764 * r127765;
double r127767 = x;
double r127768 = r127766 - r127767;
double r127769 = r127765 + r127766;
double r127770 = r127768 / r127769;
double r127771 = r127764 - r127770;
return r127771;
}
double f(double wj, double x) {
double r127772 = wj;
double r127773 = 8.133938014656618e-09;
bool r127774 = r127772 <= r127773;
double r127775 = x;
double r127776 = r127772 * r127775;
double r127777 = -2.0;
double r127778 = fma(r127772, r127772, r127775);
double r127779 = fma(r127776, r127777, r127778);
double r127780 = exp(r127772);
double r127781 = sqrt(r127780);
double r127782 = r127775 / r127781;
double r127783 = r127782 / r127781;
double r127784 = r127772 - r127783;
double r127785 = 1.0;
double r127786 = r127785 + r127772;
double r127787 = r127784 / r127786;
double r127788 = r127772 - r127787;
double r127789 = r127774 ? r127779 : r127788;
return r127789;
}




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))))))