wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 3.2387214544875811 \cdot 10^{-28}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{1}{\frac{wj + 1}{wj}}\\
\end{array}double f(double wj, double x) {
double r213229 = wj;
double r213230 = exp(r213229);
double r213231 = r213229 * r213230;
double r213232 = x;
double r213233 = r213231 - r213232;
double r213234 = r213230 + r213231;
double r213235 = r213233 / r213234;
double r213236 = r213229 - r213235;
return r213236;
}
double f(double wj, double x) {
double r213237 = wj;
double r213238 = 3.238721454487581e-28;
bool r213239 = r213237 <= r213238;
double r213240 = x;
double r213241 = 2.0;
double r213242 = pow(r213237, r213241);
double r213243 = r213240 + r213242;
double r213244 = r213237 * r213240;
double r213245 = r213241 * r213244;
double r213246 = r213243 - r213245;
double r213247 = 1.0;
double r213248 = r213237 + r213247;
double r213249 = r213240 / r213248;
double r213250 = exp(r213237);
double r213251 = r213249 / r213250;
double r213252 = r213251 + r213237;
double r213253 = r213248 / r213237;
double r213254 = r213247 / r213253;
double r213255 = r213252 - r213254;
double r213256 = r213239 ? r213246 : r213255;
return r213256;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.0 |
|---|---|
| Target | 13.3 |
| Herbie | 1.5 |
if wj < 3.238721454487581e-28Initial program 13.4
Simplified13.4
Taylor expanded around 0 0.9
if 3.238721454487581e-28 < wj Initial program 24.5
Simplified11.8
rmApplied clear-num11.8
Final simplification1.5
herbie shell --seed 2020083
(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))))))