I have the following multi-variable function: $\ h(x)=(x^Tx)^2=||x||^4$ where $x=[x_1 ... x_n]^T$. I am trying to find the Hessian matrix. First I find the gradient vector $g(x)=2(x_{1}^2+...+x_{n}^2)2x_1=(4x^Tx)x$. I am pretty confident in this part. Then I need to take the derivative again to get the Hessian so I do it piece meal and get $\frac{d^2h}{dx_1^2}=4(3x_{1}^2+x_{2}^2+...+x_{n}^2)$ which will be along the diagonals changing the position of the factor of 3 respectively and I get $\frac{d^2h}{dx_jdx_i}=8x_ix_j$ for all $i \neq j$.
My issue now is how to write this thing as a vector valued function like I did for the gradient which just happened to work out easier.