wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.509211057300332155337300766044170141633 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(wj, wj, x\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{{wj}^{3} + 1}}{\frac{e^{wj}}{wj \cdot wj + \left(1 - wj \cdot 1\right)}} + wj\right) - \frac{wj}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r235493 = wj;
double r235494 = exp(r235493);
double r235495 = r235493 * r235494;
double r235496 = x;
double r235497 = r235495 - r235496;
double r235498 = r235494 + r235495;
double r235499 = r235497 / r235498;
double r235500 = r235493 - r235499;
return r235500;
}
double f(double wj, double x) {
double r235501 = wj;
double r235502 = 6.509211057300332e-09;
bool r235503 = r235501 <= r235502;
double r235504 = x;
double r235505 = fma(r235501, r235501, r235504);
double r235506 = 2.0;
double r235507 = r235501 * r235504;
double r235508 = r235506 * r235507;
double r235509 = r235505 - r235508;
double r235510 = 3.0;
double r235511 = pow(r235501, r235510);
double r235512 = 1.0;
double r235513 = r235511 + r235512;
double r235514 = r235504 / r235513;
double r235515 = exp(r235501);
double r235516 = r235501 * r235501;
double r235517 = r235501 * r235512;
double r235518 = r235512 - r235517;
double r235519 = r235516 + r235518;
double r235520 = r235515 / r235519;
double r235521 = r235514 / r235520;
double r235522 = r235521 + r235501;
double r235523 = r235501 + r235512;
double r235524 = r235501 / r235523;
double r235525 = r235522 - r235524;
double r235526 = r235503 ? r235509 : r235525;
return r235526;
}




Bits error versus wj




Bits error versus x
| Original | 13.5 |
|---|---|
| Target | 12.9 |
| Herbie | 1.0 |
if wj < 6.509211057300332e-09Initial program 13.1
Simplified13.1
Taylor expanded around 0 0.9
Taylor expanded around 0 0.9
Simplified0.9
if 6.509211057300332e-09 < wj Initial program 25.1
Simplified3.1
rmApplied flip3-+3.1
Applied associate-/r/3.1
Applied associate-/l*3.1
Final simplification1.0
herbie shell --seed 2020002 +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))