wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\frac{x}{e^{wj} + e^{wj} \cdot wj} + \mathsf{fma}\left(wj \cdot wj, wj \cdot wj, \mathsf{fma}\left(wj, wj, wj \cdot \left(\left(-wj\right) \cdot wj\right)\right)\right)double f(double wj, double x) {
double r8613616 = wj;
double r8613617 = exp(r8613616);
double r8613618 = r8613616 * r8613617;
double r8613619 = x;
double r8613620 = r8613618 - r8613619;
double r8613621 = r8613617 + r8613618;
double r8613622 = r8613620 / r8613621;
double r8613623 = r8613616 - r8613622;
return r8613623;
}
double f(double wj, double x) {
double r8613624 = x;
double r8613625 = wj;
double r8613626 = exp(r8613625);
double r8613627 = r8613626 * r8613625;
double r8613628 = r8613626 + r8613627;
double r8613629 = r8613624 / r8613628;
double r8613630 = r8613625 * r8613625;
double r8613631 = -r8613625;
double r8613632 = r8613631 * r8613625;
double r8613633 = r8613625 * r8613632;
double r8613634 = fma(r8613625, r8613625, r8613633);
double r8613635 = fma(r8613630, r8613630, r8613634);
double r8613636 = r8613629 + r8613635;
return r8613636;
}




Bits error versus wj




Bits error versus x
| Original | 13.5 |
|---|---|
| Target | 12.9 |
| Herbie | 1.1 |
Initial program 13.5
rmApplied div-sub13.5
Applied associate--r-7.5
Taylor expanded around 0 1.1
Simplified1.1
rmApplied fma-neg1.1
Final simplification1.1
herbie shell --seed 2019172 +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))