# A Regression-Based Technique for Capacity Estimation of Lithium-Ion Batteries
## 3 Capacity Estimation
### Proposed Methods to Estimate \(Q\)
#### 3.2.5 Geometry Method  
The next proposed method is feasible to perform, but in practice, the noise of \(\sigma_{x_{i}}\) and \(\sigma_{y_{i}}\) are not necessarily proportional. An approach is suggested in which noise of \(\sigma_{x_{i}}\) and \(\sigma_{y_{i}}\) can adopt any free independent value, reaching a recursive close form solution based on geometry relationships. The geometry method is illustrated in Figure 3.  
In Figure 3 there is a pair of data, \((x_{i},y_{i})\), which are measured \(x\) and \(y\), and \((X_{i},Y_{i})\) is the optimized image of that pair on \(Y=\tilde{Q}X\). The arrows of \(\delta x_{i}\) and \(\delta y_{i}\) indicate uncertainties for each dimension and are proportional to \(\sigma_{x_{i}}\) and \(\sigma_{y_{i}}\). The variances of \(\sigma_{x_{i}}^{2}\) and \(\sigma_{y_{i}}^{2}\) are free as mentioned above. Therefore, the distance of \((x_{i},X_{i})\) is not necessarily the same as \((y_{i},Y_{i})\). More quality in the data measurement of \(x_{i}\) (or \(y_{i}\)) leads to less space to its map \(X_{i}\) (\(Y_{i}\)). A particular state of this method is to consider equal errors, which means \(\sigma_{x_{i}}\)=\(\sigma_{y_{i}}\). In this form, the line connects \((x_{i},y_{i})\) and \((X_{i},Y_{i})\) is perpendicular to \(Y=\tilde{Q}X\) line. As can be seen in Figure 3, the gradient (or slope) of \(Y=\tilde{Q}X\) line is \(\tilde{Q}=\Delta y_{i}/\Delta x_{i}\) and the angle of \(\theta\) is equal to \(\tan^{-1}\tilde{Q}\). The length of the perpendicular line between the data point and the line is \(R_{i}=\Delta y_{i}\cos\theta=\Delta y_{i}/\sqrt{1+\tilde{Q}^{2}}\). Moreover, there are \(\delta x_{i}=R_{i}\sin\theta\) and \(\delta y_{i}=R_{i}\cos\theta\). A cost function is defined as:  
\[\chi_{geometryLS}^{2}=\sum_{i=1}^{N}\frac{\delta x_{i}^{2}}{\sigma_{x_{i}}^{ 2}}+\frac{\delta y_{i}^{2}}{\sigma_{y_{i}}^{2}} \tag{49}\]  
By considering \(\sin\theta^{2}=1-\cos\theta^{2}=\frac{\tilde{Q}^{2}}{1+\tilde{Q}^{2}}\):  
\[\delta x_{i}^{2}=\left(\frac{\Delta y_{i}^{2}}{1+\tilde{Q}^{2}}\right)\left( \frac{\tilde{Q}^{2}}{1+\tilde{Q}^{2}}\right);\delta y_{i}^{2}=\left(\frac{ \Delta y_{i}^{2}}{1+\tilde{Q}^{2}}\right)\left(\frac{1}{1+\tilde{Q}^{2}}\right) \tag{50}\]  
Moreover, by considering \(\Delta y_{i}=y_{i}-\tilde{Q}x_{i}\), the cost function will be rewritten as:  
\[\chi_{geometryLS}^{2}=\sum_{i=1}^{N}\frac{\left(y_{i}-\tilde{Q}x_{i}\right)^{ 2}}{\left(1+\tilde{Q}^{2}\right)^{2}}\left(\frac{\tilde{Q}^{2}}{\sigma_{x_{i} }^{2}}+\frac{1}{\sigma_{y_{i}}^{2}}\right) \tag{51}\]  
Figure 3: Geometry method. By applying the assumption of \(\sigma_{x_{i}}=\sigma_{y_{i}}\) the following equation is reached:  
\[\chi^{2}_{geometryLS}=\sum\limits_{i=1}^{N}\frac{\left(y_{i}-\hat{Q}x_{i}\right) ^{2}}{\left(1+\hat{Q}^{2}\right)\sigma_{i}^{2}} \tag{52}\]  
The above equation is equal to the Equation number (38). By adding \(\gamma\) as a fading memory element to the cost function, the following equation can be achieved:  
\[\chi^{2}_{geometry-FMLS}=\sum\limits_{i=1}^{N}\gamma^{N-i}\frac{\left(y_{i}- \hat{Q}x_{i}\right)^{2}}{\left(1+\hat{Q}^{2}\right)\sigma_{i}^{2}} \tag{53}\]  
As in the previous sections, the derivative of the cost function with respect to \(\hat{Q}\) must be calculated and be set to zero in order to find the optimal value for \(\hat{Q}\).