wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(wj, \mathsf{fma}\left(x, -2, wj\right), x\right) + wj \cdot \mathsf{fma}\left(-2, x, 2 \cdot x\right)double f(double wj, double x) {
double r238971 = wj;
double r238972 = exp(r238971);
double r238973 = r238971 * r238972;
double r238974 = x;
double r238975 = r238973 - r238974;
double r238976 = r238972 + r238973;
double r238977 = r238975 / r238976;
double r238978 = r238971 - r238977;
return r238978;
}
double f(double wj, double x) {
double r238979 = wj;
double r238980 = x;
double r238981 = -2.0;
double r238982 = fma(r238980, r238981, r238979);
double r238983 = fma(r238979, r238982, r238980);
double r238984 = 2.0;
double r238985 = -r238984;
double r238986 = r238984 * r238980;
double r238987 = fma(r238985, r238980, r238986);
double r238988 = r238979 * r238987;
double r238989 = r238983 + r238988;
return r238989;
}




Bits error versus wj




Bits error versus x
| Original | 13.4 |
|---|---|
| Target | 12.8 |
| Herbie | 2.2 |
Initial program 13.4
Simplified12.8
Taylor expanded around 0 2.2
Simplified2.2
rmApplied add-sqr-sqrt32.8
Applied prod-diff32.8
Applied distribute-lft-in32.8
Applied associate-+r+32.8
Simplified2.2
Final simplification2.2
herbie shell --seed 2020046 +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))))))