An elementary and constructive solution to Hilbert's 17th Problem for matrices

We give a short and elementary proof of a theorem of Procesi, Schacher and (independently) Gondard, Ribenboim that generalizes a famous result of Artin. Let $A$ be an $n \times n$ symmetric matrix with entries in the polynomial ring $\mathbb R[x_1,...,x_m]$. The result is that if $A$ is postive semidefinite for all substitutions $(x_1,...,x_m) \in \mathbb R^m$, then $A$ can be expressed as a sum of squares of symmetric matrices with entries in $\mathbb R(x_1,...,x_m)$. Moreover, our proof is constructive and gives explicit representations modulo the scalar case.

We shall give an elementary proof of the following theorem. Recall that a real matrix is positive semidefinite if it is symmetric with all nonnegative eigenvalues. This generalizes the following famous result of Artin on nonnegative polynomials; it is the starting point for a large body of work relating positivity and algebra.
Theorem 1 was originally proved in [3] and (within a general framework) in [7], although a formulation involving elements in a number field was already considered in [2]. Like Artin's result, it guarantees algebraic certificates to (matrix) nonnegativity. However, the known proofs are nonconstructive, employing either model theory [3] or ultraproducts [7]. In contrast, we use only basic facts about real closed fields and linear algebra to give an explicit and elegant proof of Theorem 1.
Recall that a field F is real if −1 is not a sum of squares in F , and a real closed field R is a real field such that any algebraic extension of R that is real must be equal to R. Real closed fields have a unique ordering, the nonnegative elements being the squares. For instance, R(x 1 , . . . , x m ) is a real field and R is real closed. A principal minor of a matrix is a determinant of a submatrix determined by the same row and column indices. The set of symmetric matrices over R with all principal minors nonnegative coincides with the set of positive semidefinite matrices (see for example [4, p. 405]), a fundamental relationship we exploit below. We will prove the following generalization of Theorem 1 to the setting of real fields.  To see see how Theorem 1 follows from Theorem 3, consider a principal minor p(x 1 , . . . , x m ) ∈ R[x 1 , . . . , x m ] of the matrix A. By assumption, it will be nonnegative for all substitutions (x 1 , . . . , x m ) ∈ R m , and therefore, Artin's theorem implies that it is a sum of squares of rational functions. We may now invoke Theorem 3.
As another application, consider positive semidefinite matrices A ∈ Q n×n . Standard matrix theory allows one to write A = B 2 for a symmetric B with entries that are algebraic numbers; however, Theorem 3 tells us that A is actually a sum of squares of rational matrices. This follows since any nonnegative rational number a/b = ab/b 2 can be written as a sum of four rational squares by Lagrange's theorem.
To prove Theorem 3, we begin with a lemma. For the basic theory of real closed fields (RCF) we will need, we refer the reader to [5,6]. The main observation is that a symmetric matrix A ∈ R n×n that has all nonnegative principal minors is diagonalizable over R with nonnegative eigenvalues, just as is the case for R.

Lemma 4. Suppose that A satisfies the statement of Theorem 3. Then the minimal polynomial p(t) ∈ F [t] of A is of the form:
for a i that are sums of squares of elements of F . Moreover, a 1 = 0.
Proof. Express the minimal polynomial of A as in the statement of the theorem. We first make the following observation. Let R be any real closure of F ; this induces an ordering on R, in which the principal minors of A are nonnegative (they are sums of squares). Since A is diagonalizable over R and has nonnegative eigenvalues, it follows that each a i ≥ 0 and also that p(t) has no repeated roots.
Suppose now that some a i was not a sum of squares in F . Then there is an ordering of F with a i negative. Let R be a real closure of F that extends the ordering on F . By above, a i is nonnegative, a contradiction. To verify the second claim, first notice that t 2 does not divide p(t) so that a 0 and a 1 cannot both be 0. In a real closure of F , the coefficient a 1 is a sum of products of (nonnegative) roots of p(t). It follows that if a 1 = 0, we have (−1) m a 0 = p(0) = 0. Thus, a 1 = 0.
Proof of Theorem 3. Let A be a symmetric matrix satisfying the hypotheses of the theorem. Also, let p(t) be the minimal polynomial for A, which has the form prescribed by Lemma 4. For notational simplicity, we assume that m is odd, although the argument is the same when m is even. Since p(A) = 0, it follows that Set B = A m−1 + · · · + a 1 I, which is invertible (since a 1 = 0, in any real closure of F , it is diagonalizable with strictly positive eigenvalues). Therefore, we have Since B is a sum of squares and B and B −1 commute with A, the result follows.
Notice that our argument gives a commuting sum of squares representation, the existence of which was also observed in [7]. We close with two examples to illustrate the construction from our proof.