wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 5.3258678519809691 \cdot 10^{-17}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{wj \cdot \left(\frac{\frac{x}{wj + 1}}{e^{wj}} \cdot \frac{\frac{x}{wj + 1}}{e^{wj}} - wj \cdot wj\right) + \left(1 \cdot \left(\frac{\frac{x}{wj + 1}}{e^{wj}} \cdot \frac{\frac{x}{wj + 1}}{e^{wj}} - wj \cdot wj\right) - \left(\frac{\frac{x}{wj + 1}}{e^{wj}} - wj\right) \cdot wj\right)}{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} - wj\right) \cdot \left(wj + 1\right)}\\
\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 <= 5.325867851980969e-17)) {
temp = ((x + pow(wj, 2.0)) - (2.0 * (wj * x)));
} else {
temp = (((wj * ((((x / (wj + 1.0)) / exp(wj)) * ((x / (wj + 1.0)) / exp(wj))) - (wj * wj))) + ((1.0 * ((((x / (wj + 1.0)) / exp(wj)) * ((x / (wj + 1.0)) / exp(wj))) - (wj * wj))) - ((((x / (wj + 1.0)) / exp(wj)) - wj) * wj))) / ((((x / (wj + 1.0)) / exp(wj)) - wj) * (wj + 1.0)));
}
return temp;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 1.2 |
if wj < 5.325867851980969e-17Initial program 13.3
Simplified13.3
Taylor expanded around 0 0.8
if 5.325867851980969e-17 < wj Initial program 24.5
Simplified7.3
rmApplied flip-+16.8
Applied frac-sub17.0
rmApplied distribute-rgt-in16.8
Applied associate--l+10.7
Final simplification1.2
herbie shell --seed 2020049
(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))))))