# Show that $X^T X = \sum_{i=1}^n \mathbf{x}_i \mathbf{x}_i^T$

Referring to this post: https://stats.stackexchange.com/questions/164223/proof-of-loocv-formula

The line which says $$\sum_{t=1}^TX_t'X_t=X'X$$ is the result I'm trying to interpret.

Or in perhaps more standard notation:

Question. Prove that $$X^{T} X = \sum_{i=1}^{n} \mathbf{x}_i \mathbf{x}_i^T$$ where $$\mathbf{x}_i$$ is the $$i^{th}$$ row of a matrix $$X$$ (as a column vector).

If someone could please explain why this is true, it would be very helpful. I'm not quite sure how I would come up with this "decomposition" of $$X^T X$$.

• I believe you can prove the entries of both sides are equal by using the matrix multiplication formula. – WeakestTopology Nov 19 '19 at 11:55
• If $x_i$ is a row vector, $x_i x_i^+$ is a scalar and the identity does not make much sense. Are you sure that $x_i$ is a row vector or that the transpose operations are well reported ? – Thomas Nov 19 '19 at 12:02
• @Thomas Yes you're correct, thanks for the comment, clarified in edit – user523384 Nov 19 '19 at 12:04

With implicit summation over indices,$$(X^TX)_{jk}=X^T_{ji}X_{ik}=(x_i)_j(x_i)_k=(x_ix_i^T)_{jk}.$$