wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 1.02314066329064058 \cdot 10^{-8}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(wj, wj, x\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{\frac{x}{wj + 1}}{e^{wj}} + wj}, \sqrt[3]{\frac{\frac{x}{wj + 1}}{e^{wj}} + wj} \cdot \sqrt[3]{\frac{\frac{x}{wj + 1}}{e^{wj}} + wj}, \frac{-{\left(\sqrt[3]{wj}\right)}^{3}}{wj + 1}\right) + \left(\frac{{\left(\sqrt[3]{wj}\right)}^{3}}{1 \cdot \left(wj + 1\right)} + \frac{-{\left(\sqrt[3]{wj}\right)}^{3}}{wj + 1}\right)\\
\end{array}double f(double wj, double x) {
double r231665 = wj;
double r231666 = exp(r231665);
double r231667 = r231665 * r231666;
double r231668 = x;
double r231669 = r231667 - r231668;
double r231670 = r231666 + r231667;
double r231671 = r231669 / r231670;
double r231672 = r231665 - r231671;
return r231672;
}
double f(double wj, double x) {
double r231673 = wj;
double r231674 = 1.0231406632906406e-08;
bool r231675 = r231673 <= r231674;
double r231676 = 1.0;
double r231677 = x;
double r231678 = fma(r231673, r231673, r231677);
double r231679 = r231676 * r231678;
double r231680 = 2.0;
double r231681 = r231673 * r231677;
double r231682 = r231680 * r231681;
double r231683 = r231679 - r231682;
double r231684 = r231673 + r231676;
double r231685 = r231677 / r231684;
double r231686 = exp(r231673);
double r231687 = r231685 / r231686;
double r231688 = r231687 + r231673;
double r231689 = cbrt(r231688);
double r231690 = r231689 * r231689;
double r231691 = cbrt(r231673);
double r231692 = 3.0;
double r231693 = pow(r231691, r231692);
double r231694 = -r231693;
double r231695 = r231694 / r231684;
double r231696 = fma(r231689, r231690, r231695);
double r231697 = r231676 * r231684;
double r231698 = r231693 / r231697;
double r231699 = r231698 + r231695;
double r231700 = r231696 + r231699;
double r231701 = r231675 ? r231683 : r231700;
return r231701;
}




Bits error versus wj




Bits error versus x
| Original | 13.8 |
|---|---|
| Target | 13.2 |
| Herbie | 1.0 |
if wj < 1.0231406632906406e-08Initial program 13.5
Simplified13.5
Taylor expanded around 0 0.9
rmApplied *-un-lft-identity0.9
Applied *-un-lft-identity0.9
Applied distribute-lft-out0.9
Simplified0.9
if 1.0231406632906406e-08 < wj Initial program 25.9
Simplified2.7
rmApplied *-un-lft-identity2.7
Applied add-cube-cbrt3.2
Applied times-frac3.2
Applied add-cube-cbrt3.6
Applied prod-diff3.5
Simplified3.7
Simplified3.7
Final simplification1.0
herbie shell --seed 2020062 +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))))))