wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -5.8145946613870445 \cdot 10^{-9}:\\
\;\;\;\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(wj, wj, x\right) - 2 \cdot \left(wj \cdot x\right)\\
\end{array}double f(double wj, double x) {
double r150067 = wj;
double r150068 = exp(r150067);
double r150069 = r150067 * r150068;
double r150070 = x;
double r150071 = r150069 - r150070;
double r150072 = r150068 + r150069;
double r150073 = r150071 / r150072;
double r150074 = r150067 - r150073;
return r150074;
}
double f(double wj, double x) {
double r150075 = wj;
double r150076 = -5.8145946613870445e-09;
bool r150077 = r150075 <= r150076;
double r150078 = exp(r150075);
double r150079 = r150075 * r150078;
double r150080 = x;
double r150081 = r150079 - r150080;
double r150082 = r150078 + r150079;
double r150083 = r150081 / r150082;
double r150084 = r150075 - r150083;
double r150085 = 1.0;
double r150086 = fma(r150075, r150075, r150080);
double r150087 = r150085 * r150086;
double r150088 = 2.0;
double r150089 = r150075 * r150080;
double r150090 = r150088 * r150089;
double r150091 = r150087 - r150090;
double r150092 = r150077 ? r150084 : r150091;
return r150092;
}




Bits error versus wj




Bits error versus x
| Original | 13.8 |
|---|---|
| Target | 13.3 |
| Herbie | 1.4 |
if wj < -5.8145946613870445e-09Initial program 4.7
if -5.8145946613870445e-09 < wj Initial program 14.0
Simplified13.5
Taylor expanded around 0 1.3
rmApplied *-un-lft-identity1.3
Applied *-un-lft-identity1.3
Applied distribute-lft-out1.3
Simplified1.3
Final simplification1.4
herbie shell --seed 2020047 +o rules:numerics
(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))))))