How is $\text{tr}(AB) = \text{tr}(BA)$? I have already seen theoretical proofs on how $\text{tr}(AB) =\text{tr}(BA)$, but I'd like to see how this is true concretely. Let's say I have two $2\times 2$ matrices:
$A = \begin{bmatrix}
2&4\\
6&2
\end{bmatrix}$ and $B = \begin{bmatrix}
1&4\\
2&8
\end{bmatrix}$. 
$\text{tr}(AB) = 100$ while $\text{tr}(BA) = 114$. So how is $\text{tr}(AB) = \text{tr}(BA)$ valid?
 A: $$AB=\begin{bmatrix}2&4\\6&2\end{bmatrix}\begin{bmatrix}1&4\\2&8\end{bmatrix}=\begin{bmatrix}\color{red}{10}&40\\10&\color{red}{40}\end{bmatrix}.$$
So Trace$(AB)=10+40=50.$
$$BA=\begin{bmatrix}1&4\\2&8\end{bmatrix}\begin{bmatrix}2&4\\6&2\end{bmatrix}=\begin{bmatrix}\color{red}{26}&12\\52&\color{red}{24}\end{bmatrix}.$$
So Trace$(BA)=26+24=50.$
A: 
A = {{2,4},{6,2}} and B = {{1,4},{2,8}}

Assuming you specified column vectors $A = (a_1, a_2)$, we get:
> A=[2,4;6,2]'
A =

   2   6
   4   2

> B=[1,4;2,8]'
B =

   1   2
   4   8

> A*B
ans =

   26   52
   12   24

> B*A
ans =

   10   10
   40   40

In both cases the trace (sum of the diagonal elements) is $50$.
If it were row vectors, the matrices have to be transposed, and it would make no difference:
$$
A^T B^T = (BA)^T \\ 
B^T A^T = (AB)^T \\
$$
which means the same products show up, just in reverse order and transposed, which makes no difference for the trace each, as the diagonal elements stay the same under transposition.
The proof using Einstein summation convention is short:
$$
\DeclareMathOperator{tr}{tr}
\tr A B = \tr a_{ij} b_{jk} = a_{ij} b_{ji} = b_{ji} a_{ij} = \tr b_{ji} a_{ik} = \tr B A  
$$
A: Let $A,B\in M(n,\mathbb{K})$. Write $A=(a_{ij}) \ \mbox{and} B=(b_{ij})$. Then $$AB=(\Sigma_{k=1}^{n}a_{ik}b_{kj})$$ and $$BA=(\Sigma_{k=1}^{n}b_{ik}a_{kj})$$
Therefore $Tr(AB)=\Sigma_{i=1}^{n}\Sigma_{k=1}^{n}a_{ik}b_{ki}=\Sigma_{k=1}^{n}\Sigma_{i=1}^{n}b_{ki}a_{ik}=Tr(BA)$.
A: You compute wrongly the trace. The problem is still true. Just compute for 
$A = {\left( {{a_{ij}}} \right)_{n \times n}},B = {\left( {{b_{ij}}} \right)_{n \times n}}$
