Showing if two matrices have the same eigenvectors, they commute

Solution 1:

You know that

$$A=PUP^{-1}$$

and

$$B=PVP^{-1}$$

for some diagonal $U,V$ (which commute). The matrix $P$ can be made the same since it's made of linearly independent eigenvectors of $A,B$ which are (can be made and ordered) the same.

$$AB=PUP^{-1}PVP^{-1} = PUVP^{-1}=\cdots$$ $$\cdots=PVUP^{-1}=PVP^{-1}PUP^{-1} = BA$$