# Finding the interval of values of an unknown element such that a square matrix is positive semidefinite

I'm looking for a way to determine which values of $$c \in \mathbb{R}$$ make the matrix $$A$$ positive semidefinite:

$$A = \begin{bmatrix} 1 & c \\ c & 1 \end{bmatrix}$$

I'm looking for a way to determine which values of c∈R make the matrix A positive semidefinite:

By definition, A matrix is called positive semidefinite if it is symmetric and all its eigenvalues are non-negative. Hence

Clear["Global*"]
mat = {{1, c}, {c, 1}}
If[SymmetricMatrixQ[mat],
eigv = Eigenvalues[mat];
Reduce[eigv[[1]] >=  0 && eigv[[2]] >= 0, c]
]


So any value between -1 and 1 will do. The above code ofcourse assumes the matrix is 2 by 2, but it can easily be made more general.

• Congrats on 100K. Dec 6 '21 at 15:53

cp = CharacteristicPolynomial[{{1, c}, {c, 1}}, t]

(* Out[142]= 1 - c^2 - 2 t + t^2 *)


There are two important things to check. (i) Where do roots cross the y axis? (ii) Where might roots be complex-valued?

For (i) we just solve for c under the assumption thatt==0

Solve[cp == 0 && t == 0, {c, t}]

(* Out[143]= {{c -> -1, t -> 0}, {c -> 1, t -> 0}} *)


This splits the real line for c into three regions abd simply plugging in a value in each region will show that both solutions are nonnegative in the finite part.

For (ii) We check where the discriminant with respect to t vanishes. This will give conditions on c.

Discriminant[cp, t]

(* Out[144]= 4 c^2 *)


So it only vanishes at the origin. We already know that on neither side do we have complex valued roots in t. So there are no further restrictions.

An advantage to this approach is that it extends to higher dimensions.

If you compute the Cholesky decomposition of the matrix, and simplify it under the assumptions you gave:

Simplify[CholeskyDecomposition[{{1, c}, {c, 1}}], c ∈ Reals]
{{1, c}, {0, Sqrt[1 - c^2]}}


you can immediately read off the condition that Sqrt[1 - c^2] >= 0 for positive-semidefiniteness. Thus,

Reduce[%[[-1, -1]] >= 0, c, Reals]
-1 <= c <= 1
`