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

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

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

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

which says, that the Hessian matrix of $\displaystyle F$ is the matrix

$\displaystyle \nabla^2F(x):=2Qxx^TQ+x^TQxQ+A$.

First of all, I'm not sure if I should believe this, because if the product $\displaystyle 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 $\displaystyle xQ$, where the dimensions don't match.
On the other side, if I first compute $\displaystyle x^TQx$, I'll get a real number and then I can just multiply matrix $\displaystyle 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 $\displaystyle F$ in the form $\displaystyle \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 $\displaystyle \nabla F$? Or it's not a good way?

Thanks for any answers