wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -6.53889828412627139 \cdot 10^{-9}:\\
\;\;\;\;\left(\frac{x}{wj \cdot wj - 1} \cdot \frac{wj - 1}{e^{wj}} + wj\right) - \frac{wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\end{array}double code(double wj, double x) {
return ((double) (wj - ((double) (((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 <= -6.538898284126271e-09)) {
VAR = ((double) (((double) (((double) (((double) (x / ((double) (((double) (wj * wj)) - 1.0)))) * ((double) (((double) (wj - 1.0)) / ((double) exp(wj)))))) + wj)) - ((double) (wj / ((double) (wj + 1.0))))));
} else {
VAR = ((double) (((double) (x + ((double) pow(wj, 2.0)))) - ((double) (2.0 * ((double) (wj * x))))));
}
return VAR;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 1.4 |
if wj < -6.53889828412627139e-9Initial program 5.1
Simplified4.9
rmApplied *-un-lft-identity4.9
Applied flip-+5.0
Applied associate-/r/5.0
Applied times-frac5.0
Simplified5.0
if -6.53889828412627139e-9 < wj Initial program 13.8
Simplified13.2
Taylor expanded around 0 1.4
Final simplification1.4
herbie shell --seed 2020155
(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))))))