wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 8.133938014656618390032425086177275685984 \cdot 10^{-9}:\\
\;\;\;\;x + wj \cdot \left(wj - x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{\frac{x}{\sqrt{e^{wj}}}}{\sqrt{e^{wj}}}}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r225222 = wj;
double r225223 = exp(r225222);
double r225224 = r225222 * r225223;
double r225225 = x;
double r225226 = r225224 - r225225;
double r225227 = r225223 + r225224;
double r225228 = r225226 / r225227;
double r225229 = r225222 - r225228;
return r225229;
}
double f(double wj, double x) {
double r225230 = wj;
double r225231 = 8.133938014656618e-09;
bool r225232 = r225230 <= r225231;
double r225233 = x;
double r225234 = 2.0;
double r225235 = r225233 * r225234;
double r225236 = r225230 - r225235;
double r225237 = r225230 * r225236;
double r225238 = r225233 + r225237;
double r225239 = exp(r225230);
double r225240 = sqrt(r225239);
double r225241 = r225233 / r225240;
double r225242 = r225241 / r225240;
double r225243 = r225230 - r225242;
double r225244 = 1.0;
double r225245 = r225230 + r225244;
double r225246 = r225243 / r225245;
double r225247 = r225230 - r225246;
double r225248 = r225232 ? r225238 : r225247;
return r225248;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.9 |
|---|---|
| Target | 13.2 |
| Herbie | 1.0 |
if wj < 8.133938014656618e-09Initial program 13.5
Simplified13.5
Taylor expanded around 0 1.0
Simplified1.0
if 8.133938014656618e-09 < wj Initial program 27.6
Simplified2.3
rmApplied add-sqr-sqrt2.4
Applied associate-/r*2.3
Final simplification1.0
herbie shell --seed 2019325
(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))))))