wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -6.07033611174586248575152911712005110445 \cdot 10^{-9}:\\
\;\;\;\;\left(wj - \frac{wj}{1 + wj}\right) + \frac{\frac{x}{e^{wj}}}{1 + wj}\\
\mathbf{else}:\\
\;\;\;\;\left(x + wj \cdot wj\right) - x \cdot \left(wj + wj\right)\\
\end{array}double f(double wj, double x) {
double r10711214 = wj;
double r10711215 = exp(r10711214);
double r10711216 = r10711214 * r10711215;
double r10711217 = x;
double r10711218 = r10711216 - r10711217;
double r10711219 = r10711215 + r10711216;
double r10711220 = r10711218 / r10711219;
double r10711221 = r10711214 - r10711220;
return r10711221;
}
double f(double wj, double x) {
double r10711222 = wj;
double r10711223 = -6.0703361117458625e-09;
bool r10711224 = r10711222 <= r10711223;
double r10711225 = 1.0;
double r10711226 = r10711225 + r10711222;
double r10711227 = r10711222 / r10711226;
double r10711228 = r10711222 - r10711227;
double r10711229 = x;
double r10711230 = exp(r10711222);
double r10711231 = r10711229 / r10711230;
double r10711232 = r10711231 / r10711226;
double r10711233 = r10711228 + r10711232;
double r10711234 = r10711222 * r10711222;
double r10711235 = r10711229 + r10711234;
double r10711236 = r10711222 + r10711222;
double r10711237 = r10711229 * r10711236;
double r10711238 = r10711235 - r10711237;
double r10711239 = r10711224 ? r10711233 : r10711238;
return r10711239;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 1.5 |
if wj < -6.0703361117458625e-09Initial program 5.7
rmApplied *-un-lft-identity5.7
Applied distribute-rgt-out5.7
Applied associate-/r*5.5
rmApplied div-sub5.5
Applied div-sub5.5
Applied associate--r-5.5
Simplified5.5
if -6.0703361117458625e-09 < wj Initial program 13.9
Taylor expanded around 0 1.4
Simplified1.4
Final simplification1.5
herbie shell --seed 2019200
(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))))))