wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(wj, wj, {wj}^{4}\right)}, \sqrt{\mathsf{fma}\left(wj, wj, {wj}^{4}\right)}, -{wj}^{3}\right) + \frac{\frac{x}{e^{wj}}}{1 + wj}double f(double wj, double x) {
double r184328 = wj;
double r184329 = exp(r184328);
double r184330 = r184328 * r184329;
double r184331 = x;
double r184332 = r184330 - r184331;
double r184333 = r184329 + r184330;
double r184334 = r184332 / r184333;
double r184335 = r184328 - r184334;
return r184335;
}
double f(double wj, double x) {
double r184336 = wj;
double r184337 = 4.0;
double r184338 = pow(r184336, r184337);
double r184339 = fma(r184336, r184336, r184338);
double r184340 = sqrt(r184339);
double r184341 = 3.0;
double r184342 = pow(r184336, r184341);
double r184343 = -r184342;
double r184344 = fma(r184340, r184340, r184343);
double r184345 = x;
double r184346 = exp(r184336);
double r184347 = r184345 / r184346;
double r184348 = 1.0;
double r184349 = r184348 + r184336;
double r184350 = r184347 / r184349;
double r184351 = r184344 + r184350;
return r184351;
}




Bits error versus wj




Bits error versus x
| Original | 13.9 |
|---|---|
| Target | 13.2 |
| Herbie | 1.1 |
Initial program 13.9
Simplified13.2
rmApplied div-sub13.2
Applied associate--r-6.9
Taylor expanded around 0 1.1
Simplified1.1
rmApplied add-sqr-sqrt1.1
Applied fma-neg1.1
Final simplification1.1
herbie shell --seed 2020045 +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))))))