I am learning PCA and I encounter this formula transformation in the derivation
$\sum_{i=1}^{n}(w^Tx_i)^2=w^T(\sum_{i=1}^{n}x_ix_i^T)w$
If I concretize $i$ with 3 and assume $x \in R^{3x1}$ and $w \in R^{3x1}$...then I can expand this formula and see their equivalences. But with shaky background in linear algebra, I can' really derive this formula myself. How can I learn to handle vector/matrix calculation in such forms in general? I know this last question might be too big, but I would like to know whether I just need more practice or there is some systematic method that I don't know.
I'd say: Get familiar with the formalism of vector and matrix manipulations, but not tied to a particular space dimension (3 in your example), or a particular coordinate system.
For instance, the identity you presented stems from simple manipulations:
$$ \begin{split}\sum_{i=1}^{n}(w^Tx_i)^2 &= \sum_{i=1}^{n}(w^Tx_i)(w^Tx_i)\\ &=\sum_{i=1}^{n}(w^Tx_i)(w^Tx_i)^T&\quad\text{(because }w^Tx_i\text{is just a number)}\\ &=\sum_{i=1}^{n}(w^Tx_i)(x_i^Tw)&\\ &=\sum_{i=1}^{n}w^T(x_ix_i^T)w&\quad\text{(associative property)}\\ &=w^T\left(\sum_{i=1}^{n}x_ix_i^T\right)w&\quad\text{(distributive property)} \end{split}$$
Note that not once have I relied on computing the particular component of a vector or product. I haven't relied on a particular dimension of the space. It's all a certain formalism that you need to get used to. And for that, you need practice.