wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 1.48959693341686037244700827053556224655 \cdot 10^{-5}:\\
\;\;\;\;\left(\left({wj}^{4} + {wj}^{2}\right) - {wj}^{3}\right) + \left(\left(wj \cdot \left(\frac{5}{2} \cdot wj - 2\right)\right) \cdot x + x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + \frac{x}{\left(1 + wj\right) \cdot e^{wj}}\\
\end{array}double f(double wj, double x) {
double r189947 = wj;
double r189948 = exp(r189947);
double r189949 = r189947 * r189948;
double r189950 = x;
double r189951 = r189949 - r189950;
double r189952 = r189948 + r189949;
double r189953 = r189951 / r189952;
double r189954 = r189947 - r189953;
return r189954;
}
double f(double wj, double x) {
double r189955 = wj;
double r189956 = 1.4895969334168604e-05;
bool r189957 = r189955 <= r189956;
double r189958 = 4.0;
double r189959 = pow(r189955, r189958);
double r189960 = 2.0;
double r189961 = pow(r189955, r189960);
double r189962 = r189959 + r189961;
double r189963 = 3.0;
double r189964 = pow(r189955, r189963);
double r189965 = r189962 - r189964;
double r189966 = 2.5;
double r189967 = r189966 * r189955;
double r189968 = r189967 - r189960;
double r189969 = r189955 * r189968;
double r189970 = x;
double r189971 = r189969 * r189970;
double r189972 = r189971 + r189970;
double r189973 = r189965 + r189972;
double r189974 = 1.0;
double r189975 = r189955 + r189974;
double r189976 = r189955 / r189975;
double r189977 = r189955 - r189976;
double r189978 = r189974 + r189955;
double r189979 = exp(r189955);
double r189980 = r189978 * r189979;
double r189981 = r189970 / r189980;
double r189982 = r189977 + r189981;
double r189983 = r189957 ? r189973 : r189982;
return r189983;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.0 |
| Herbie | 0.6 |
if wj < 1.4895969334168604e-05Initial program 13.3
Simplified13.3
rmApplied div-sub13.3
Applied associate--r-6.9
Taylor expanded around 0 0.3
Taylor expanded around 0 0.6
Simplified0.6
if 1.4895969334168604e-05 < wj Initial program 30.1
Simplified1.2
rmApplied div-sub1.2
Applied associate--r-1.2
rmApplied div-inv1.2
Applied associate-/l*1.2
Simplified1.2
Final simplification0.6
herbie shell --seed 2019347
(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))))))