A quadratic expression such as two squares plus a mixed term may look very different from a sum of squares. A symmetric matrix reveals when it can be rewritten as one, and its eigenvalues show how: rotate the axes, and the mixed term disappears.
1. From a quadratic expression to a matrix
Consider the quadratic form
The mixed term comes from the two symmetric off-diagonal entries:
More generally, for a real symmetric matrix A and a column vector x, a quadratic form is Q(\mathbf{x})=\mathbf{x}^{T}A\mathbf{x}. Every real quadratic form has a unique symmetric coefficient matrix.
2. A first sum-of-squares example
Complete the square:
Thus
In fact, the sum vanishes only at (x,y)=(0,0). We call such a quadratic form positive definite.
3. Positive definite versus positive semidefinite
A symmetric matrix A is positive semidefinite if \mathbf{x}^TA\mathbf{x}\ge0 for every vector \mathbf{x}. It is positive definite if the inequality is strict for every nonzero vector.
For example, (x+y)^2 is positive semidefinite but not positive definite: it vanishes on the entire line y=-x. In contrast, x^2+y^2 is positive definite.
4. Why eigenvalues give the answer
The spectral theorem states that every real symmetric matrix can be diagonalized by an orthogonal matrix:
Set \mathbf{z}=U^T\mathbf{x}. Then
If all eigenvalues are nonnegative, each term is a square of a linear form:
Here \mathbf{u}_i is a unit eigenvector of A. This proves an important theorem:
Theorem. A real quadratic form is a sum of squares of real linear forms if and only if its symmetric matrix is positive semidefinite. It is positive definite if and only if all its eigenvalues are strictly positive.
Why the converse holds: if Q(\mathbf{x})=\sum_j\ell_j(\mathbf{x})^2, every term is nonnegative, so Q(\mathbf{x})\ge0.
5. A complete two-variable eigenvalue example
Take the matrix
Its eigenvalues are 3 and 1, with orthonormal eigenvectors (1,1)/\sqrt2 and (1,-1)/\sqrt2. Therefore
Expanding the right side recovers 2x^2+2xy+2y^2. The positive eigenvalues also prove that Q(x,y)>0 whenever (x,y)\ne(0,0).
Geometrically, the eigenvectors are the axes of the ellipses Q(x,y)=1. In the rotated coordinates z_1=(x+y)/\sqrt2, z_2=(x-y)/\sqrt2, the form becomes 3z_1^2+z_2^2: no mixed term, and the eigenvalues tell how steeply Q grows along each axis.
6. Do we always need eigenvalues?
No. Completing the square already gave (2x+y)^2+x^2+y^2 for our first example, and Cholesky factorization turns that idea into an algorithm that works for any positive definite matrix. Eigenvalues give the most geometric picture; Cholesky and Sylvester’s criterion give the fastest tests. For those methods, see Is a Quadratic Form Positive? Sylvester’s Criterion, Cholesky and Sums of Squares.
7. What if an eigenvalue is negative?
Consider Q(x,y)=x^2-y^2. Its matrix has eigenvalues 1 and -1. Setting x=0,y=1 gives Q=-1, which cannot equal a sum of real squares. The obstruction is not a lack of clever algebra: a negative eigenvalue makes a real sum-of-squares representation impossible.
8. Why this matters
Quadratic forms appear in least-squares fitting, optimization, geometry, and energy models. The matrix viewpoint lets us test nonnegativity systematically rather than guessing how to complete squares. For a twice-differentiable function, a positive definite Hessian at a critical point gives a strict local minimum; a positive semidefinite Hessian alone does not settle the question.
Try it yourself
Exercise 1. Write 3x^2+2xy+3y^2 as a matrix quadratic form.
Solution. A=\begin{pmatrix}3&1\\1&3\end{pmatrix}. The off-diagonal entries each contribute xy.
Exercise 2. Express 3x^2+2xy+3y^2 as two squares using eigenvalues.
Solution. The eigenvalues are 4 and 2. Hence Q=2(x+y)^2+(x-y)^2.
Exercise 3. Is x^2+2xy+y^2 positive definite?
Solution. No. It equals (x+y)^2, so it is positive semidefinite and vanishes at nonzero points such as (1,-1).
Exercise 4. Can x^2+4xy+y^2 be a sum of real squares of linear forms?
Solution. No. At (x,y)=(1,-1), the value is -2. Equivalently, its matrix has eigenvalues 3 and -1.
Challenge. Prove that a positive semidefinite matrix of rank r can be represented using exactly r squares, and that fewer are impossible.
Solution. The spectral representation has exactly r positive eigenvalues and therefore r squares. If A=B^TB comes from s linear forms, then \operatorname{rank}(A)=\operatorname{rank}(B)\le s. Thus s\ge r.
Connections and further reading
For quick tests of positive definiteness without computing eigenvalues (completing the square, Sylvester’s criterion and Cholesky factorization), see Is a Quadratic Form Positive? Sylvester’s Criterion, Cholesky and Sums of Squares.
This matrix method complements our discussion of When Is a Polynomial a Sum of Squares?. For quadratic forms, nonnegativity is equivalent to being a sum of squares of linear forms; for higher-degree multivariable polynomials, the situation is more subtle.
For arithmetic identities, see How Euler’s Four-Square Identity Generates New Sums of Four Squares. Browse related posts in the Sums of Squares collection.
Historical reading: Olga Taussky, “Sums of Squares,” The American Mathematical Monthly 77 (1970), 805–830. JSTOR. This article is an independently written introduction, not a reproduction of the survey.

Leave a Reply