wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le 1.043870210665429517076386450868952238125 \cdot 10^{-17}:\\
\;\;\;\;\left(x + wj \cdot wj\right) - \left(wj + wj\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{\frac{wj \cdot e^{wj} - x}{e^{wj}}}{1 + wj}\\
\end{array}double f(double wj, double x) {
double r18778657 = wj;
double r18778658 = exp(r18778657);
double r18778659 = r18778657 * r18778658;
double r18778660 = x;
double r18778661 = r18778659 - r18778660;
double r18778662 = r18778658 + r18778659;
double r18778663 = r18778661 / r18778662;
double r18778664 = r18778657 - r18778663;
return r18778664;
}
double f(double wj, double x) {
double r18778665 = wj;
double r18778666 = exp(r18778665);
double r18778667 = r18778665 * r18778666;
double r18778668 = x;
double r18778669 = r18778667 - r18778668;
double r18778670 = r18778666 + r18778667;
double r18778671 = r18778669 / r18778670;
double r18778672 = r18778665 - r18778671;
double r18778673 = 1.0438702106654295e-17;
bool r18778674 = r18778672 <= r18778673;
double r18778675 = r18778665 * r18778665;
double r18778676 = r18778668 + r18778675;
double r18778677 = r18778665 + r18778665;
double r18778678 = r18778677 * r18778668;
double r18778679 = r18778676 - r18778678;
double r18778680 = r18778669 / r18778666;
double r18778681 = 1.0;
double r18778682 = r18778681 + r18778665;
double r18778683 = r18778680 / r18778682;
double r18778684 = r18778665 - r18778683;
double r18778685 = r18778674 ? r18778679 : r18778684;
return r18778685;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.0 |
| Herbie | 1.4 |
if (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < 1.0438702106654295e-17Initial program 17.8
Taylor expanded around 0 0.8
Simplified0.8
if 1.0438702106654295e-17 < (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) Initial program 3.1
rmApplied *-un-lft-identity3.1
Applied distribute-rgt-out3.1
Applied associate-/r*3.1
Final simplification1.4
herbie shell --seed 2019173
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))