wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 1.425827286753258358087311776993266754232 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot x, -2, \mathsf{fma}\left(wj, wj, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{{wj}^{3} - {\left(\frac{x}{e^{wj}}\right)}^{3}}{\mathsf{fma}\left(wj, wj, \frac{x}{e^{wj}} \cdot \left(wj + \frac{x}{e^{wj}}\right)\right) \cdot \left(1 + wj\right)}\\
\end{array}double f(double wj, double x) {
double r131703 = wj;
double r131704 = exp(r131703);
double r131705 = r131703 * r131704;
double r131706 = x;
double r131707 = r131705 - r131706;
double r131708 = r131704 + r131705;
double r131709 = r131707 / r131708;
double r131710 = r131703 - r131709;
return r131710;
}
double f(double wj, double x) {
double r131711 = wj;
double r131712 = 1.4258272867532584e-07;
bool r131713 = r131711 <= r131712;
double r131714 = x;
double r131715 = r131711 * r131714;
double r131716 = -2.0;
double r131717 = fma(r131711, r131711, r131714);
double r131718 = fma(r131715, r131716, r131717);
double r131719 = 3.0;
double r131720 = pow(r131711, r131719);
double r131721 = exp(r131711);
double r131722 = r131714 / r131721;
double r131723 = pow(r131722, r131719);
double r131724 = r131720 - r131723;
double r131725 = r131711 + r131722;
double r131726 = r131722 * r131725;
double r131727 = fma(r131711, r131711, r131726);
double r131728 = 1.0;
double r131729 = r131728 + r131711;
double r131730 = r131727 * r131729;
double r131731 = r131724 / r131730;
double r131732 = r131711 - r131731;
double r131733 = r131713 ? r131718 : r131732;
return r131733;
}




Bits error versus wj




Bits error versus x
| Original | 14.1 |
|---|---|
| Target | 13.6 |
| Herbie | 1.3 |
if wj < 1.4258272867532584e-07Initial program 13.9
Simplified13.9
Taylor expanded around 0 1.0
Simplified1.0
if 1.4258272867532584e-07 < wj Initial program 24.7
Simplified2.5
rmApplied flip3--15.1
Applied associate-/l/15.3
Simplified15.3
Final simplification1.3
herbie shell --seed 2019303 +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))))))