wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\left(wj \cdot wj + \left(wj \cdot wj - wj\right) \cdot \left(wj \cdot wj\right)\right) + \frac{x}{e^{wj + \mathsf{log1p}\left(wj\right)}}double f(double wj, double x) {
double r4316027 = wj;
double r4316028 = exp(r4316027);
double r4316029 = r4316027 * r4316028;
double r4316030 = x;
double r4316031 = r4316029 - r4316030;
double r4316032 = r4316028 + r4316029;
double r4316033 = r4316031 / r4316032;
double r4316034 = r4316027 - r4316033;
return r4316034;
}
double f(double wj, double x) {
double r4316035 = wj;
double r4316036 = r4316035 * r4316035;
double r4316037 = r4316036 - r4316035;
double r4316038 = r4316037 * r4316036;
double r4316039 = r4316036 + r4316038;
double r4316040 = x;
double r4316041 = log1p(r4316035);
double r4316042 = r4316035 + r4316041;
double r4316043 = exp(r4316042);
double r4316044 = r4316040 / r4316043;
double r4316045 = r4316039 + r4316044;
return r4316045;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.1 |
|---|---|
| Target | 13.5 |
| Herbie | 1.2 |
Initial program 14.1
rmApplied div-sub14.1
Applied associate--r-7.6
Taylor expanded around 0 1.0
Simplified1.0
rmApplied add-exp-log1.2
Simplified1.2
Final simplification1.2
herbie shell --seed 2019142 +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))