# In-Motion Coarse Alignment Method Based on Position Loci and Optimal-REQUEST for SINS
## 4 Attitude Determination Using the Optimal-REQUEST Algorithm
### Calculation of Optimal Gain  
After the measurement update formulae and error models are deduced, the cost function can be determined through the estimated errors of the K-matrix. Next, the fading memory factor \(\rho_{k+1}\) can be updated adaptively according to the cost function. We define the estimation errors of the K-matrix as:  
\[\Delta\text{K}_{k+1/k}\triangleq\text{K}_{k+1/k}^{o}-\text{K}_{k+1/k} \tag{49}\]  
\[\Delta\text{K}_{k+1/k+1}\triangleq\text{K}_{k+1/k+1}^{o}-\text{K}_{k+1/k+1} \tag{50}\]  
where \(\text{K}_{k+1/k}^{o}\) and \(\text{K}_{k+1/k+1}^{o}\) denote the a priori and the a posteriori estimation with error-free, respectively. \(\Delta\text{K}_{k+1/k}\) and \(\Delta\text{K}_{k+1/k+1}\) denote the errors of the a priori and the a posteriori estimation. Similarly to Equation (34), reconstruct the equation with the error-free K-matrix, namely:  
\[\text{K}_{k+1/k+1}^{o}=(1-\rho_{k+1})\frac{m_{k}}{m_{k+1}}\text{K}_{k+1/k}^{o }+\rho_{k+1}\frac{\delta m_{k+1}}{m_{k+1}}\delta\text{K}_{k+1}^{o} \tag{51}\]  
After subtracting Equations (34) and (51), substitute Equations (40), (49) and (50) into the following formula:  
\[\Delta\text{K}_{k+1/k+1}=(1-\rho_{k+1})\frac{m_{k}}{m_{k+1}}\Delta\text{K}_{ k+1/k}+\rho_{k+1}\frac{\delta m_{k+1}}{m_{k+1}}\text{V}_{k+1} \tag{52}\]  
The P matrix of \(\Delta\text{K}_{k+1/k}\) and \(\Delta\text{K}_{k+1/k+1}\) are defined as below  
\[\text{P}_{k+1/k}\triangleq E\Big{[}\Delta\text{K}_{k+1/k}\Delta\text{K}_{k+1/k}^{ \rm T}\Big{]} \tag{53}\]  
\[\text{P}_{k+1/k+1}\triangleq E\Big{[}\Delta\text{K}_{k+1/k+1}\Delta\text{K}_{k+1/ k+1}^{\rm T}\Big{]} \tag{54}\]  
Considering Equation (52), the following formula can be calculated as:  
\[ \begin{split}&\Delta\text{K}_{k+1/k+1}\Delta\text{K}_{k+1/k+1}^{ \rm T}=\Big{[}(1-\rho_{k+1})\frac{m_{k}}{m_{k+1}}\Big{]}^{2}\Delta\text{K}_{ k+1/k}\Delta\text{K}_{k+1/k}^{\rm T}\\ &-(1-\rho_{k+1})\rho_{k+1}\frac{m_{k}\partial m_{k+1}}{m_{k+1}^{ \rm T}}(\Delta\text{K}_{k+1/k}\text{V}_{k+1}^{\rm T}+\text{V}_{k+1}\Delta \text{K}_{k+1/k}^{\rm T})+(\rho_{k+1}\frac{\delta m_{k+1}}{m_{k+1}})^{2}\text{ V}_{k+1}\text{V}_{k+1}^{\rm T}\end{split}  \tag{55}\]  
As mentioned, \(\partial\text{b}_{k}\) and \(\text{V}_{k}\) represent the white noise process with zero-mean. Moreover, \(\Delta\text{K}_{k+1/k}\) consists of \(\text{V}_{i}\), where \(i\) is an integer from 1 to \(k\). Thus, \(\Delta\text{K}_{k+1/k}\) has no relation with \(\text{V}_{k+1}\), namely,  
\[E\Big{[}\Delta\text{K}_{k+1/k}\text{V}_{k+1}^{\rm T}\Big{]}=0 \tag{56}\]  
Then, we take the expectation of Equation (55), and simplify the following formulae:\[\mathrm{P}_{k+1/k+1}\triangleq E\Big{[}\Delta\mathrm{K}_{k+1/k+1}\Delta\mathrm{K}_{k +1/k+1}^{\mathrm{T}}\Big{]}=\bigg{[}(1-\rho_{k+1})\frac{m_{k}}{m_{k+1}}\bigg{]}^ {2}E\Big{[}\Delta\mathrm{K}_{k+1/k}\Delta\mathrm{K}_{k+1/k}^{\mathrm{T}}\Big{]} +\left(\rho_{k+1}\frac{\delta m_{k+1}}{m_{k+1}}\right)^{2}E\Big{[}\mathrm{V}_{ k+1}\mathrm{V}_{k+1}^{\mathrm{T}}\Big{]} \tag{57}\]  
\[\mathrm{P}_{k+1/k+1}=\bigg{[}(1-\rho_{k+1})\frac{m_{k}}{m_{k+1}}\bigg{]}^{2} \mathrm{P}_{k+1/k}+\left(\rho_{k+1}\frac{\delta m_{k+1}}{m_{k+1}}\right)^{2} \Re_{k+1} \tag{58}\]  
Based on Equation (58), we define the cost function \(I_{k+1}\):  
\[I_{k+1}=tr\big{(}E\Big{[}\Delta\mathrm{K}_{k+1/k+1}\Delta\mathrm{K}_{k+1/k+1}^ {\mathrm{T}}\Big{]}\big{)}=tr\big{(}\mathrm{P}_{k+1/k+1}\big{)} \tag{59}\]  
The calculation of the fading memory factor is then transformed by solving the minimization problem of Equation (59). We use the derivation to obtain the expression of the fading memory factor.