Are covariance matrices guaranteed to have real-valued eigenvectors and eigenvalues (related to PCA)?

I'm a software engineering, and I'm trying to learn principal components analysis.

I've read that as part of PCA, I need to compute a covariance matrix and then find the eigenvectors and eigenvalues of that matrix.

However, from my understanding, not all square matrices with real numbers have real eigenvectors. See this question "Do all square matrices have eigenvectors?".

Thus, how can a covariance matrix be guaranteed to have eigenvectors and eigenvalues? Could the eigenvectors have complex numbers (that wouldn't seem to be useful for PCA, I would guess)?

• Because it is symmetric: math.stackexchange.com/questions/1243276/… May 19, 2016 at 20:59
• @MiguelAtencia: Thanks. Are you saying that all real-valued, symmetric matrices must have real-valued eigenvectors? May 20, 2016 at 5:08
• Covariance matrices are symmetric, so are guaranteed to have real eigenvalues and real eigenvectors by the spectral theorem: en.wikipedia.org/wiki/Spectral_theorem May 20, 2016 at 5:09
• @QiaochuYuan: Thank you. Please consider making your comment into an answer. May 20, 2016 at 5:53

Let $A$ be an $n$-by-$n$ covariance matrix, which must be Hermitian or real symmetric if $A$ is real. It's simple to see that all eigenvalues of $A$ must be real. Suppose $\lambda$ is an eigenvalue of $A$. Then $Ax=\lambda x$ for some non-zero vector $x$. So clearly $x^*Ax=x^*\lambda x=\lambda \|x\|^2$. But since $A=A^*$, we also have $x^*Ax=x^*A^*x=\bar\lambda x^*x=\bar\lambda\|x\|^2$. Hence $\lambda=\bar\lambda$, i.e. it must be real.
The eigenvectors of $A$ (real symmetric) need not all be real. However, it's always possible find a real eigenvector for each eigenvalue of $A$. To see this, suppose $\lambda$ is an eigenvalue of $A$, i.e. $Ax=\lambda x$ or $(A-\lambda I)x=0$ for some non-zero $x$. We've shown that $\lambda$ must be real. This implies that $(A-\lambda I)$ is real and singular. Therefore, solving this real linear set of equations can definitely yield a real non-zero solution for $x$, which is an eigenvector of $A$ corresponding to $\lambda$. (Note that $jx$ is also an eigenvector of $A$ corresponding to $\lambda$, and it's not real.)
Alternatively, suppose $x=u+jv$ is a complex eigenvector of $A$ corresponding to $\lambda$. Then $Ax=\lambda x$ means $A(u+jv)=\lambda(u+jv)$, implying that $Au=\lambda u$ and $Av=\lambda v$, since $\lambda$ is real. So $u$ and $v$ are real eigenvectors of $A$ corresponding to $\lambda$, if they are non-zero. (They can't both be zero.)
In fact, stronger statements can be made. Using the above argument repeatedly in the Schur Triangularization process, we can further show that $A$ can be diagonalized by a real orthogonal matrix, i.e. $U^*AU=D$, where $U$ is real orthogonal and $D$ is real diagonal. So $U$ consists of $n$ real orthogonal eigenvectors of $A$, which diagonalize $A$ and also form a basis for $R^n$.