wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 1.855396681840028 \cdot 10^{-8}:\\
\;\;\;\;\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{\sqrt[3]{wj} \cdot \sqrt[3]{wj}}{\sqrt[3]{wj + 1} \cdot \sqrt[3]{wj + 1}} \cdot \frac{\sqrt[3]{wj}}{\sqrt[3]{wj + 1}}\\
\end{array}double code(double wj, double x) {
return (wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj)))));
}
double code(double wj, double x) {
double temp;
if ((wj <= 1.855396681840028e-08)) {
temp = ((x + pow(wj, 2.0)) - (2.0 * (wj * x)));
} else {
temp = ((((x / (wj + 1.0)) / exp(wj)) + wj) - (((cbrt(wj) * cbrt(wj)) / (cbrt((wj + 1.0)) * cbrt((wj + 1.0)))) * (cbrt(wj) / cbrt((wj + 1.0)))));
}
return temp;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.9 |
|---|---|
| Target | 13.4 |
| Herbie | 0.9 |
if wj < 1.855396681840028e-08Initial program 13.7
Simplified13.7
Taylor expanded around 0 0.8
if 1.855396681840028e-08 < wj Initial program 24.3
Simplified3.3
rmApplied add-cube-cbrt3.8
Applied add-cube-cbrt4.2
Applied times-frac4.1
Final simplification0.9
herbie shell --seed 2020066
(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))))))