# A Weighted and Distributed Algorithm for Range-Based Multi-Hop Localization Using a Newton Method
## 4 A Robust and Distributed Localization Algorithm Based on the Newton Method
The gradient of (11), \(\
abla F(\mathbf{p}_{i})=\left(\frac{\partial F(\mathbf{p}_{i})}{\partial x_ {i}},\frac{\partial F(\mathbf{p}_{i})}{\partial y_{i}}\right)^{T}\) is stated as  
\[\frac{\partial F(\mathbf{p}_{i})}{\partial x_{i}} =-\sum_{r\in\Omega_{i}\cup\textbf{B}}\left(\frac{\partial f}{ \partial\widetilde{e}_{ir}}\right)\frac{(x_{i}-x_{r})}{\|\mathbf{p}_{i}\!- \!\mathbf{p}_{r}\|}, \tag{20}\] \[\frac{\partial F(\mathbf{p}_{i})}{\partial y_{i}} =-\sum_{r\in\Omega_{i}\cup\textbf{B}}\left(\frac{\partial f}{ \partial\widetilde{e}_{ir}}\right)\frac{(y_{i}-y_{r})}{\|\mathbf{p}_{i}\!-\! \mathbf{p}_{r}\|} \tag{21}\]where  
\[\frac{\partial f}{\partial e_{ir}}=\frac{e_{ir}\cdot w_{r}^{2}}{c_{r}^{2}}. \tag{22}\]  
The Hessian of (11) is described as  
\[\mathbf{H}(\mathbf{p}_{i})=\left[ \begin{array}{cc}\frac{\partial F(\mathbf{p} _{i})}{\partial^{2}x_{i}}&\frac{\partial F(\mathbf{p}_{i})}{\partial x_{i} \partial y_{i}}\\ \frac{\partial F(\mathbf{p}_{i})}{\partial y_{i}\partial x_{i}}&\frac{\partial F (\mathbf{p}_{i})}{\partial^{2}y_{i}}\end{array} \right], \tag{23}\]  
\[\frac{\partial F(\mathbf{p}_{i})}{\partial^{2}x_{i}}=\sum_{r\in \Omega_{i}\cup\mathbf{B}}\Biggl{[}\left(\frac{\partial f}{\partial e_{ir}} \right)\Biggr{[} \begin{array}{cc}\frac{(x_{i}-x_{r})^{2}}{\left[(x_{i}-x_{r })^{2}+(y_{i}-y_{r})^{2}\right]^{3/2}}-&\frac{1}{\left[(x_{i}-x_{r})^{2}+(y_{ i}-y_{r})^{2}\right]^{1/2}}\end{array} \right]+\\ \Biggl{(}\frac{\partial^{2}f}{\partial e_{ir}^{2}}\Biggr{)}\Biggr{[} \frac{(x_{i}-x_{r})^{2}}{\left(x_{i}-x_{r}\right)^{2}+(y_{i}-y_{r})^{2}} \Biggr{]}\Biggr{]}, \tag{24}\]  
\[\frac{\partial F(\mathbf{p}_{i})}{\partial^{2}y_{i}}=\sum_{r\in \Omega_{i}\cup\mathbf{B}}\Biggl{[}\left(\frac{\partial f}{\partial e_{ir}} \right)\Biggr{[} \begin{array}{cc}\frac{(y_{i}-y_{r})^{2}}{\left[(x_{i}-x_{r })^{2}+(y_{i}-y_{r})^{2}\right]^{3/2}}\end{array} \right]+\Biggl{(}\frac{ \partial^{2}f}{\partial e_{ir}^{2}}\Biggr{)}\Biggr{[}\frac{(x_{i}-x_{r})(y_{i} -y_{r})}{\left(x_{i}-x_{r}\right)^{2}+(y_{i}-y_{r})^{2}}\Biggr{]}\Biggr{]}, \tag{25}\]  
\[\frac{\partial F(\mathbf{p}_{i})}{\partial x_{i}\partial y_{i}}=\sum_{r\in \Omega_{i}\cup\mathbf{B}}\Biggl{[}\left(\frac{\partial f}{\partial e_{ir}} \right)\Biggr{[} \begin{array}{cc}\frac{(x_{i}-x_{r})(y_{i}-y_{r})}{\left[(x _{i}-x_{r})^{2}+(y_{i}-y_{r})^{2}\right]^{3/2}}\end{array} \right]+\Biggl{(} \frac{\partial^{2}f}{\partial e_{ir}^{2}}\Biggr{)}\Biggr{[}\frac{(x_{i}-x_{r})(y _{i}-y_{r})}{\left(x_{i}-x_{r}\right)^{2}+(y_{i}-y_{r})^{2}}\Biggr{]}\Biggr{]}, \tag{26}\]  
\[\frac{\partial F(\mathbf{p}_{i})}{\partial y_{i}\partial x_{i}}=\sum_{r\in \Omega_{i}\cup\mathbf{B}}\Biggl{[}\left(\frac{\partial f}{\partial e_{ir}} \right)\Biggr{[} \begin{array}{cc}\frac{(y_{i}-y_{r})(x_{i}-x_{r})}{\left[(x _{i}-x_{r})^{2}+(y_{i}-y_{r})^{2}\right]^{3/2}}\end{array} \right]+\Biggl{(} \frac{\partial^{2}f}{\partial e_{ir}^{2}}\Biggr{)}\Biggr{[}\frac{(y_{i}-y_{r})( x_{i}-x_{r})}{\left(x_{i}-x_{r}\right)^{2}+(y_{i}-y_{r})^{2}}\Biggr{]}\Biggr{]}, \tag{27}\]  
where  
\[\frac{\partial^{2}f}{\partial e_{ir}^{2}}=\frac{w_{r}^{2}}{c_{r}^{2}}. \tag{28}\]  
Assuming that rough initial estimates for all unknown sensor nodes are obtained by standard methods such as Least-Squares and Min-Max, among others [11], the distributed localization process for a sensor \(s_{i}\) follows the process shown in Algorithm 1. ```
0:\(\mathbf{p}_{i}\), \(\mathbf{W}_{i}\), \(\mathit{Niter}\), \(\mathbf{\Omega}_{i}\), \(\mathbf{B}\)
0: Refined version of \(\mathbf{p}_{i}\)
1:Initialize:\(\rho=0.05\), \(\tau=10^{-2}\)
2:Compute:\(c_{r}\) for all \(r\in\mathbf{\Omega}_{i}\cup\mathbf{B}\) from (19)
3:\(n=0\)
4:repeat
5:\(\mathbf{\hat{p}}_{i}=\mathbf{p}_{i



As is well known, the optimal step length \(\alpha\) in line 10 of Algorithm 1 can be found using both the Armijo and Wolfe conditions at expenses of more computational cost [31; 32]. For practical purposes, \(\alpha\) was set to one. The updated position \(\mathbf{p}_{i}\) of \(s_{i}\) is broadcast to its neighboring sensors starting a new refining position process.