wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 1.08704555276393653483273218961560613316 \cdot 10^{-8}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj \cdot wj - 1} \cdot \left(wj - 1\right)\\
\end{array}double f(double wj, double x) {
double r347102 = wj;
double r347103 = exp(r347102);
double r347104 = r347102 * r347103;
double r347105 = x;
double r347106 = r347104 - r347105;
double r347107 = r347103 + r347104;
double r347108 = r347106 / r347107;
double r347109 = r347102 - r347108;
return r347109;
}
double f(double wj, double x) {
double r347110 = wj;
double r347111 = 1.0870455527639365e-08;
bool r347112 = r347110 <= r347111;
double r347113 = x;
double r347114 = 2.0;
double r347115 = pow(r347110, r347114);
double r347116 = r347113 + r347115;
double r347117 = r347110 * r347113;
double r347118 = r347114 * r347117;
double r347119 = r347116 - r347118;
double r347120 = 1.0;
double r347121 = r347110 + r347120;
double r347122 = r347113 / r347121;
double r347123 = exp(r347110);
double r347124 = r347122 / r347123;
double r347125 = r347124 + r347110;
double r347126 = r347110 * r347110;
double r347127 = r347126 - r347120;
double r347128 = r347110 / r347127;
double r347129 = r347110 - r347120;
double r347130 = r347128 * r347129;
double r347131 = r347125 - r347130;
double r347132 = r347112 ? r347119 : r347131;
return r347132;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.5 |
|---|---|
| Target | 12.9 |
| Herbie | 1.0 |
if wj < 1.0870455527639365e-08Initial program 13.1
Simplified13.1
Taylor expanded around 0 0.9
if 1.0870455527639365e-08 < wj Initial program 25.4
Simplified2.8
rmApplied flip-+2.8
Applied associate-/r/2.8
Simplified2.8
Final simplification1.0
herbie shell --seed 2020002
(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))))))