Do commuting matrices share the same eigenvectors? In one of my exams I'm asked to prove the following 

Suppose $A,B\in \mathbb R^{n\times n}$, and $AB=BA$, then $A,B$ share the same eigenvectors. 

My attempt is let $\xi$ be an eigenvector corresponding to $\lambda$ of $A$, then $A\xi=\lambda\xi$, then I want to show $\xi$ is also some eigenvector of $B$ but I get stuck.
 A: They will share an eigenvector: suppose $Ax = ax$, then $BAx = Bax$ and by commutativity $A(Bx) = a(Bx)$, so if $x$ is an eigenvector of $A$ then $Bx$ is an eigenvector of $A$ with the same eigenvalue. Now look at the subspace $V$ generated by $x, Bx, B^2 x,...$, which are all eigenvectors of $A$. Then $V$ is invariant under $B$, so $V$ also contains an eigenvector of $B$.
In fact, more is true. If $A : V \to V$ then we can write $V$ as a direct sum of subspaces $V_\lambda$ of generalised eigenvectors associated to each eigenvalue $\lambda$ of $A$. The $V_\lambda$ are $B$-invariant. So we can split up $V_\lambda$ further into a direct sum of $V_{\lambda\mu}$ corresponding to the different eigenvalues $\mu$ of $B$. We could continue doing this if we have more matrices $C,D$, and so on. This way we split $V$ as a direct sum, and each term of the sum is a generalised eigenspace of all the matrices.
So we can write the matrices as block diagonal matrices where the shape of the blocks is the same for all the matrices, and all the eigenvalues on the diagonal of each block are the same in all matrices. Furthermore, each block may be put in upper triangular form.
A: Matrices $A = \pmatrix{0&1\\0&0}, B = \pmatrix{1&0\\0&1}$ commute, but they don't share the eigenvector $\pmatrix{0\\1}$  of $B.$
A: Let $S$ be a set of commuting matrices over an algebraically closed field $F$. As Algebraic Pavel said above, there may not be a common basis of eigenvectors (since any of them may not be diagonalizable!) but there must be at least a common eigenvector. Let us prove that this can also be seen as an easy consequence of Burnside's theorem on matrix algebras:
Burnside's theorem on matrix algebras states that if $F$ is algebraically closed, $V$ is a finite-dimensional $F$-vector space and $S$ is a proper subalgebra of $\text{End}(V)$ then there exists a nontrivial $S$-invariant subspace, i.e, there exists $W\leq V$ with $0\neq W\neq V$ such that $s(W)\subseteq W$ for every $s\in S$.
Suppose $S\subseteq M_n(F)$ with $n>1$ is commuting. Observe that a subspace of $F^n$ is $S$-invariant if and only if it is invariant for $\langle S\rangle$, the subalgebra of $M_n(F)$ generated by $S$. Since $S$ is commuting, $\langle S\rangle$ is also commuting and therefore $\langle S\rangle\neq M_n(F)$. Burnside's theorem applies, and so there exists a proper and nontrivial subspace $V\leq F^n$ which is invariant for all $S$. If $V$ has dimension more than $1$ then $\langle S\rangle\neq\text{End}(V)$, since $\langle S\rangle$ is commuting, and we can apply Burnside's theorem again. By induction there exists an $S$-invariant subspace of dimension $1$, and so a common eigenvector for the matrices in $S$.
A: The other counterexample can be generated with a real skew-symmetric matrix, denote it $K$.   Consider matrix dimension $4 \times 4$.  Take for example $$K=\begin{bmatrix} 0 & 3 & 0 & 0  \\ -3 & 0 & 0 & 0\\ 0 & 0 & 0 & 4\\ 0 & 0 & -4 & 0 \end{bmatrix}\,.$$
Now if $K$ is skew-symmetric then $K^2$ is symmetric. $K$ and $K^2$ commute as polynomials.  
Now for $K$ we have no real eigenvectors at all, but for $K^2$ (as it is symmetric) there are eigenvectors which can be presented as only real. The matrices do not share any eigenvectors.
A: The answer is in the book Linear Algebra and its Application by Gilbert Strang. I'll just write down what he said in the book.

Starting from $Ax=\lambda x$, we have
$$ABx = BAx = B \lambda x = \lambda Bx$$
Thus $x$ and $Bx$ are both eigenvectors of $A$, sharing the same $\lambda$ (or else $Bx = 0$). If we assume for convenience that the eigenvalues of $A$ are distinct – the eigenspaces are one dimensional – then $Bx$ must be a multiple of $x$. In other words $x$ is an eigenvector of $B$ as well as $A$.

