How to express matrix multiplication as the sum of individual elements? I want to express $$\sum_{i=1}^N \sum_{j=1}^N a_{ij} x_i x_j$$ as matrix/vector multiplication. I've managed to get that the expression above is equal to $$x'Ax$$ where x is a vector, by expanding the sum but it took a while. Is there a faster way, which I can use to calculate it (and also be able to express matrix multiplication as a sum)?

Yes, it depends upon what value of $a_{ij}$ and $x$ you are choosing. Relate your question with this example. Suppose $x_i  = 1$ and $x_j = 1$ for every value of $i$ and $j$ and $$a_{ij} = \frac{a_i a_j }{i+j+1}$$ where $1\le i,j\le N$ and $a_i, a_j \in \Bbb N$ then  $$\sum_{i=1}^N \sum_{j=1}^N a_{ij} x_i x_j = \sum_{i=1}^N \sum_{j=1}^N \frac{a_i a_j }{i+j+1} = \int _{0}^ 1 f(x) f(x) $$ where $f(x) = a_1x + a_2 x^2 +\cdots a_n x^N $.  You can relate $x' A x$ to standard inner product of $ Ax $ and $ x $ in real space.
