wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 4.811043021165421 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{x}{wj + 1}}{e^{wj}} + \mathsf{fma}\left(wj, wj, {wj}^{4} - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + \left(wj - \frac{wj}{wj + 1}\right)\\
\end{array}double f(double wj, double x) {
double r151542 = wj;
double r151543 = exp(r151542);
double r151544 = r151542 * r151543;
double r151545 = x;
double r151546 = r151544 - r151545;
double r151547 = r151543 + r151544;
double r151548 = r151546 / r151547;
double r151549 = r151542 - r151548;
return r151549;
}
double f(double wj, double x) {
double r151550 = wj;
double r151551 = 4.811043021165421e-08;
bool r151552 = r151550 <= r151551;
double r151553 = x;
double r151554 = 1.0;
double r151555 = r151550 + r151554;
double r151556 = r151553 / r151555;
double r151557 = exp(r151550);
double r151558 = r151556 / r151557;
double r151559 = 4.0;
double r151560 = pow(r151550, r151559);
double r151561 = 3.0;
double r151562 = pow(r151550, r151561);
double r151563 = r151560 - r151562;
double r151564 = fma(r151550, r151550, r151563);
double r151565 = r151558 + r151564;
double r151566 = r151557 * r151555;
double r151567 = r151553 / r151566;
double r151568 = r151550 / r151555;
double r151569 = r151550 - r151568;
double r151570 = r151567 + r151569;
double r151571 = r151552 ? r151565 : r151570;
return r151571;
}




Bits error versus wj




Bits error versus x
| Original | 13.8 |
|---|---|
| Target | 13.1 |
| Herbie | 0.3 |
if wj < 4.811043021165421e-08Initial program 13.4
Simplified13.4
rmApplied associate--l+6.9
Taylor expanded around 0 0.2
Simplified0.2
if 4.811043021165421e-08 < wj Initial program 28.7
Simplified2.3
rmApplied associate--l+2.3
rmApplied div-inv2.3
Applied associate-/l*2.3
Simplified2.3
Final simplification0.3
herbie shell --seed 2020089 +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))))))