Under which conditions is $f(x)=\frac{1}{2}x^TPx+q^Tx+r$ convex?

84 Views Asked by At

I am given the function $$f(x)=\frac{1}{2}x^TPx+q^Tx+r$$ and am asked to establish under which conditions $f(x)$ is a convex function.

I have to use the definition of a convex function where we look at the second order derivative, i.e.

A twice differentiable function $f: \mathbb{R}^n \rightarrow \mathbb{R}$ is convex if $\operatorname{dom}(f)$ is a convex set and if $$\nabla^2 f(x) \geqslant 0 $$ for all $x \in\operatorname{ dom}(f)$.

My approach was to find the second derivative:

$$\nabla^2 f(x) = \dfrac{1}{2}\left(P+P^T\right).$$

So as long as $P+P^T \geqslant 0$, $f(x)$ is a convex function or am I missing something?