I found the following problem
Prove that if $A, B \in \mathbb{k}^{n\times n}$ are diagonal then $AB=BA$ where $\mathbb{k}$ is a field.
I wanted to prove this via the scalar definition of each element in the matrices; this is, without appealing to simply computing the product for $AB$ and $BA$ and finding they are the same. I was wondering whether my proof is correct (I self-study and have no professors to correct/validate this). More importantly, I want to know whether there are alternative, simpler proofs of this property. This is what I did.
Let $AB=C$. Then $c_{ij}=\sum_{k=1}^n a_{ik}b_{kj}$. Note that because $j \neq i \implies a_{ij}=b_{ij}=0$ then $a_{ik}b_{kj}=0$ whenever $i \neq k \neq j$.
Let $j \neq i$. Then $c_{ij}=a_{i1}b_{1j}+ a_{i2}b_{2j}+ \cdots + a_{ij}b_{ij}+ \cdots +a_{in}b_{nj}$. Notice that because $i \neq j$ every term $a_{ik}b_{kj}$ has at least one factor $0$, since $i=k \implies k\neq j \implies b_{kj}=0$ and $j=k \implies i \neq j \implies a_{ik}=0$. (Of course for $k \neq i \neq j$ both factors are $0$.) Then $c_{ij}=0$.
Let $j=i$. Then $c_{ij}$ has terms $a_{ik}b_{kj}$ that are $0$ when $k \neq i \neq j$, and a single non-null term $a_{ij}b_{ij}=a_{ii}b_{ii}$. Then $c_{ij}=a_{ii}b_{ii}$. Then $C$ is a diagonal matrix with $c_{ii}={a_{ii}b_{ii}}$.
The exact same reasoning goes to show that $BC=C'$ has terms
$$ \begin{cases}c'_{ij}=0 & j \neq i \\ c'_{ij}=b_{ii}a_{ii} & j=i \end{cases} $$
Because $b_{ii}a_{ii}=a_{ii}b_{ii}$ we have $c_{ij}=c'_{ij} \implies AB=BA$.