wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.06252678575455972 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(wj, wj, x\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj \cdot wj - 1} \cdot \left(wj - 1\right)\\
\end{array}double f(double wj, double x) {
double r250087 = wj;
double r250088 = exp(r250087);
double r250089 = r250087 * r250088;
double r250090 = x;
double r250091 = r250089 - r250090;
double r250092 = r250088 + r250089;
double r250093 = r250091 / r250092;
double r250094 = r250087 - r250093;
return r250094;
}
double f(double wj, double x) {
double r250095 = wj;
double r250096 = 9.06252678575456e-09;
bool r250097 = r250095 <= r250096;
double r250098 = x;
double r250099 = fma(r250095, r250095, r250098);
double r250100 = 2.0;
double r250101 = r250095 * r250098;
double r250102 = r250100 * r250101;
double r250103 = r250099 - r250102;
double r250104 = 1.0;
double r250105 = r250095 + r250104;
double r250106 = r250098 / r250105;
double r250107 = exp(r250095);
double r250108 = r250106 / r250107;
double r250109 = r250108 + r250095;
double r250110 = r250095 * r250095;
double r250111 = r250110 - r250104;
double r250112 = r250095 / r250111;
double r250113 = r250095 - r250104;
double r250114 = r250112 * r250113;
double r250115 = r250109 - r250114;
double r250116 = r250097 ? r250103 : r250115;
return r250116;
}




Bits error versus wj




Bits error versus x
| Original | 14.2 |
|---|---|
| Target | 13.5 |
| Herbie | 1.1 |
if wj < 9.06252678575456e-09Initial program 13.9
Simplified13.9
Taylor expanded around 0 1.0
Taylor expanded around 0 1.0
Simplified1.0
if 9.06252678575456e-09 < wj Initial program 26.3
Simplified3.1
rmApplied flip-+3.2
Applied associate-/r/3.0
Simplified3.0
Final simplification1.1
herbie shell --seed 2020035 +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))))))