[Math] Derivative – Convert summation to matrix

matricesmatrix-calculus

Hello I am trying to compute the derivative of the equation

$f = x^TAx $

I can rewrite it to

$f = \sum_{i,j} A_{ij}x_ix_j $

Then find its derivative

$\frac{df}{dx_k} = \sum_j A_{kj}x_j + \sum_i A_{ik}x_i $

How do I rewrite this in matrix form ?

Best Answer

In index notation, you can write $$\frac{\partial f}{\partial x_k}=A_{kj}x_j + A_{ik}x_i$$ where a summation is implied by the presence of a repeated index.

You can also change a summation index (aka a dummy index), without altering the result, e.g. $(x_iy_i = x_ky_k)$.

So let's change both dummy indices to $p$ yielding $$\eqalign{ \frac{\partial f}{\partial x_k} &= A_{kp}x_p + A_{pk}x_p \cr &= (A_{kp}+A_{pk})\,x_p \cr }$$ which in matrix notation would be written as $\,(A+A^T)\,x$

Related Question