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 r7012691 = wj;
double r7012692 = exp(r7012691);
double r7012693 = r7012691 * r7012692;
double r7012694 = x;
double r7012695 = r7012693 - r7012694;
double r7012696 = r7012692 + r7012693;
double r7012697 = r7012695 / r7012696;
double r7012698 = r7012691 - r7012697;
return r7012698;
}
double f(double wj, double x) {
double r7012699 = x;
double r7012700 = wj;
double r7012701 = exp(r7012700);
double r7012702 = r7012701 * r7012700;
double r7012703 = r7012701 + r7012702;
double r7012704 = r7012699 / r7012703;
double r7012705 = r7012700 * r7012700;
double r7012706 = -r7012700;
double r7012707 = r7012706 * r7012700;
double r7012708 = r7012700 * r7012707;
double r7012709 = fma(r7012700, r7012700, r7012708);
double r7012710 = fma(r7012705, r7012705, r7012709);
double r7012711 = r7012704 + r7012710;
return r7012711;
}




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))))))