Conjugate gradient method

Assume now that we have a symmetric positive-definite matrix \( \hat{A} \) of size \( n\times n \). At each iteration \( i+1 \) we obtain the conjugate direction of a vector $$ \begin{equation*} \hat{x}_{i+1}=\hat{x}_{i}+\alpha_i\hat{p}_{i}. \end{equation*} $$ We assume that \( \hat{p}_{i} \) is a sequence of \( n \) mutually conjugate directions. Then the \( \hat{p}_{i} \) form a basis of \( R^n \) and we can expand the solution $ \hat{A}\hat{x} = \hat{b}$ in this basis, namely $$ \begin{equation*} \hat{x} = \sum^{n}_{i=1} \alpha_i \hat{p}_i. \end{equation*} $$