wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.444094386194336532475590329253553600886 \cdot 10^{-9}:\\
\;\;\;\;wj \cdot \left(wj - 2 \cdot x\right) + x\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + \frac{\frac{x}{e^{wj}}}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r354201 = wj;
double r354202 = exp(r354201);
double r354203 = r354201 * r354202;
double r354204 = x;
double r354205 = r354203 - r354204;
double r354206 = r354202 + r354203;
double r354207 = r354205 / r354206;
double r354208 = r354201 - r354207;
return r354208;
}
double f(double wj, double x) {
double r354209 = wj;
double r354210 = 6.4440943861943365e-09;
bool r354211 = r354209 <= r354210;
double r354212 = 2.0;
double r354213 = x;
double r354214 = r354212 * r354213;
double r354215 = r354209 - r354214;
double r354216 = r354209 * r354215;
double r354217 = r354216 + r354213;
double r354218 = 1.0;
double r354219 = r354209 + r354218;
double r354220 = r354209 / r354219;
double r354221 = r354209 - r354220;
double r354222 = exp(r354209);
double r354223 = r354213 / r354222;
double r354224 = r354223 / r354219;
double r354225 = r354221 + r354224;
double r354226 = r354211 ? r354217 : r354225;
return r354226;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.6 |
|---|---|
| Target | 12.9 |
| Herbie | 0.9 |
if wj < 6.4440943861943365e-09Initial program 13.2
Simplified13.2
Taylor expanded around 0 0.9
Simplified0.9
if 6.4440943861943365e-09 < wj Initial program 27.2
Simplified2.7
rmApplied div-sub2.7
Applied associate--r-2.7
Final simplification0.9
herbie shell --seed 2019351
(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))))))