Given the function $f(\vec{x})=(\frac{1}{2})\vec{x}^TP^TP\vec{x}+q^T\vec{x}+r$, where $\vec{x}$ and $q \in \mathbb{R}^n$, and $P \in \mathbb{R}^{n x n}$ is full rank and $r \in \mathbb{R}$, I am trying to find the gradient, Hessian, and what the minimum of this function is.
For the sake of simplicity, I am going to say $n=2$ and define the following as:
$\vec{x}= \begin{bmatrix} x_1\\ x_2 \end{bmatrix}$
$ P = \begin{bmatrix} p_{11} & p_{12}\\ p_{21} & p_{22} \end{bmatrix}$
$\vec{q}= \begin{bmatrix} q_1\\ q_2 \end{bmatrix}$
This is what I computed for the gradient:
$\frac{\partial f(\vec{x})}{\partial x_1} = x_1p^2_{11} + x_1p^2_{21} + x_2p_{11}p_{12} + x_2p_{21}p_{22} + q_1$
$\frac{\partial f(\vec{x})}{\partial x_2} = x_1p_{11}p_{12} + x_1p_{21}p_{22} + x_2p^2_{12} + x_2p^2_{22} + q_2$
For the Hessian, I got the following: $\begin{bmatrix} p^2_{11} + p^2_{21} & p_{11}p_{12} + p_{21}p_{22}\\ p_{11}p_{12} + p_{21}p_{22} & p^2_{11} + p^2_{21} \end{bmatrix}$
Are my computations of the gradient and Hessian correct? From here, how do I find the minimum of this function?
What is is interesting is at least sufficient condition to have that extremum:
If $a$ is a critical point
$f$ has a strict minimum in $a$ if $H(f)(a)$ is defined positive (resp. defined negative for a maximum)
Recalling that defined positive is that
$$ \forall x \in R^2, x \neq \vec{0, }\, x^tH(f)(a)x>0 $$
Begin by determining the critical point (annulation of gradient is necessary)