wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -3.868446554170448 \cdot 10^{-310}:\\
\;\;\;\;x + \left({\left(\sqrt[3]{-1}\right)}^{2} \cdot {\left(\frac{-1}{wj}\right)}^{\frac{-2}{3}}\right) \cdot \left(\sqrt[3]{wj} \cdot \left(wj - 2 \cdot x\right)\right)\\
\mathbf{elif}\;wj \le 9.93050096655964495 \cdot 10^{-9}:\\
\;\;\;\;x + \left({\left({\left(\sqrt[3]{\sqrt[3]{wj}}\right)}^{\left(\sqrt[3]{4} \cdot \sqrt[3]{4}\right)}\right)}^{\left(\sqrt[3]{4}\right)} \cdot \left(\sqrt[3]{\sqrt[3]{wj}} \cdot \sqrt[3]{\sqrt[3]{wj}}\right)\right) \cdot \left(\sqrt[3]{wj} \cdot \left(wj - 2 \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + \frac{\frac{x}{e^{wj}}}{wj + 1}\\
\end{array}double code(double wj, double x) {
return ((double) (wj - (((double) (((double) (wj * ((double) exp(wj)))) - x)) / ((double) (((double) exp(wj)) + ((double) (wj * ((double) exp(wj)))))))));
}
double code(double wj, double x) {
double VAR;
if ((wj <= -3.86844655417045e-310)) {
VAR = ((double) (x + ((double) (((double) (((double) pow(((double) cbrt(-1.0)), 2.0)) * ((double) pow((-1.0 / wj), -0.6666666666666666)))) * ((double) (((double) cbrt(wj)) * ((double) (wj - ((double) (2.0 * x))))))))));
} else {
double VAR_1;
if ((wj <= 9.930500966559645e-09)) {
VAR_1 = ((double) (x + ((double) (((double) (((double) pow(((double) pow(((double) cbrt(((double) cbrt(wj)))), ((double) (((double) cbrt(4.0)) * ((double) cbrt(4.0)))))), ((double) cbrt(4.0)))) * ((double) (((double) cbrt(((double) cbrt(wj)))) * ((double) cbrt(((double) cbrt(wj)))))))) * ((double) (((double) cbrt(wj)) * ((double) (wj - ((double) (2.0 * x))))))))));
} else {
VAR_1 = ((double) (((double) (wj - (wj / ((double) (wj + 1.0))))) + ((x / ((double) exp(wj))) / ((double) (wj + 1.0)))));
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.3 |
|---|---|
| Target | 12.6 |
| Herbie | 1.4 |
if wj < -3.868446554170448e-310Initial program 13.2
Simplified13.2
Taylor expanded around 0 1.3
Simplified1.4
rmApplied add-cube-cbrt1.5
Applied associate-*l*1.6
Taylor expanded around -inf 1.9
Simplified1.9
if -3.868446554170448e-310 < wj < 9.93050096655964495e-9Initial program 12.6
Simplified12.6
Taylor expanded around 0 0.1
Simplified0.2
rmApplied add-cube-cbrt0.3
Applied associate-*l*0.3
rmApplied add-cube-cbrt0.4
Applied add-cube-cbrt0.4
Applied swap-sqr0.4
Simplified0.4
rmApplied add-cube-cbrt0.8
Applied pow-unpow0.8
if 9.93050096655964495e-9 < wj Initial program 27.2
Simplified2.5
rmApplied div-sub2.5
Applied associate--r-2.5
Final simplification1.4
herbie shell --seed 2020182
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))