How to show that if two matrices have the same eigenvectors, then they commute? This is a problem from Quarteroni, Sacco, and Saleri's Numerical Mathematics.  Their question isn't any more specific than my phrasing of it.  I don't see how to do it without any additional assumptions - for example, that they have the same generalized eigenspaces.  I'm also not very experienced in linear algebra so I also couldn't think of counterexamples if the general case is false.  
 A: This problem has been bugging me for a few days, I think I have a 'counterexample' in which two matrices $A,B$ share the same eigenspaces
but do not commute.
Let $A=\begin{bmatrix} 1 & 0 & 1 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \end{bmatrix}$.
Let $\Pi = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix}$
and note that $\Pi A \Pi^T = \begin{bmatrix} 1 & 1 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 2 \end{bmatrix}$, hence from the Jordan form we note that $A$ has two 1-dimensional eigenspaces,
$\operatorname{sp} \{e_1\}, \operatorname{sp} \{e_2\}$.
Let $B=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 1 \\ 0 & 0 & 2 \end{bmatrix}$.
Since $B$ is already in Jordan form we note that $B$ has two 1-dimensional eigenspaces,
$\operatorname{sp} \{e_1\}, \operatorname{sp} \{e_2\}$.
However, $AB-BA = \begin{bmatrix} 0 & 0 & 1 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \end{bmatrix}$.
A: Matrices  will commute when operating on any linear combination of shared eigenvectors
if $A\vec v_i=a_i \vec v_i$ and if $B\vec v_i=b_i \vec v_i$  then an arbitrary linear combination of shared eigenvectors is $\sum_i \alpha_i \vec v_i$
$$AB(\sum_i \alpha_i \vec v_i)=(\sum_i a_i b_i\alpha_i \vec v_i)=BA(\sum_i \alpha_i \vec v_i) 
$$
if the vectors $v_i$ form a basis for $R^n$ then the matrices commute when operating on any vector in $R^n$ and so $AB = BA$
