# $AB=BA$ if there is an orthonormal basis of $\mathbb{R}^n$ of eigenvectors

Show that if there is an orthonormal basis of $\mathbb{R}^n$ that consists of eigenvectors of both of the $n \times n$ matrices $A$ and $B$, then $AB = BA$.

I'm not sure if what I have done suffices to solve the problem, but let $(v_1,v_2,v_3,v_4)$ be the basis of orthonormal eigenvevtors of $A$ and $B$.

Then for example, $Av_1=\lambda_1 v_1$ and $Bv_1=\mu_1 v_1$ (where $\lambda$ and $\mu$ are corresponding eigevalues).

Then we have $$ABv_1=A\mu_1 v_1=\mu_1 A v_1=\mu_1 \lambda_1 v_1 = \lambda_1 B v_1=BAv_1$$

And since we can do this for all $(v_1,v_2,v_3,v_4)$, thus $AB=BA$

If that that does not suffice, could anybody point out why? Thanks!

$$AB(v_{j}) = \lambda_{j}\mu_{j}v_{j} = BAv_{j}$$
for $1\leq j \leq n$.