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 r7744402 = wj;
double r7744403 = exp(r7744402);
double r7744404 = r7744402 * r7744403;
double r7744405 = x;
double r7744406 = r7744404 - r7744405;
double r7744407 = r7744403 + r7744404;
double r7744408 = r7744406 / r7744407;
double r7744409 = r7744402 - r7744408;
return r7744409;
}
double f(double wj, double x) {
double r7744410 = x;
double r7744411 = wj;
double r7744412 = exp(r7744411);
double r7744413 = r7744412 * r7744411;
double r7744414 = r7744412 + r7744413;
double r7744415 = r7744410 / r7744414;
double r7744416 = r7744411 * r7744411;
double r7744417 = -r7744411;
double r7744418 = r7744417 * r7744411;
double r7744419 = r7744411 * r7744418;
double r7744420 = fma(r7744411, r7744411, r7744419);
double r7744421 = fma(r7744416, r7744416, r7744420);
double r7744422 = r7744415 + r7744421;
return r7744422;
}




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