# Trace of matrix proof

1. Aug 26, 2014

### jonroberts74

1. The problem statement, all variables and given/known data

Prove $tr(AA^T)=tr(A^TA)=s$ where $s$ is the sum of the squares of the entries of A

I need help cleaning this up and I don't think my sigma notation is completely correct.

3. The attempt at a solution

I found the identity $$(AB)^T=B^TA^T$$then applying it to $AA^T \Rightarrow (AA^T)^T= (A^T)^TA^T=AA^T$ and $(A^T)^T=A, A^T=A^T$ so now I know A is symmetric.

$A= \displaystyle\sum_{i,j=1}^{n} a_{i,j}$ and $A^T= \displaystyle\sum_{j,i=1}^{n} a_{j,i}$, $A=A^T$so we know $\displaystyle\sum_{j,i=1}^{n} a_{j,i}= \displaystyle\sum_{i,j=1}^{n} a_{i,j}$

also $s=\displaystyle\sum_{i,j}^{n}(a_{i,j})^2$

then $AA^T=A^TA=A^2 \Rightarrow [AA^T]_{i,k} = \displaystyle\sum_{j}^{n} a_{i,j}a_{j,k}$
so $Tr(A^2) = Tr\Bigg(\displaystyle\sum_{j}^{n} a_{i,j}a_{j,k}\Bigg) = \displaystyle\sum_{i,j}^{n}(a_{i,j})^2 = s$
thanks!

Last edited: Aug 26, 2014
2. Aug 26, 2014

### Zondrina

Actually looks completely fine.

3. Aug 26, 2014

### jonroberts74

the trace of the the product would be the sum of the squares along the diagonal and s is the entries of A (not the product) squared and summed. I know its true, I proved it for a 3x3 square matrix but it has to be symmetric.

heres the 2x2 case

Let $A=\left[\begin{array}{cc} a_{11} & a_{12} \\ a_{21} & a_{22}\end{array}\right]$so $A^T= \left[\begin{array}{cc} a_{11} & a_{21} \\ a_{12} & a_{22}\end{array}\right]$

and $s=(a_{11})^2+(a_{12})^2+(a_{21})^2+(a_{22})^2$

now,

$tr(AA^T)=tr\Bigg(\left[\begin{array}{cc} a_{11} & a_{12} \\ a_{21} & a_{22}\end{array}\right]\left[\begin{array}{cc} a_{11} & a_{21} \\ a_{12} & a_{22}\end{array}\right]\Bigg) = tr\Bigg(\left[\begin{array}{cc} (a_{11})^2 + (a_{12})^2 & a_{11}a_{21} + a_{12}a_{22} \\ a_{11}a_{21} + a_{12}a_{22} & (a_{21})^2 + (a_{22})^2\end{array}\right]\Bigg)$

$= (a_{11})^2+(a_{12})^2+(a_{21})^2+(a_{22})^2 = s$

and,

$tr(A^TA)=tr\Bigg(\left[\begin{array}{cc} a_{11} & a_{21} \\ a_{12} & a_{22}\end{array}\right]\left[\begin{array}{cc} a_{11} & a_{12} \\ a_{21} & a_{22}\end{array}\right]\Bigg) = tr\Bigg(\left[\begin{array}{cc} (a_{11})^2 + (a_{21})^2 & a_{11}a_{12} + a_{21}a_{22} \\ a_{11}a_{12} + a_{21}a_{22} & (a_{12})^2 + (a_{22})^2\end{array}\right]\Bigg)$

$=(a_{11})^2+(a_{12})^2+(a_{21})^2+(a_{22})^2 = s$

therefore, $tr(AA^T)=tr(A^TA)=s$

its probably not the best proof. Now I am trying to do the more general proof and want to use sigma notation so its not really messy making general square matrices.

Edit. Thanks!

4. Aug 26, 2014

### Ray Vickson

Why do you claim that $A$ is symmetric? The result holds equally well for any square matrix, whether symmetric or not. Your 2x2 example shown later does NOT need a symmetric matrix; nowhere there did you say that you had to have $a_{12} = a_{21}$ in order to make it work.

Also, you have written a number of seriously incorrect statements: the equations
$$A =\sum_{i,j=1}^{n} a_{i,j} \text{ and } A^T = \sum_{j,i=1}^{n} a_{j,i}$$
are wrong (and, basically, meaningless). You cannot just equate the $n \times n$ matrix $A$ to a sum of scalars $a_{ij}$.

5. Aug 26, 2014

### jonroberts74

I tried find summation notation for a matrix the ones I found were in similar fashion also

and $\left[\begin{array}{cc} 1&4\\2&3\end{array}\right] \left[\begin{array}{cc} 1&2\\4&3\end{array}\right]$wont have the same trace as $\left[\begin{array}{cc} 1&2\\4&3\end{array}\right]\left[\begin{array}{cc} 1&4\\2&3\end{array}\right]$

6. Aug 26, 2014

### Zondrina

Hmm I would write it like this:

You want to show $s$, which is the sum of the squares of the entries in matrix $A$, is equal to the trace of $AA^T$.

So $s = \sum_{j = 1}^{m} \sum_{i = 1}^{n} (A_{ij}^2)$ where the $A_{ij}$ are the matrix elements in $A$.

