wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 8.976401343690175460051364946315044512914 \cdot 10^{-9}:\\
\;\;\;\;x + wj \cdot \left(wj - 2 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{1}{\sqrt{wj + 1}} \cdot \frac{wj - \frac{x}{e^{wj}}}{\sqrt{wj + 1}}\\
\end{array}double f(double wj, double x) {
double r142775 = wj;
double r142776 = exp(r142775);
double r142777 = r142775 * r142776;
double r142778 = x;
double r142779 = r142777 - r142778;
double r142780 = r142776 + r142777;
double r142781 = r142779 / r142780;
double r142782 = r142775 - r142781;
return r142782;
}
double f(double wj, double x) {
double r142783 = wj;
double r142784 = 8.976401343690175e-09;
bool r142785 = r142783 <= r142784;
double r142786 = x;
double r142787 = 2.0;
double r142788 = r142787 * r142786;
double r142789 = r142783 - r142788;
double r142790 = r142783 * r142789;
double r142791 = r142786 + r142790;
double r142792 = 1.0;
double r142793 = r142783 + r142792;
double r142794 = sqrt(r142793);
double r142795 = r142792 / r142794;
double r142796 = exp(r142783);
double r142797 = r142786 / r142796;
double r142798 = r142783 - r142797;
double r142799 = r142798 / r142794;
double r142800 = r142795 * r142799;
double r142801 = r142783 - r142800;
double r142802 = r142785 ? r142791 : r142801;
return r142802;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.0 |
|---|---|
| Target | 13.4 |
| Herbie | 1.0 |
if wj < 8.976401343690175e-09Initial program 13.6
Simplified13.6
Taylor expanded around 0 0.8
Simplified0.9
if 8.976401343690175e-09 < wj Initial program 26.6
Simplified3.8
rmApplied clear-num3.9
rmApplied *-un-lft-identity3.9
Applied add-sqr-sqrt4.3
Applied times-frac4.2
Applied add-cube-cbrt4.2
Applied times-frac4.2
Simplified4.2
Simplified4.3
Final simplification1.0
herbie shell --seed 2019326
(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))))))