From index notation to trace of matrices product

426 Views Asked by At

Let $M \in R ^{n\times p} $, $A \in R^{n\times n}$ and $D$ be a diagonal matrix in $R^{n\times n}$ such that: $$d_{ii}=\sum_{j=1}^na_{ij}$$

So I need to prove that: $$ \frac{1}{2} \sum_{i=1}^{n}\sum_{j=1}^{n} (m^i-m^j)^2 a_{ij},$$ is equal to: $$ tr(M^\top {(D-A)} M)= tr( M^\top {LM}) $$

With:

$L$ is the Laplacian matrix defined as $D-A$.

$m^i$ denotes $i$-th row of the matrice $M$.

$a_{ij}$ defontes the entry on A in $i$-th row and $j$-th colomn.

$\|m^i\|_2$ denotes $\ell_2$ norm of the vector $m^i$ defined as $\sqrt(\sum_{j=1}^p m_{ij}^2)$

$A$ is symetric matrix, can be viewed as adjacency matrix

Thanks

EDIT: I do the following steps but i dont know how to get the trace in the end $$ \frac{1}{2} \sum_{i,j}(m^i-m^j)^2 a_{ij}$$ $$= \sum_{i,j} {m^i}^\top a_{ij} m^i - \sum_{i,j} {m^i}^\top a_{ij}m^j$$ $$= \sum_{i} {m^i}^\top (\sum_{j} a_{ij}) m^i - \sum_{i,j} {m^i}^\top a_{ij}m^j$$ $$= \sum_{i} {m^i}^\top d_{ii} m^i - \sum_{i,j} {m^i}^\top a_{ij}m^j$$ $$= M^\top DM - M^\top AM$$ $$= M^\top (D-A)M $$ $$= M^\top LM $$

So, i need to get $tr(M^\top LM)$ bu i only get $M^\top LM$, it is where the problem in my proof ?

Second EDIT

I tried a second proof, starting from the left term in order to have the term right but I still can not have the trace. Could you help me please ?

\begin{equation*} \begin{gathered} \frac{1}{2} \sum_{i,j}(m^i-m^j)^2 a_{ij} \\ \frac{1}{2} \sum_{i,j}({m^i}^2+{m^j}^2-2m^im^j)a_{ij}\\ \frac{1}{2} \sum_{i,j}{m^i}^2a_{ij}+{m^j}^2a_{ij}-2m^im^ja_{ij}\\ \frac{1}{2} \sum_{i,j} {m^i}^2a_{ij}+{m^j}^2a_{ij}- \frac{1}{2} \sum_{i,j}2m^im^ja_{ij} \\ \frac{1}{2} \sum_{i,j} {m^i}^2a_{ij}+{m^j}^2a_{ij}-\sum_{i,j}m^im^ja_{ij}\\ \frac{1}{2} \sum_{i,j} {m^i}^2a_{ij} + \frac{1}{2} \sum_{i,j} {m^j}^2a_{ij}-\sum_{i,j}m^im^ja_{ij}\\ \frac{1}{2} \sum_{i} {m^i}^2d_{ii} + \frac{1}{2} \sum_{i} {m^i}^2d_{ii}-\sum_{i,j}m^im^ja_{ij}\\ \sum_{i} {m^i}^2d_{ii}-\sum_{i,j}m^im^ja_{ij} \end {gathered} \end{equation*}

Thanks