I have $f(\boldsymbol{x}) = \boldsymbol{x}^{\boldsymbol{T}} \boldsymbol{Q} \boldsymbol{x}$, where $\boldsymbol{Q}$ is an $n \times n$ symmetric positive semidefinite matrix.
How can I show that $f(\boldsymbol{x})$ is convex on the domain $R^n$?
Attempt:
By definition of convex, for any $x,y\in\mathbb R$, we have $$f(\frac{x+y}2)\leq\frac12(f(x)+f(y))$$ Thus it is sufficient to reduce and prove that $$\frac12(x+y)^TQ(x+y)\leq x^TQx+y^TQy\\ x^TQy+y^TQx\leq x^TQx+y^TQy$$ Namely $$(x-y)^TQ(x-y)\geq0$$
At this point I am stuck on how to use positive semi-definite - assuming my logic is sound up to this point.
(a) For $\;f:\mathbb{R}\to \mathbb{R}$, $\;f(x)=x^2$ we verify that $f$ is convex. In fact, $$(\alpha x+(1-\alpha )y)^2\leq \alpha x^2+(1-\alpha)y^2 \Leftrightarrow\\ \alpha^2x^2+2\alpha (1-\alpha)xy+(1-\alpha)^2y^2-\alpha x^2-(1-\alpha)y^2\leq 0\Leftrightarrow\\(\alpha^2-\alpha)x^2+(\alpha^2-\alpha)y^2+ 2(\alpha^2-\alpha)xy\leq 0\Leftrightarrow\\ (\alpha^2-\alpha)(x+y)^2\leq 0.$$ The last inequality is verified because $\alpha^2-\alpha \leq 0$ for all $\alpha\in [0,1]$. That is, $$f(\alpha x+(1-\alpha )y)\leq \alpha f(x)+(1-\alpha)f(y)\quad \forall{x,y}\in{V},\; \forall{\alpha }\in{[0,1]}.$$ and $f$ is a convex function.
(b) For $\;f(\boldsymbol{x}) = \boldsymbol{x}^{\boldsymbol{T}} \boldsymbol{Q} \boldsymbol{x}\;$ with $\;\boldsymbol{Q}\;$ positive semidefinite, we can express $$f(\boldsymbol{x}) = \boldsymbol{x}^{\boldsymbol{T}} \boldsymbol{Q} \boldsymbol{x}=\boldsymbol{(\boldsymbol{P}x})^{\boldsymbol{T}} \boldsymbol{D} (\boldsymbol{P}\boldsymbol{x})=x_1^2+\cdots+x_r^2$$ and apply (a).