wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.715218772498828 \cdot 10^{-07}:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot wj, wj \cdot wj, \mathsf{fma}\left(wj, wj, -\left(wj \cdot wj\right) \cdot wj\right)\right) + \frac{x}{e^{wj} \cdot wj + e^{wj}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot wj + e^{wj}} + \left(wj - \frac{wj}{1 + wj}\right)\\
\end{array}double f(double wj, double x) {
double r7625989 = wj;
double r7625990 = exp(r7625989);
double r7625991 = r7625989 * r7625990;
double r7625992 = x;
double r7625993 = r7625991 - r7625992;
double r7625994 = r7625990 + r7625991;
double r7625995 = r7625993 / r7625994;
double r7625996 = r7625989 - r7625995;
return r7625996;
}
double f(double wj, double x) {
double r7625997 = wj;
double r7625998 = 6.715218772498828e-07;
bool r7625999 = r7625997 <= r7625998;
double r7626000 = r7625997 * r7625997;
double r7626001 = r7626000 * r7625997;
double r7626002 = -r7626001;
double r7626003 = fma(r7625997, r7625997, r7626002);
double r7626004 = fma(r7626000, r7626000, r7626003);
double r7626005 = x;
double r7626006 = exp(r7625997);
double r7626007 = r7626006 * r7625997;
double r7626008 = r7626007 + r7626006;
double r7626009 = r7626005 / r7626008;
double r7626010 = r7626004 + r7626009;
double r7626011 = 1.0;
double r7626012 = r7626011 + r7625997;
double r7626013 = r7625997 / r7626012;
double r7626014 = r7625997 - r7626013;
double r7626015 = r7626009 + r7626014;
double r7626016 = r7625999 ? r7626010 : r7626015;
return r7626016;
}




Bits error versus wj




Bits error versus x
| Original | 13.3 |
|---|---|
| Target | 12.7 |
| Herbie | 0.4 |
if wj < 6.715218772498828e-07Initial program 13.0
rmApplied div-sub13.0
Applied associate--r-6.9
Taylor expanded around 0 0.3
Simplified0.3
rmApplied fma-neg0.3
if 6.715218772498828e-07 < wj Initial program 26.6
rmApplied div-sub26.6
Applied associate--r-26.6
rmApplied *-un-lft-identity26.6
Applied distribute-rgt-out26.7
Applied associate-/r*26.4
Simplified2.0
Final simplification0.4
herbie shell --seed 2019158 +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))