wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 2.114553828895713897623393276448133804024 \cdot 10^{-6}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) \cdot \left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1}}{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) + \frac{wj}{wj + 1}}\\
\end{array}double f(double wj, double x) {
double r261521 = wj;
double r261522 = exp(r261521);
double r261523 = r261521 * r261522;
double r261524 = x;
double r261525 = r261523 - r261524;
double r261526 = r261522 + r261523;
double r261527 = r261525 / r261526;
double r261528 = r261521 - r261527;
return r261528;
}
double f(double wj, double x) {
double r261529 = wj;
double r261530 = 2.114553828895714e-06;
bool r261531 = r261529 <= r261530;
double r261532 = x;
double r261533 = 2.0;
double r261534 = pow(r261529, r261533);
double r261535 = r261532 + r261534;
double r261536 = r261529 * r261532;
double r261537 = r261533 * r261536;
double r261538 = r261535 - r261537;
double r261539 = 1.0;
double r261540 = r261529 + r261539;
double r261541 = r261532 / r261540;
double r261542 = exp(r261529);
double r261543 = r261541 / r261542;
double r261544 = r261543 + r261529;
double r261545 = r261544 * r261544;
double r261546 = r261529 / r261540;
double r261547 = r261546 * r261546;
double r261548 = r261545 - r261547;
double r261549 = r261544 + r261546;
double r261550 = r261548 / r261549;
double r261551 = r261531 ? r261538 : r261550;
return r261551;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.8 |
|---|---|
| Target | 13.2 |
| Herbie | 1.2 |
if wj < 2.114553828895714e-06Initial program 13.5
Simplified13.5
Taylor expanded around 0 1.0
if 2.114553828895714e-06 < wj Initial program 26.2
Simplified1.9
rmApplied flip--10.7
Final simplification1.2
herbie shell --seed 2019356
(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))))))