Positive semidefinite cone (source code)

= Positive semidefinite cone
{title2=$\mathbb S_+^n$}

The <positive semidefinite cone> in the real vector space of <symmetric matrices> is
$$
\mathbb S_+^n=\{X=X^T:v^TXv\ge0\text{ for every }v\in\mathbb R^n\}.
$$
Equivalently, every <eigenvalue> is nonnegative. Nonnegative combinations preserve each quadratic-form inequality, proving convexity and the cone property. For each fixed $v$ the test $X\mapsto v^TXv$ is continuous, so their intersection is closed.<Convex Optimization by Stephen Boyd and Lieven Vandenberghe>[§2.2.5, positive semidefinite cone]{ref}

Positive semidefiniteness is different from entrywise nonnegativity. The matrix
$$
\begin{pmatrix}1&-1\\-1&1\end{pmatrix}
$$
is positive semidefinite because its <quadratic form> is $(v_1-v_2)^2$, despite its negative off-diagonal entries. Conversely, the entrywise positive matrix with diagonal one and off-diagonal two is indefinite: its <quadratic form> at $(1,-1)$ is negative.

For a $2$-by-$2$ <symmetric matrix> $X=\begin{pmatrix}a&b\\b&c\end{pmatrix}$, the condition is $a,c\ge0$ and $ac\ge b^2$. This is equivalent to
$$
\sqrt{((a-c)/2)^2+b^2}\le(a+c)/2,
$$
a <second-order cone> condition. Larger matrix constraints are central to <semidefinite programming>. The cone is a <self-dual cone> under the <Frobenius inner product>, while the <copositive cone> only tests nonnegative vectors.