Then the trace is given by:

$tr(AA^T) = tr([AA^T]_{ij}) = tr(\sum_{k=1}^{m} A_{ik} A^T_{kj})$

Last edited: Aug 26, 2014
7. Aug 26, 2014

### jonroberts74

oh okay so to write the n x n matrix A

$[A]_{i,j} = \displaystyle\sum_{i,j=1}^{n} A_{i,j}$

and to continue what you have

$tr(AA^T) = tr([AA^T]_{ij}) = tr(\sum_{k=1}^{m} A_{ik} A^T_{kj}) = (a_{i,1})^2+(a_{i,2})^2+...+(a_{i,n})^2+(a_{1,j})^2+(a_{2,j})^2+...+(a_{n,j})^2 = \sum_{j = 1}^{m} \sum_{i = 1}^{n} (A_{ij}^2) = s$

8. Aug 26, 2014

### Ray Vickson

Nope. If you compute them both you will see that they both have the same trace = 30 = 1^2 + 2^2 + 3^2 + 4^2.

9. Aug 26, 2014

### jonroberts74

oh yeah, I was squaring down the diagonal for whatever reason. I apologize, you are correct.

10. Aug 26, 2014

### Zondrina

To continue further:

$tr(AA^T) = tr([AA^T]_{ij}) = tr(\sum_{k=1}^{m} A_{ik} A^T_{kj}) = tr(A_{i1}A^T_{1j} + A_{i2}A^T_{2j} + A_{i3}A^T_{3j} + ... + A_{im}A^T_{mj} )$

The sum $s = \sum_{j = 1}^{m} \sum_{i = 1}^{n} (A_{ij}^2) = A_{11}^2 + A_{21}^2 + \cdots + A_{n1}^2 + \cdots + A_{1m}^2 + A_{2m}^2 + \cdots + A_{nm}^2$

11. Aug 26, 2014

### Fredrik

Staff Emeritus
This notation is a bit odd, since indices suggest that we're dealing with a component of a matrix rather than the matrix itself. I would write the definitions of trace and matrix multiplication as
\begin{align}
&\operatorname{Tr} A=\sum_i A_{ii}\\
&(AB)_{ij}=\sum_k A_{ik}B_{kj},
\end{align} and then start the calculation like this:
$$\operatorname{Tr}(AA^T)=\sum_i (AA^T)_{ii} =\cdots$$ I initially wrote down two more very short and simple steps, but then I took another look at the problem statement and realized that my string of three simple equalities was the complete solution.

12. Aug 26, 2014

### jonroberts74

figured this out another way

Let A be an m x n matrix and $s =\displaystyle\sum_{i=1}^{m}\sum_{j=1}^{n} a_{i,j}^2$

$A = \left[\begin{array}{cc}R_{1}\\R_{2}\\.\\.\\.\\R_{m}\end{array}\right] = \left[\begin{array}{cc}C_{1}&C_{2}&.&.&.&C_{n}\end{array}\right]$ where $R_{i},C_{i}$ are rows and columns

now $A^T =\left[\begin{array}{cc}R_{1}&R_{2}&.&.&.&R_{m}\end{array}\right] = \left[\begin{array}{cc}C_{1}\\C_{2}\\.\\.\\.\\C_{n}\end{array}\right]$

so $AA^T$ gives an m x m matrix and $A^TA$ gives an n x n matrix by doing the dot product, $R_{i} \cdot R_{i}, C_{i} \cdot C_{i}$, respectively. Now, I'm after the trace so I only need the diagonal
so $\displaystyle\sum_{i=1}^{m} R_{i} \cdot R_{i} = \displaystyle\sum_{i=1}^{n} C_{i} \cdot C_{i} =\displaystyle\sum_{i=1}^{m}\sum_{j=1}^{n} a_{i,j}^2 = s$

this is just the rundown, the version I turned in was more formal looking.

Last edited: Aug 26, 2014
13. Aug 26, 2014

### Fredrik

Staff Emeritus
If the Rs and Cs denote the same things in that last line as in the first, there should be transpose symbols on them in the last line, i.e. $R_1{}^T$ rather than $R_1$.

The ij component of $AA^T$ will be $R_iR_j{}^T$. This is equal to $R_i{}^T\cdot R_j{}^T$ and $R_i\cdot R_j$, so you appear to be doing the right calculations, but writing them down in a way that's a little bit strange.

Since you have solved the problem, I will show you my complete solution:
$$\operatorname{Tr}(AA^T)=\sum_i (AA^T)_{ii} =\sum_i\sum_j A_{ij}(A^T)_{ji} =\sum_i\sum_j A_{ij}A_{ij}=s.$$ First equality: Just the definition of the trace.
Second equality: Just the definition of matrix multiplication.
Third equality: Just the definition of the transpose.

Most people don't bother to learn the definitions in this way. Perhaps this will be the motivation you need to do it.

14. Aug 26, 2014

### jonroberts74

okay perfect thanks! Yeah the more I know the better, I am a math major so I don't want to learn just the bare minimum.

15. Aug 27, 2014

### HallsofIvy

Staff Emeritus
Again, this is wrong. On the left you have an array of numbers, on the right a single number- the sum of the numbers in that array.