## 2 Methodology
### Inverse Magnetic Localization Based on Adaptive LM Algorithm
#### 2.2.1 Inverse Model
Since the quasi-static magnetic fields satisfy the principle of linear superposition, the magnetic fields **B** induced by this \(T\)-type PM can be described by the sum of the magnetic fields induced by the vertical and horizontal magnet termed \(\textbf{B}_{v}\) and \(\textbf{B}_{h}\), respectively:  
\[\textbf{B}(\textbf{r},\textbf{m})=\textbf{B}_{v}(\textbf{r}_{pv},\textbf{m}_{ v})+\textbf{B}_{h}\Big{(}\textbf{r}_{ph},\textbf{m}_{h}\Big{)}, \tag{2a}\]  
\[\textbf{B}_{v}\big{(}\textbf{r}_{pv},\textbf{m}_{v}\big{)}=\frac{\mu_{0}m_{v} }{4\pi\big{|}\textbf{r}_{s}-\textbf{r}_{pv}\big{|}^{3}}\Bigg{[}\frac{3\textbf{ m}_{v}\bullet\big{(}\textbf{r}_{s}-\textbf{r}_{pv}\big{)}}{\big{|}\textbf{r}_{s}- \textbf{r}_{pv}\big{|}^{2}}\big{(}\textbf{r}_{s}-\textbf{r}_{pv}\big{)}- \textbf{m}_{v}\Bigg{]} \tag{2b}\]  
\[\textbf{B}_{h}\Big{(}\textbf{r}_{ph},\textbf{m}_{h}\Big{)}=\textbf{B}_{h}\big{(} \textbf{r}_{pv},\textbf{m}_{v},\textbf{m}_{h}\big{)}=\frac{\mu_{0}m_{h}}{4\pi \big{|}\textbf{r}_{s}-\textbf{r}_{pv}+\textbf{m}_{pv}\big{|}^{3}}\Bigg{[}\frac {3\textbf{m}_{v}\bullet\big{(}\textbf{r}_{s}-\textbf{r}_{pv}\big{)}}{\big{|} \textbf{r}_{s}-\textbf{r}_{pv}+\textbf{m}_{pv}\big{|}^{2}}\big{(}\textbf{r}_{ s}-\textbf{r}_{pv}+\textbf{m}_{pv}\big{)}-\textbf{m}_{h}\Bigg{]} \tag{2c}\]  
where \(\textbf{r}_{pv}\) and \(\textbf{r}_{ph}\) represent the locations of the vertical and horizontal magnet, respectively; \(\textbf{r}_{ph}=\textbf{r}_{pv}-l\textbf{m}_{v}\); \(\textbf{m}_{v}\) and \(\textbf{m}_{h}\) are the unit vector of the magnetic moment for the vertical and horizontal magnet respectively; and \(\textbf{m}_{v}\bullet\textbf{m}_{h}=0\). Substituting Equations (2b) and (2c) into Equation (2a), it is noted that there are seven unknown parameters, termed location (\(\textbf{r}_{pv}\) (\(x_{v}\), \(y_{v}\), \(z_{v}\)) and orientation \(\textbf{m}_{v}\) (\(\theta_{v}\), \(\varphi_{v}\)), \(\textbf{m}_{h}\) (\(\theta_{h}\), \(\varphi_{h}\))). At least seven equations are required to derive them, where seven measurements are involved. However, due to the noise interference from the environment and the high-order characteristics of the forward model in Equation (2), the inverse problem is overdetermined. To solve the high-order nonlinear inverse magnetic problem, we define an objective function relating to computed results \(\textbf{B}_{c}\) from the forward model in Equation (2) and observations \(\textbf{B}_{m}\) from sensors to derive the position and orientation parameters:  
\[f(\textbf{r}_{pv},\textbf{m}_{v},\textbf{m}_{h})=\sum_{i=1}^{N}\|\textbf{B}_{ m}(i)-\textbf{B}_{c}\big{(}\textbf{r}_{pv},\textbf{m}_{v},\textbf{m}_{h},i \big{)}\|^{2}, \tag{3}\]  
where \(\textbf{B}_{c}\) is the theoretical magnetic field at the position of the \(i\)th sensor computed with candidate location and orientation parameters according to Equations (1) and (2). To locate the magnetic marker, we need to find the optimal parameters to minimize \(f(\textbf{r}_{pv},\textbf{m}_{v},\textbf{m}_{h})\), where the nonlinear least-square (LS) techniques are always applied to get an optimized solution.