Tutorials › Multivariate Statistics (Graduate) › Quadratic Forms and Congruence

Matrix Foundations for Inference · Tutorial 3 of 975

Quadratic Forms and Congruence

Represent and classify quadratic forms, then see why invertible changes of variables preserve their sign structure even when they change the matrix.

Beginner 11 min read

What You'll Learn

  • Express a quadratic form as a matrix expression and identify its unique symmetric matrix.
  • Explain why the skew-symmetric part of a matrix contributes nothing to a quadratic form.
  • Classify a quadratic form as positive, negative, or indefinite using its eigenvalues.
  • Compute the matrix of a quadratic form after a change of variables.
  • State and prove the invariance of inertia under invertible congruence.

Quadratic Forms and Their Matrix Representations

Quadratic expressions summarize how a vector interacts with a matrix. In multivariate statistics, they occur in expressions for distances, variances, and the curvature of objective functions. Understanding their matrix representation makes it possible to analyze their sign and to see which features survive a change of coordinates.

Definition: A quadratic form on \(\mathbb{R}^p\) is a function \(q:\mathbb{R}^p\to\mathbb{R}\) that can be written as
$$ q(x)=x^TAx, $$
where \(A\) is a real \(p\times p\) matrix and \(x\in\mathbb{R}^p\) is a column vector. The matrix \(A\) is a matrix representation of \(q\).

For example, if \(x=(x_1,x_2)^T\), then \(x^TAx\) is a scalar. Its terms involve products \(x_ix_j\), including squared terms \(x_i^2\) and cross-products such as \(x_1x_2\). The coefficient of a cross-product is split across two entries of \(A\) when \(A\) is symmetric.

Worked Example: Writing a Polynomial as a Quadratic Form

Write \(3x_1^2+4x_1x_2+2x_2^2\) as \(x^TAx\) with \(A\) symmetric, and determine its sign.

The diagonal entries give the coefficients of the squared terms. The cross-product coefficient is twice the off-diagonal entry, so

$$ A=\begin{pmatrix}3&2\\2&2\end{pmatrix}, \qquad x^TAx =3x_1^2+2x_1x_2+2x_2x_1+2x_2^2 =3x_1^2+4x_1x_2+2x_2^2. $$

Completing the square gives

$$ 3x_1^2+4x_1x_2+2x_2^2 =3\left(x_1+\frac{2}{3}x_2\right)^2+\frac{2}{3}x_2^2. $$

Both terms on the right are nonnegative, and their sum is zero only when \(x_2=0\) and then \(x_1=0\). Thus the form is positive for every nonzero \(x\): it is positive definite.

Why the Symmetric Matrix Is the Essential Representation

A quadratic form can be represented using a matrix that is not symmetric. However, only its symmetric part affects the value of the form. For any real square matrix \(A\), write its symmetric and skew-symmetric parts as \((A+A^T)/2\) and \((A-A^T)/2\), respectively. The latter contributes zero to \(x^TAx\).

Theorem: For every real square matrix \(A\) and every \(x\in\mathbb{R}^p\),
$$ x^TAx=x^T\left(\frac{A+A^T}{2}\right)x. $$
Moreover, each quadratic form has exactly one symmetric matrix representation.

To prove the identity, the scalar \(x^TAx\) equals its transpose, \(x^TA^Tx\). Adding these two equal quantities and dividing by two gives the stated formula. Thus replacing \(A\) by its symmetric part leaves the form unchanged.

For uniqueness, suppose symmetric matrices \(S\) and \(T\) satisfy \(x^TSx=x^TTx\) for every \(x\). Set \(D=S-T\), which is symmetric. Then \(x^TDx=0\) for every \(x\). Taking \(x=e_i\), the \(i\)th coordinate vector, gives \(D_{ii}=0\). For \(i\ne j\), take \(x=e_i+e_j\). Since the diagonal entries are zero and \(D\) is symmetric, \(0=x^TDx=2D_{ij}\), so \(D_{ij}=0\). Every entry of \(D\) is zero, hence \(S=T\). \(\square\)

Worked Example: Removing the Skew-Symmetric Part

Consider

$$ A=\begin{pmatrix}2&5\\-1&3\end{pmatrix}, \qquad x=\begin{pmatrix}x_1\\x_2\end{pmatrix}. $$

