wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.293516541346027667620105505719152461097 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{x}{wj + 1}}{e^{wj}} + \mathsf{fma}\left(wj, wj, {wj}^{4} - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{wj \cdot wj - 1} \cdot \frac{wj - 1}{e^{wj}} + \left(wj - \frac{wj}{wj + 1}\right)\\
\end{array}double f(double wj, double x) {
double r232390 = wj;
double r232391 = exp(r232390);
double r232392 = r232390 * r232391;
double r232393 = x;
double r232394 = r232392 - r232393;
double r232395 = r232391 + r232392;
double r232396 = r232394 / r232395;
double r232397 = r232390 - r232396;
return r232397;
}
double f(double wj, double x) {
double r232398 = wj;
double r232399 = 9.293516541346028e-05;
bool r232400 = r232398 <= r232399;
double r232401 = x;
double r232402 = 1.0;
double r232403 = r232398 + r232402;
double r232404 = r232401 / r232403;
double r232405 = exp(r232398);
double r232406 = r232404 / r232405;
double r232407 = 4.0;
double r232408 = pow(r232398, r232407);
double r232409 = 3.0;
double r232410 = pow(r232398, r232409);
double r232411 = r232408 - r232410;
double r232412 = fma(r232398, r232398, r232411);
double r232413 = r232406 + r232412;
double r232414 = r232398 * r232398;
double r232415 = r232414 - r232402;
double r232416 = r232401 / r232415;
double r232417 = r232398 - r232402;
double r232418 = r232417 / r232405;
double r232419 = r232416 * r232418;
double r232420 = r232398 / r232403;
double r232421 = r232398 - r232420;
double r232422 = r232419 + r232421;
double r232423 = r232400 ? r232413 : r232422;
return r232423;
}




Bits error versus wj




Bits error versus x
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 0.2 |
if wj < 9.293516541346028e-05Initial program 13.4
Simplified13.3
rmApplied associate--l+6.9
Taylor expanded around 0 0.2
Simplified0.2
if 9.293516541346028e-05 < wj Initial program 30.9
Simplified1.0
rmApplied associate--l+1.0
rmApplied *-un-lft-identity1.0
Applied flip-+1.0
Applied associate-/r/1.0
Applied times-frac1.0
Simplified1.0
Final simplification0.2
herbie shell --seed 2019362 +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))))))