wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 8.976401343690175460051364946315044512914 \cdot 10^{-9}:\\
\;\;\;\;x + wj \cdot \left(wj - 2 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{1}{\sqrt{wj + 1}} \cdot \frac{wj - \frac{x}{e^{wj}}}{\sqrt{wj + 1}}\\
\end{array}double f(double wj, double x) {
double r237706 = wj;
double r237707 = exp(r237706);
double r237708 = r237706 * r237707;
double r237709 = x;
double r237710 = r237708 - r237709;
double r237711 = r237707 + r237708;
double r237712 = r237710 / r237711;
double r237713 = r237706 - r237712;
return r237713;
}
double f(double wj, double x) {
double r237714 = wj;
double r237715 = 8.976401343690175e-09;
bool r237716 = r237714 <= r237715;
double r237717 = x;
double r237718 = 2.0;
double r237719 = r237718 * r237717;
double r237720 = r237714 - r237719;
double r237721 = r237714 * r237720;
double r237722 = r237717 + r237721;
double r237723 = 1.0;
double r237724 = r237714 + r237723;
double r237725 = sqrt(r237724);
double r237726 = r237723 / r237725;
double r237727 = exp(r237714);
double r237728 = r237717 / r237727;
double r237729 = r237714 - r237728;
double r237730 = r237729 / r237725;
double r237731 = r237726 * r237730;
double r237732 = r237714 - r237731;
double r237733 = r237716 ? r237722 : r237732;
return r237733;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.0 |
|---|---|
| Target | 13.4 |
| Herbie | 1.0 |
if wj < 8.976401343690175e-09Initial program 13.6
Simplified13.6
Taylor expanded around 0 0.8
Simplified0.9
if 8.976401343690175e-09 < wj Initial program 26.6
Simplified3.8
rmApplied clear-num3.9
rmApplied *-un-lft-identity3.9
Applied add-sqr-sqrt4.3
Applied times-frac4.2
Applied add-cube-cbrt4.2
Applied times-frac4.2
Simplified4.2
Simplified4.3
Final simplification1.0
herbie shell --seed 2019326
(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))))))