Suppose I have a matrix $f = \begin{bmatrix}x_1 & x_2 \\ 1 & 0\end{bmatrix}$. I would like to compute $\frac{dx'fx}{dx}$ with $x = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix}$.
One way is to first compute $x'fx = x_1^3+x_1x_2+x_1x_2^2$, then differentiate it: $\frac{dx'fx}{dx} = \begin{bmatrix}3x_1^2+x_2+x_2^2 \\ x_1+2x_1x_2\end{bmatrix}$.
The other way is to rewrite $\frac{dx'fx}{dx} = fx + vec\{x'f_xx\}$ using product rule. Here vec is a operator to stack the scalar. Then I have to compute $f_x$. This is where I stuck.
There are two issues here, note that $f_x$ is a matrix to vector derivative, hence we get a tensor with each element a 2 by 2 matrix. The order matters how this tensor is formed, i.e. each element could be $\frac{df}{dx_i}$ or $\frac{df_i}{dx}$, which should I choose for my purpose?
Through some computations, I note that none of them leads to the correct answer simply becasue $fx = \begin{bmatrix}x_1^2+x_2^2 \\ x_1\end{bmatrix}$, so $x_2$ in the first row can never be achieved by $vec\{x'f_xx\}$.
Can anyone please tell me what I am wrong here? Thanks in advance.