wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.293516541346027667620105505719152461097 \cdot 10^{-5}:\\
\;\;\;\;\frac{\frac{x}{wj + 1}}{e^{wj}} + \left(\left({wj}^{4} + {wj}^{2}\right) - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{wj \cdot wj - 1} \cdot \frac{wj - 1}{e^{wj}} + \left(wj - \frac{wj}{wj + 1}\right)\\
\end{array}double f(double wj, double x) {
double r490003 = wj;
double r490004 = exp(r490003);
double r490005 = r490003 * r490004;
double r490006 = x;
double r490007 = r490005 - r490006;
double r490008 = r490004 + r490005;
double r490009 = r490007 / r490008;
double r490010 = r490003 - r490009;
return r490010;
}
double f(double wj, double x) {
double r490011 = wj;
double r490012 = 9.293516541346028e-05;
bool r490013 = r490011 <= r490012;
double r490014 = x;
double r490015 = 1.0;
double r490016 = r490011 + r490015;
double r490017 = r490014 / r490016;
double r490018 = exp(r490011);
double r490019 = r490017 / r490018;
double r490020 = 4.0;
double r490021 = pow(r490011, r490020);
double r490022 = 2.0;
double r490023 = pow(r490011, r490022);
double r490024 = r490021 + r490023;
double r490025 = 3.0;
double r490026 = pow(r490011, r490025);
double r490027 = r490024 - r490026;
double r490028 = r490019 + r490027;
double r490029 = r490011 * r490011;
double r490030 = r490029 - r490015;
double r490031 = r490014 / r490030;
double r490032 = r490011 - r490015;
double r490033 = r490032 / r490018;
double r490034 = r490031 * r490033;
double r490035 = r490011 / r490016;
double r490036 = r490011 - r490035;
double r490037 = r490034 + r490036;
double r490038 = r490013 ? r490028 : r490037;
return r490038;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 0.2 |
if wj < 9.293516541346028e-05Initial program 13.4
Simplified13.3
rmApplied associate--l+6.9
Taylor expanded around 0 0.2
if 9.293516541346028e-05 < wj Initial program 30.9
Simplified1.0
rmApplied associate--l+1.0
rmApplied *-un-lft-identity1.0
Applied flip-+1.0
Applied associate-/r/1.0
Applied times-frac1.0
Simplified1.0
Final simplification0.2
herbie shell --seed 2019362
(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))))))