There's another proof using diagonalization in the book.
A: Commuting matrices do not necessarily share all eigenvector, but generally do share a common eigenvector.
Let $A,B\in\mathbb{C}^{n\times n}$ such that $AB=BA$. There is always a nonzero subspace of $\mathbb{C}^n$ which is both $A$-invariant and $B$-invariant (namely $\mathbb{C}^n$ itself). Among all these subspaces, there exists hence an invariant subspace $\mathcal{S}$ of the minimal (nonzero) dimension.
We show that $\mathcal{S}$ is spanned by some common eigenvectors of $A$ and $B$.
Assume that, say, for $A$, there is a nonzero $y\in \mathcal{S}$ such that $y$ is not an eigenvector of $A$. Since $\mathcal{S}$ is $A$-invariant, it contains some eigenvector $x$ of $A$; say, $Ax=\lambda x$ for some $\lambda\in\mathbb{C}$. Let $\mathcal{S}_{A,\lambda}:=\{z\in \mathcal{S}:Az=\lambda z\}$. By the assumption, $\mathcal{S}_{A,\lambda}$ is a proper (but nonzero) subspace of $\mathcal{S}$ (since $y\not\in\mathcal{S}_{A,\lambda}$).
We know that for any $z\in \mathcal{S}_{A,\lambda}$, $Bz\in \mathcal{S}$ since $\mathcal{S}_{A,\lambda}\subset\mathcal{S}$ and $\mathcal{S}$ is $B$-invariant. However, $A$ and $B$ commute so 
$$
ABz=BAz=\lambda Bz \quad \Rightarrow\quad Bz\in \mathcal{S}_{A,\lambda}.
$$
This means that $\mathcal{S}_{A,\lambda}$ is $B$-invariant. Since $\mathcal{S}_{A,\lambda}$ is both $A$- and $B$-invariant and is a proper (nonzero) subspace of $\mathcal{S}$, we have a contradiction. Hence every nonzero vector in $\mathcal{S}$ is an eigenvector of both $A$ and $B$.

EDIT: A nonzero $A$-invariant subspace $\mathcal{S}$ of $\mathbb{C}^n$ contains an eigenvector of $A$.
Let $S=[s_1,\ldots,s_k]\in\mathbb{C}^{n\times k}$ be such that $s_1,\ldots,s_k$ form a basis of $\mathcal{S}$. Since $A\mathcal{S}\subset\mathcal{S}$, we have $AS=SG$ for some $G\in\mathbb{C}^{k\times k}$. Since $k\geq 1$, $G$ has at least one eigenpair $(\lambda,x)$. From $Gx=\lambda x$, we get $A(Sx)=SGx=\lambda(Sx)$ ($Sx\neq 0$ because $x\neq 0$ and $S$ has full column rank). The vector $Sx\in\mathcal{S}$ is an eigenvector of $A$ and, consequently, $\mathcal{S}$ contains at least one eigenvector of $A$.

EDIT: There is a nonzero $A$- and $B$-invariant subspace of $\mathbb{C}^n$ of the least dimension.
Let $\mathcal{I}$ be the set of all nonzero $A$- and $B$-invariant subspaces of $\mathbb{C}^n$. The set is nonempty since $\mathbb{C}^n$ is its own (nonzero) subspace which is both $A$- and $B$-invariant ($A\mathbb{C}^n\subset\mathbb{C}^n$ and $B\mathbb{C}^n\subset\mathbb{C}^n$). Hence the set $\mathcal{D}:=\{\dim \mathcal{S}:\mathcal{S}\in\mathcal I\}$ is a nonempty subset of $\{1,\ldots,n\}$. By the well-ordering principle, $\mathcal{D}$ has the least element and hence there is a nonzero $\mathcal{S}\in\mathcal{I}$ of the least dimension.
A: (Modified) Answer of Qiaochu Yuan here: This is false in a sort of trivial way. The identity matrix $I$ commutes with every matrix and has eigenvector set all of the underlying vector space $V$, but no other matrix except a multiple of the identity matrix has this property.
A: As noted in another answer, the statement is not true as stated, just take
$$
A = \begin{bmatrix}1&0\\0&1\\\end{bmatrix},
\qquad
B = \begin{bmatrix}1&0\\0&2\\\end{bmatrix}.
$$
What is true is that, if $A$ and $B$ are diagonalizable, then $A$ and $B$ can be simultaneously diagonalized. Thanks to Thomas Andrews for pointing out an oversight.
Applying $B$ to both sides of  $\lambda \xi = A \xi$ you get $\lambda (B \xi) = B A \xi = A (B \xi)$, so either $B \xi = 0$, or $B \xi$ is an eigenvector for $A$ with respect to the eigenvalue $\lambda$.
In any case $B$ maps the eigenspace $W$ of $A$ relative to the eigenvalue $\lambda$ into itself. On $W$, $A$ acts like the scalar $\lambda$. Now one can put $B$ in diagonal form on $W$ without changing the scalar shape of $A$ on $W$.
