wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 5.801891356124452416919000006471224262228 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot x, -2, \mathsf{fma}\left(wj, wj, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(wj - 1, \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, -wj, 1\right)}, wj\right) + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, -wj, 1\right)} \cdot \left(\left(wj - 1\right) + \left(1 - wj\right)\right)\\
\end{array}double f(double wj, double x) {
double r225534 = wj;
double r225535 = exp(r225534);
double r225536 = r225534 * r225535;
double r225537 = x;
double r225538 = r225536 - r225537;
double r225539 = r225535 + r225536;
double r225540 = r225538 / r225539;
double r225541 = r225534 - r225540;
return r225541;
}
double f(double wj, double x) {
double r225542 = wj;
double r225543 = 5.8018913561244524e-09;
bool r225544 = r225542 <= r225543;
double r225545 = x;
double r225546 = r225542 * r225545;
double r225547 = -2.0;
double r225548 = fma(r225542, r225542, r225545);
double r225549 = fma(r225546, r225547, r225548);
double r225550 = 1.0;
double r225551 = r225542 - r225550;
double r225552 = exp(r225542);
double r225553 = r225545 / r225552;
double r225554 = r225542 - r225553;
double r225555 = -r225542;
double r225556 = fma(r225542, r225555, r225550);
double r225557 = r225554 / r225556;
double r225558 = fma(r225551, r225557, r225542);
double r225559 = r225550 - r225542;
double r225560 = r225551 + r225559;
double r225561 = r225557 * r225560;
double r225562 = r225558 + r225561;
double r225563 = r225544 ? r225549 : r225562;
return r225563;
}




Bits error versus wj




Bits error versus x
| Original | 14.0 |
|---|---|
| Target | 13.4 |
| Herbie | 0.9 |
if wj < 5.8018913561244524e-09Initial program 13.6
Simplified13.6
Taylor expanded around 0 0.8
Simplified0.8
if 5.8018913561244524e-09 < wj Initial program 26.5
Simplified3.9
rmApplied flip-+4.1
Applied associate-/r/4.0
Applied add-sqr-sqrt4.4
Applied prod-diff4.3
Simplified3.8
Simplified3.8
Final simplification0.9
herbie shell --seed 2019326 +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))))))