$AB=BA$ with same eigenvector matrix

I read in G. Strang's Linear Algebra and its Applications that, if $A$ and $B$ are diagonalisable matrices of the form such that $AB=BA$, then their eigenvector matrices $S_1$ and $S_2$ (such that $A=S_1\Lambda_1S_1^{-1}$ and $B=S_2\Lambda_2 S_2^{-1}$) can be chosen to be equal: $S_1=S_2$.

How can it be proved?

I have found a proof here, but it is not clear to me how to see that $C$ is diagonalisable as $DCD^{-1}=Q$. Matrix $C$ obviously is the matrix with the coordinates of $B\mathbf{x}$ with respect to the basis $\{\mathbf{x}_1,...,\mathbf{x}_k\}$ of the eigenspaceof $V_\lambda (A)$, but I do not see how we can know that it is diagonalisable.

Thank you very much for any explanation of the linked proof or other proof!!!

EDIT: Corrected statement of the lemma I am interested in. See comments below by the users whom I thank for what they have noticed.

• This isn't true. There are infinite ways to diagonalize a matrix and you can always pick $S_1\neq S_2$. Nov 14, 2014 at 20:02
• For example, if $S_1$ works, then so does $-S_1$. Where exactly in Strang did you read that? Nov 14, 2014 at 20:02
• The book states "diagonalizable matrices shares the same eigenvector matrix $S$ if and only if $AB=BA$" in a quite informal language. I think I misunderstood and I'm going to edit. Thank you for the comments! Nov 14, 2014 at 20:04
• An accurate statement is "two matrices commute if and only if they are simultaneously diagonalizable" that is, if and only if you can write $A = S\Lambda_1S^{-1}, B = S\Lambda_2S^{-1}$ (but there's nothing requiring this). Nov 14, 2014 at 20:08

The idea is to show that you can find a basis consisting of vectors that are eigenvectors of both $A$ and $B$. Then a proof goes by induction on the dimension of the space (or the size of the matrices, if you prefer that). The key observation is the following.

Let $V$ be the whole space ($\Bbb{C}^n$ or $\Bbb{R}^n$, depending). Let $\lambda$ be an eigenvalue of $A$. Consider the corresponding eigenspace $V_\lambda$. Then it follows that $B(V_\lambda)\subseteq V_\lambda$. This is because for all $x\in V_\lambda$ we have $$A(Bx)=(AB)x=(BA)x=B(Ax)=B(\lambda x)=\lambda (Bx)$$ proving that $Bx\in V_\lambda$.

This holds for all eigenvalues of $A$. If there is more than one eigenspace, then they all have dimensions $<\dim V$, and induction hypothesis kicks in: by the above observation it is enough to settle the question for all those smaller spaces as by diagnoalizablity of $A$ the whole space is a direct sum of $V_\lambda$:s.

OTOH, if one of the $V_\lambda$:s is the whole space, then $A$ is a scalar matrix, and thus diagonalized by any matrix $S$. In that case it suffices to simply diagonalize $B$.

The base case of $1\times 1$ matrices is trivial.

What seems to be missing from the above is that the subspace $V_\lambda$ also has a basis consisting of eigenvectors of $B$. This can be shown as follows. Diagonalizability of $A$ means that $$V=V_\lambda\oplus\left(\bigoplus_{\mu\neq\lambda}V_\mu\right)$$ is a sum of eigenspaces of $A$. Call that other summand $V_{\neq\lambda}$. Both $V_\lambda$ and $V_{\neq\lambda}$ are stable under $B$, because the above argument also shows that $B(V_\mu)\subseteq V_\mu$ for all $\mu$. If $\beta$ is any eigenvalue of $B$, and $U_\beta$ is the corresponding eigenspace, then any vector $y\in U_\beta$ can be uniquely written in the form $y=y_1+y_2$ with $y_1\in V_\lambda$, $y_2\in V_{\neq\lambda}$. Here $By=\beta y=(\beta y_1)+(\beta y_2)$. But as $By_1\in V_\lambda$ and $By_2\in V_{\neq\lambda}$ we must have $By= By_1+By_2$. By the direct sum property we can conclude that $By_1=\beta y_1$ and $By_2=\beta y_2$. Therefore $$U_\beta=(U_\beta\cap V_\lambda)\oplus (U_\beta\cap V_{\neq\lambda}).$$ The claim follows from this. [\Edit].

• I'm fairly sure that this has been explained on the site already, but my first search didn't show anything explicit - the result of simultaneous diagonalizability was used/mentioned many times. So I decided to post a sketch. Will delete if a suitable duplicate shows up. Nov 14, 2014 at 21:11
• Thank you so much for your answer! I hope I've understood: if $A:V\to V$, $V=\bigoplus_i E_i$ where each $E_i$ is a space generated by eigenvectos corresponding to a set of eigenvalues of $A$ all distinct from each other. Then the restriction of $A$ to each $E_i$ and the result explained by alexjo prove the lemma. Have I misunderstood anything? Why is $V$ such a direct sum? Is every $E_i$ orthogonal to the other ones? I heartily thank you again! Nov 15, 2014 at 10:36
• @DavideZena: You don't get orthogonality unless $A$ is Hermitian (or real symmetric). But the some of eigenspaces is always direct. If $x_1,x_2,\ldots,x_m$ belong to different eigenvalues $\lambda_i$ of $A$, then from any linear dependency relation $\sum_ic_ix_i=0$ you get another one by applying $A$: $\sum_i \lambda_ic_ix_i=0$. Then working with these two relations you can eliminate one of the vectors, and proceed by induction. Diagonalizability implies that the sum of eigenspaces is the whole space. Nov 15, 2014 at 10:56
• The idea is that $x\in V_\lambda\implies Bx\in V_\lambda$? So both $A$ and $B$ map $V_\lambda$ to itself. If $\dim V_\lambda<\dim V$, then we can apply induction to $V_\lambda$. Nov 15, 2014 at 19:35
• @Davide: I added an explanation showing that the restriction of $B$ to $V_\lambda$ is also diagonalizable. This is needed for the induction to work. Sorry about not explaining that earlier. Nov 16, 2014 at 21:48

Proposition. Diagonalizable matrices share the same eigenvector matrix $S$ if and only if $AB = BA$.

Proof. If the same $S$ diagonalizes both $A = S\Lambda_1S^{-1}$ and $B = S\Lambda_2S^{-1}$, we can multiply in either order: $$AB = S\Lambda_1S^{-1}S\Lambda_2S^{-1}= S\Lambda_1\Lambda_2S^{-1} \;\text{and}\; BA = S\Lambda_2S^{-1}S\Lambda_1S^{-1}= S\Lambda_2\Lambda_1S^{-1}.$$ Since $\Lambda_1\Lambda_2 = \Lambda_2\Lambda_1$ (diagonal matrices always commute) we have $AB = BA$.

In the opposite direction, suppose $AB = BA$. 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 all one-dimensional), then $Bx$ must be a multiple of $x$. In other words $x$ is an eigenvector of $B$ as well as $A$. The proof with repeated eigenvalues is a little longer.

• This is the idea (+1). Repeated eigenvalues can be handled for example by induction. Nov 14, 2014 at 21:12
• Thank you very much! In the case where eigenvectors of $A$ arn't distinct and $\dim V_\lambda>1$ how can the proof be generalised? I heartily thank you!!! Nov 16, 2014 at 14:40
• Proof is just a copy-paste of the proof given in G. Strang' s book. Oct 5, 2023 at 14:15
• how should we prove that $Bx$ is a multiple of $x$ in the case of repeated eigenvalues ? Nov 9, 2023 at 7:34