Show that $\operatorname{tr}(AB)=\operatorname{tr}(BA)$ for any square matrices $A,B$ of size $n$. 
Let $A=(a_{i,j})$ be a square matrix of size $n$. Define $$\operatorname{tr} A :=\sum_{i=1}a_{i,i}=a_{1,1}+a_{2,2}+\cdots+a_{n,n}$$
(a) Show that $\operatorname{tr}(AB) = \operatorname{tr}(BA)$ for any square matrices $A,B$ of size $n$.
(b) Let $B$ be an invertible square matrix of size $n$. Show that $$\operatorname{tr} \left( B^{-1} A B \right) = \operatorname{tr}A$$

How do I do this? Sorry for posting without doing any work but I have completely no idea how to even start.
 A: Let $C=AB.$ Then $c_{ij} = \sum_{k=1}^n a_{ik} b_{kj}.$
So $\operatorname{tr}(C) = \sum_{i=1}^n c_{ii} = \sum_{i=1}^n \left( \sum_{k=1}^n a_{ik} b_{ki}\right).$
Now do the same thing with $BA$ and observe that you get the same result.
You ought to be more specific about where your difficulty lies before you can expect more than what is above as an answer.
As for $\operatorname{tr}(B^{-1}AB),$ it is $\operatorname{tr}\Big( \big(B^{-1}\big)\big(AB\big) \Big).$ What was done above says you can interchange the order of multiplitation of the two matrices in the $\big( \text{intermediate-sized round brackets} \big)$ and get $\operatorname{tr}\Big( \big(AB\big)\big(B^{-1}\big)\Big).$ Then simplify that.
A: Let $C := AB$ and $D := BA$. Matrix multiplication is defined "entry-wise", with $c_{ij} := \sum_{k=1}^n a_{ik}b_{kj}$, and $d_{ij} := \sum_{k=1}^n b_{ik}a_{kj}$. Thus
$$c_{ii} = \sum_{k=1}^n a_{ik}b_{ki}$$
and
$$d_{ii} = \sum_{k=1}^n b_{ik}a_{ki}\,.$$
So $$\mathrm{tr}(C) := \sum_{i=1}^n c_{ii} = \sum_{i=1}^n\sum_{k=1}^n a_{ik}b_{ki}$$
and
$$\mathrm{tr}(D) := \sum_{i=1}^n d_{ii} = \sum_{i=1}^n\sum_{k=1}^n b_{ik}a_{ki} =  \sum_{k=1}^n\sum_{i=1}^n b_{ik}a_{ki} =  \sum_{k=1}^n\sum_{i=1}^n a_{ki} b_{ik},$$
where the two last equalities follow from the independence of the sum signs and commutativity of products (I assume your ring is commutative). Interchanging the $k, i$ symbols in $\mathrm{tr}(D)$, we get $\sum_{i=1}^n\sum_{k=1}^n a_{ik} b_{ki} = \mathrm{tr}(C)$. From the definition of $C, D$, we get
$$\mathrm{tr}(AB) = \mathrm{tr}(AB). \quad\square$$
Given this theorem, $\mathrm{tr}(B^{-1}AB) = \mathrm{tr}((B^{-1}A)B) = \mathrm{tr}(B(B^{-1}A)) = \mathrm{tr}((BB^{-1})A) = \mathrm{tr}(IA) = \mathrm{tr}A$, as required.
A: With
$A = [a_{ij}], \tag 1$
$B = [b_{ij}], \tag 2$
we have
$(AB)_{ij} = \displaystyle \sum_{k = 1}^n a_{ik}b_{kj}; \tag 3$
$(BA)_{ij} = \displaystyle \sum_{k = 1}^n b_{ik}a_{kj}; \tag 4$
then
$\text{tr}(AB) = \displaystyle \sum_{i = 1}^n (AB)_{ii} = \sum_{i = 1}^n  \sum_{k = 1}^n a_{ik}b_{ki}$
$= \displaystyle \sum_{k = 1}^n \sum_{i = 1}^n b_{ki}a_{ik} = \sum_{k = 1}^n (BA)_{kk} = \text{tr}(BA).  \tag 5$
We can use this result to show that with $B$ invertible
$\text{tr}(B^{-1}AB) = \text{tr}(A), \tag 6$
for
$\text{tr}(B^{-1}AB) =  \text{tr}(B^{-1}(AB))$
$=  \text{tr}((AB)B^{-1}) = \text{tr}(A(BB^{-1})) = \text{tr}(AI) = \text{tr}(A). \tag 7$
Note Added in Edit, Sunday 29 December 2019 1:09 PM PST:  I think it is worth observing that any function $\sigma$ of $n \times n$ matrices such that
$\sigma(AB) = \sigma(BA) \tag 8$
is itself a similarity invariant; that is, for invertible $B$,
$\sigma(B^{-1}AB) = \sigma(A); \tag 9$
the proof of this simply follows (7):
$\sigma(B^{-1}AB) = \sigma(B^{-1}(AB))$
$= \sigma((AB)B^{-1}) = \sigma(A(BB^{-1})) = \sigma(AI) = \sigma(A). \tag{10}$
Furthermore, the implication 
$(9) \Longrightarrow (7) \tag{11}$
also binds, since
$\sigma(AB) = \sigma(I(AB)) = \sigma((B^{-1}B)AB) = \sigma(B^{-1}(BA)B) = \sigma(BA). \tag{12}$
End of Note.
