# Lithium Battery SoC Estimation Based on Improved Iterated Extended Kalman Filter
## 3 IEKF Algorithm Based on LM
### The Procedure of the IEKF Algorithm Based on LM Optimization  
Due to the extended Kalman filtering in the process of calculating the results after the high-order Taylor expansion, a certain error still exists in the EKF algorithm. Therefore, to introduce the ideas of the iterated EKF, we use the iterated extended Kalman filter (IEKF) to estimate the SoC of the battery. The state estimation process of IEKF includes multiple iterated calculations, and the final calculation result is the optimal one. Therefore, the estimation accuracy is improved [33]. The process of introducing iteration in the process of updating the error covariance matrix of IEKF algorithm can be regarded as a process of using the Gauss-Newton method to solve the minimum value of the mean square error function. However, because the high-order term of the Taylor expansion is discarded, the state space model will be affected by the error, resulting in the deviation of the model data. In this case, the performance of the Gauss-Newton method is often not good enough. In order to ensure the global convergence of the algorithm [34], the Levenberg-Marquardt (LM) method is used to modify the covariance matrix of the IEKF prediction stage, and the parameter \(\alpha\) is introduced to modify the covariance matrix of the prediction stage in each iteration [35]. The specific steps of the LM-IKEF algorithm are as follows. 1. Set the system state \(x_{k}\) and error covariance matrix \(P_{k}\) initial quantity: \[\left\{ \begin{array}{l}\hat{x_{0}}=E(x_{0})\\ P_{0}=E\bigg{[}\bigg{(}\hat{x_{0}}-x_{0}\bigg{)}\bigg{(}\hat{x_{0}}-x_{0} \bigg{)}^{\mathrm{T}}\bigg{]}\end{array} \right.\] (16)
2. Compute the prior estimate and the prior error covariance as follows: \[\hat{x_{k|k-1}}=f\bigg{(}\hat{x_{k-1|k-1}},u_{k-1}\bigg{)}\] (17) \[P_{k|k-1}=A_{k-1}P_{k-1|k-1}A_{k-1}^{\mathrm{T}}+\mathcal{Q}_{k-1}\] (18) The IKEF iteration process begins as follows:(3) The a priori estimates and the a priori error covariance during the iteration are computed:  
\[\left\{ \begin{array}{l}\overset{\cdot(i)}{x_{k|k-1}}=f\left(\overset{\cdot(i)}{x _{k-1|k-1}},u_{k-1}\right)\\ P_{k|k-1}^{(i)}=A_{k}P_{k-1|k-1}^{(i-1)}A_{k}^{\mathrm{T}}+Q_{k-1}\end{array} \right. \tag{19}\]  
When the first iteration is performed; that is, when \(i\) = 1, since the error covariance matrix has not been corrected, the calculation results of the prior estimate value and the prior error covariance are the same as the calculation results before the iteration process. However, when the number of iterations is greater than 1, the prior estimate value and the prior error covariance of the system will be updated. (4) The covariance matrix is modified by the LM method:  
\[\overset{\cdot(i)}{P_{k|k-1}}=\left[I-P_{k|k-1}^{(i)}\left(P_{k|k-1}^{(i)}+ \alpha^{-1}I\right)^{-1}\right]P_{k|k-1}^{(i)} \tag{20}\]  
A larger parameter \(\alpha\) means that the iterated calculation result of the algorithm is closer to the gradient descent method, while a smaller parameter \(\alpha\) means that the iterated calculation result of the LM method is closer to the calculation result of the Gauss-Newton method. Throughout the calculation process of this paper, we found that the calculation result is consistent with the direction of convergence when the parameter \(\alpha\) is small, so the initial value of \(\alpha\) is set to 0.15.