Hi there, I've got a problem with this one:

In a book I found the formula for computing hessian of biquadratic function

 (x_1,\dots,x_n)^T=:x\mapsto F(x):=\frac{1}{4}(x^TQx)^2+\frac{1}{2}x^TAx+b^Tx,

(where A,Q are n\times n real symmetric matrices, and b\in\mathbb{R}^n is constant column vector),

which says, that the Hessian matrix of F is the matrix


First of all, I'm not sure if I should believe this, because if the product x^TQxQ exists, then it should be computable in more ways then directly
begin the multiplication on the left side and end on the right side (associative multiplication for matrices), so I should be able to start with
computing xQ, where the dimensions don't match.
On the other side, if I first compute x^TQx, I'll get a real number and then I can just multiply matrix Q by this number, and I'll get a result which fits the dimensions of other matrices. So could that formula be correct? I really don't know what to think about it.

I was also trying to compute it myself to make sure that formula is right, but I was not sure how to do it exactly.
I computed gradient of the function F in the form \nabla F(x)=Qxx^TQx+Ax+b , it looks to be right.
Now, do I get Hessian matrix of F by computing the Jakobi matrix of first partial derivatives of \nabla F? Or it's not a good way?

Thanks for any answers