TITLE: Matrix $A^T A$ as sum of outer products
QUESTION [14 upvotes]: I have recently read in a script about statistical methods in a chapter about linear regression that:

Given an $n \times k$-matrix $A$, we have
$$A^T A = \sum_{i=1}^{n} a_i^T a_i$$
where $a_i$ denotes the $i$-th row of $A$.

Unfortunately, the author doesn't give a proof of that and I can't figure out one myself. Maybe someone can help me.
source: script on page 10

REPLY [17 votes]: Hint:
$$A = 
\left[\begin{array}{ll} a_1\\0\\ 0\\ \vdots\\0 \end{array}\right] + 
\left[\begin{array}{ll} 0\\a_2\\ 0\\ \vdots\\0 \end{array}\right] + \dots +
\left[\begin{array}{ll} 0\\0\\ 0\\ \vdots\\a_n \end{array}\right]
$$
$$
A^TA = A^T\left[\begin{array}{ll} a_1\\0\\ 0\\ \vdots\\0 \end{array}\right] + 
A^T\left[\begin{array}{ll} 0\\a_2\\ 0\\ \vdots\\0 \end{array}\right] + \dots +
A^T\left[\begin{array}{ll} 0\\0\\ 0\\ \vdots\\a_n \end{array}\right]
$$