Direct multiplication gives

$$ x^TAx =2x_1^2+5x_1x_2-x_1x_2+3x_2^2 =2x_1^2+4x_1x_2+3x_2^2. $$

The symmetric part is

$$ \frac{A+A^T}{2} =\begin{pmatrix}2&2\\2&3\end{pmatrix}. $$

Its quadratic form is \(2x_1^2+2x_1x_2+2x_2x_1+3x_2^2\), which is exactly the expression above. In fact,

$$ 2x_1^2+4x_1x_2+3x_2^2 =2(x_1+x_2)^2+x_2^2. $$

This is positive for every nonzero \(x\), so the form is positive definite. The asymmetric entries of the original matrix did not define additional features of the quadratic form.

Classifying the Sign of a Quadratic Form

The sign of a quadratic form is assessed over all vectors, not just over the coordinate axes. A form is positive definite if \(q(x)>0\) for every nonzero \(x\), and negative definite if \(q(x)<0\) for every nonzero \(x\). It is positive semidefinite if \(q(x)\ge 0\) for all \(x\), and negative semidefinite if \(q(x)\le 0\) for all \(x\). It is indefinite if it takes both positive and negative values. The zero form is both positive and negative semidefinite, but is neither definite nor indefinite.

For a real symmetric matrix, the spectral theorem gives an orthogonal matrix \(U\) and a real diagonal matrix \(\Lambda=\operatorname{diag}(\lambda_1,\ldots,\lambda_p)\) such that \(A=U\Lambda U^T\). Since \(U^TU=I\), putting \(z=U^Tx\) gives \(q(x)=\sum_i\lambda_i z_i^2\). This expresses the sign classification in terms of the eigenvalues: all positive eigenvalues give a positive definite form; all nonnegative eigenvalues give a positive semidefinite form; all negative eigenvalues give a negative definite form; and eigenvalues of both signs give an indefinite form. Zero eigenvalues prevent definiteness but do not, by themselves, make a form indefinite.

Worked Example: A Form With Both Signs

Classify \(q(x_1,x_2)=x_1^2+2x_1x_2\). Its symmetric matrix is

$$ A=\begin{pmatrix}1&1\\1&0\end{pmatrix}. $$

The characteristic equation is

$$ \det(A-\lambda I) =(1-\lambda)(-\lambda)-1 =\lambda^2-\lambda-1=0, $$

so the eigenvalues are \((1+\sqrt{5})/2>0\) and \((1-\sqrt{5})/2<0\). The form is indefinite. This can also be checked directly: \(q(1,0)=1\), while \(q(-1,1)=-1\). The values have opposite signs, which verifies indefiniteness without relying on an eigenvalue calculation.

Congruence: Changing Coordinates in a Quadratic Form

Let \(x=Cy\), where \(C\) is a real \(p\times p\) matrix. Substitution into the quadratic form gives

Definition: The matrix \(C^TAC\) is obtained from \(A\) by congruence with \(C\). It represents the form in the \(y\)-coordinates, because
$$ q(Cy)=(Cy)^TA(Cy)=y^T(C^TAC)y. $$
If \(C\) is invertible, \(x=Cy\) is a change of coordinates covering all of \(\mathbb{R}^p\).

Congruence is not the same as similarity: similarity has the form \(C^{-1}AC\), while congruence has the form \(C^TAC\). An invertible congruence can change the eigenvalues, so eigenvalues are not generally preserved. What it does preserve for a symmetric matrix is the number of positive, zero, and negative eigenvalues, counted with multiplicity. This triple is called the inertia of the matrix.

Theorem (Sylvester’s law of inertia): If \(A\) is a real symmetric matrix and \(C\) is invertible, then \(A\) and \(C^TAC\) have the same inertia. In particular, their quadratic forms have the same sign classification.

To prove the theorem, first note that \(B=C^TAC\) is symmetric. For a symmetric matrix, the number of positive eigenvalues equals the maximum dimension of a subspace on which its quadratic form is strictly positive for every nonzero vector. Indeed, the span of the positive-eigenvalue eigenvectors is such a subspace. If the positive eigenvalue count is \(r\), any subspace of dimension greater than \(r\) contains a nonzero vector whose projection onto that positive-eigenvalue span is zero. In an orthonormal eigenbasis, that vector has only zero or negative-eigenvalue coordinates, so its quadratic-form value is nonpositive. Thus no larger strictly positive subspace exists. The corresponding argument applied to \(-A\) gives the negative eigenvalue count.

