wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(wj, wj, {wj}^{4} - {wj}^{3}\right) + \frac{x}{e^{wj} \cdot \left(wj + 1\right)}double f(double wj, double x) {
double r120447 = wj;
double r120448 = exp(r120447);
double r120449 = r120447 * r120448;
double r120450 = x;
double r120451 = r120449 - r120450;
double r120452 = r120448 + r120449;
double r120453 = r120451 / r120452;
double r120454 = r120447 - r120453;
return r120454;
}
double f(double wj, double x) {
double r120455 = wj;
double r120456 = 4.0;
double r120457 = pow(r120455, r120456);
double r120458 = 3.0;
double r120459 = pow(r120455, r120458);
double r120460 = r120457 - r120459;
double r120461 = fma(r120455, r120455, r120460);
double r120462 = x;
double r120463 = exp(r120455);
double r120464 = 1.0;
double r120465 = r120455 + r120464;
double r120466 = r120463 * r120465;
double r120467 = r120462 / r120466;
double r120468 = r120461 + r120467;
return r120468;
}




Bits error versus wj




Bits error versus x
| Original | 13.4 |
|---|---|
| Target | 12.8 |
| Herbie | 1.1 |
Initial program 13.4
Simplified12.8
rmApplied div-sub12.8
Applied associate--r-6.7
Simplified6.7
Taylor expanded around 0 1.1
Simplified1.1
rmApplied div-inv1.1
Applied associate-/l*1.1
Simplified1.1
Final simplification1.1
herbie shell --seed 2019195 +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))))))