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 r186659 = wj;
double r186660 = exp(r186659);
double r186661 = r186659 * r186660;
double r186662 = x;
double r186663 = r186661 - r186662;
double r186664 = r186660 + r186661;
double r186665 = r186663 / r186664;
double r186666 = r186659 - r186665;
return r186666;
}
double f(double wj, double x) {
double r186667 = wj;
double r186668 = 8.133938014656618e-09;
bool r186669 = r186667 <= r186668;
double r186670 = x;
double r186671 = 2.0;
double r186672 = r186670 * r186671;
double r186673 = r186667 - r186672;
double r186674 = r186667 * r186673;
double r186675 = r186670 + r186674;
double r186676 = exp(r186667);
double r186677 = sqrt(r186676);
double r186678 = r186670 / r186677;
double r186679 = r186678 / r186677;
double r186680 = r186667 - r186679;
double r186681 = 1.0;
double r186682 = r186667 + r186681;
double r186683 = r186680 / r186682;
double r186684 = r186667 - r186683;
double r186685 = r186669 ? r186675 : r186684;
return r186685;
}




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