Now \(q_B(y)=q_A(Cy)\). Since \(C\) is invertible, it maps subspaces bijectively and preserves their dimensions. A subspace is strictly positive for \(q_B\) exactly when its image under \(C\) is strictly positive for \(q_A\). Therefore the maximum dimensions of positive subspaces agree; the same reasoning applies to negative subspaces. Finally, \(By=0\) holds exactly when \(ACy=0\), since \(C^T\) is invertible. The map \(y\mapsto Cy\) therefore gives a bijection between the null spaces of \(B\) and \(A\), so their nullities agree as well. These three equal counts establish equality of inertia. \(\square\)

Worked Example: Diagonalizing by Congruence

For \(A=\begin{pmatrix}1&1\\1&0\end{pmatrix}\), the form is \(q(x)=x_1^2+2x_1x_2\). Complete the square:

$$ q(x)=(x_1+x_2)^2-x_2^2. $$

Set \(x_1=y_1-y_2\) and \(x_2=y_2\), so \(x=Cy\) with

$$ C=\begin{pmatrix}1&-1\\0&1\end{pmatrix}, \qquad \det(C)=1. $$

This matrix is invertible, and substitution yields \(q(Cy)=y_1^2-y_2^2\). Direct multiplication confirms the transformed representation:

$$ C^TAC =\begin{pmatrix}1&0\\0&-1\end{pmatrix}. $$

The transformed matrix has one positive and one negative eigenvalue, as did \(A\), so both forms are indefinite. The coordinates simplify the expression, but the sign structure remains.

Why Congruence Matters—and a Common Pitfall

In applications, a change of coordinates can make a quadratic expression easier to interpret or calculate. Congruence explains which features are coordinate-dependent and which are not: the entries and eigenvalues may change, but an invertible change preserves inertia. This distinction is useful when analyzing quadratic criteria or expressions involving several variables.

For example, take \(A=\operatorname{diag}(1,4)\) and \(C=\operatorname{diag}(2,1)\). Then \(C^TAC=\operatorname{diag}(4,4)\). The eigenvalues changed from \(1,4\) to \(4,4\), while both matrices have two positive eigenvalues. It would be a mistake to claim that congruent matrices have the same eigenvalues; the invariant here is inertia, not the eigenvalue values.

  • Cross-term error: In a symmetric matrix, the entries \(A_{ij}\) and \(A_{ji}\) both contribute to \(x_ix_j\). Thus an off-diagonal entry \(c\) gives a cross-term \(2c x_ix_j\), not \(c x_ix_j\).
  • Similarity error: Replacing \(C^TAC\) by \(C^{-1}AC\) uses the wrong transformation for a quadratic form. Substitution \(x=Cy\) directly gives \(C^TAC\).
  • Sign error: Checking only a few vectors cannot establish that a form is nonnegative everywhere. A single positive and a single negative value do establish that it is indefinite.
  • Invertibility error: Inertia is preserved by invertible congruence. If \(C\) is singular, the substitution covers only a lower-dimensional set, and the theorem does not apply.
Key takeaway: A quadratic form has a unique symmetric matrix representation. Under \(x=Cy\), its matrix becomes \(C^TAC\); when \(C\) is invertible, the numbers of positive, zero, and negative directions are unchanged.

Check Your Understanding

Use the definitions and transformations developed above to answer these questions.

  1. Write \(5x_1^2-6x_1x_2+2x_2^2\) as \(x^TAx\) with \(A\) symmetric. What is the off-diagonal entry?
  2. Why does the skew-symmetric part of a real matrix contribute zero to \(x^TAx\)?
  3. What can the eigenvalue signs of a symmetric matrix tell you about the sign of its quadratic form?
  4. If \(x=Cy\), derive the matrix representing the form in the \(y\)-coordinates.
  5. Which feature is guaranteed to be preserved by invertible congruence: the eigenvalues themselves or the inertia? Explain.
Clinical Biostats