# A Designed Calibration Approach for the Measurement -While-Drilling Instrument
## 2 Materials and Methods
### Improvement of the Calibration Methods  
#### 2.3.1 Recursive Least Square Method (RLS)  
The raw data of \(N\) measuring points for the dataset \(\mathbf{D_{k}}\) should be collected in advance, when the EF method is used to get the error parameters. If \(N\) is small enough, the calibration method is undoubtedly efficient, premised on getting the right error parameters. In this section, an improved method of direct least square method is introduced to reduce the number of data required by the EF method. The detailed equation derivation is shown below.  
Based on Equation (10), the equation \(P_{n}=(\mathbf{V^{s}_{kn}}^{\text{T}}\mathbf{V^{s}_{kn}})^{-1}\) is assumed and is then derived further according to Woodbury matrix identity, as shown below.  
\[\begin{split} P_{n}&=\left\{\begin{bmatrix}\mathbf{V^{s}_ {k(n-1)}}^{\text{S}}\\ \mathbf{v^{s}_{kn}}\end{bmatrix}^{\text{T}}\Big{[}\mathbf{V^{s}_{k(n-1)}}\Big{]}\\ &=P_{n-1}-\frac{P_{n-1}\mathbf{v^{s}_{kn}}^{\text{T}}}{\big{(}1+\mathbf{v^{s}_{kn}} ^{\text{T}}\mathbf{v^{s}_{kn}}\big{)}}\mathbf{v^{s}_{kn}}P_{n-1}=P_{n-1}-g_{n}\mathbf{v^{s} _{kn}}P_{n-1}\\ &\text{where }g_{n}=P_{n-1}\mathbf{v^{s}_{kn}}^{\text{T}}(1+\mathbf{v^{s}_{kn}} ^{\text{T}}\mathbf{n}_{n-1}\mathbf{v^{s}_{kn}}^{\text{T}})^{-1}\text{. Then, Equation (10) will be decomposed and rewritten on the condition that \(\beta_{n}\) is presumed to be an estimated coefficient vector from the sensor data of the \(n\)th times. The result is shown in Equation (21), where the equation \(g_{n}=P_{n-1}\mathbf{v^{s}_{kn}}^{\text{T}}(1+\mathbf{v^{s}_{kn}}^{\text{T}}\mathbf{n}_{n- 1}\mathbf{v^{s}_{kn}}^{\text{T}})^{-1}=P_{n}\mathbf{v^{s}_{kn}}^{\text{T}}\) can be solved out.  
\[\begin{split}\beta_{n}&=\big{(}\mathbf{V^{s}_{kn}}\mathbf{V^{s}_ {kn}}\big{)}^{-1}\mathbf{V^{s}_{kn}}^{\text{T}}\mathbf{I}_{n}=P_{n}\begin{bmatrix}\mathbf{V^{ s}_{k(n-1)}}^{\text{S}}\\ \mathbf{v^{s}_{kn}}\end{bmatrix}^{\text{T}}\begin{bmatrix}\mathbf{I_{n-1}}\\ i_{n}\end{bmatrix}=P_{n}\Big{[}\mathbf{V^{s}_{k(n-1)}}^{\text{s}}\mathbf{I}_{n-1}+\mathbf{v^{s }_{kn}}^{\text{T}}\mathbf{i}_{in}\Big{]}\\ &=P_{n-1}\mathbf{V^{s}_{k(n-1)}}^{\text{T}}\mathbf{I}_{n-1}-\mathbf{g}_{n}\mathbf{v^{s}_{kn}}P _{n-1}\mathbf{V^{s}_{k(n-1)}}^{\text{T}}\mathbf{I}_{n-1}+\mathbf{g}_{n}i_{n}\\ &=\beta_{n-1}+\mathbf{g}_{n}\big{(}i_{n}-\mathbf{v^{s}_{kn}}\beta_{n-1}\big{)}\\ \end{split} \tag{21}\]  
The operation steps of the improved method are shown in the following list.  
1. Initialize the coefficient vector \(\beta_{0}\) and the covariance matrix \(P_{0}\).
2. Gather the raw data of the \(n\)th measuring point, namely \(\mathbf{v^{s}_{kn}}=(v^{s}_{kxnr}\), \(v^{s}_{kyn}\), \(v^{s}_{kzn})^{\text{T}}\).
3. Calculate the \(g_{n}\) and \(P_{n}\) according to Equation (20).
4. Calculate the new coefficient vector \(\beta_{n}\) according to Equation (21).  
5. Judge the posteriori error \(\|e_{n}\|\), until it meets the inequality \(\|e_{n}\|=\|i_{n}-\
u_{kn}^{s}\beta_{n}\|\leq\varepsilon_{\text{stop}}\), then stop the iteration; otherwise, return to step (2). Here, the restriction value of \(\varepsilon_{\text{stop}}\) is an empirical value. The method flow chart is shown in Figure 2.  
All the methods that use the least squares criterion to determine the coefficients in equation can be optimized by the recursive method. The purpose is to reduce the number of the sampling points, such as the EF method and the PF method. However, if the number of samples is fixed, the advantage of recursive least squares criterion will disappear.