Tutorials › Linear Algebra › Changing Variables by Congruence

Quadratic Forms and Definiteness · Tutorial 759 of 1000

Changing Variables by Congruence

Learn to transform a quadratic form under an invertible change of variables and verify the resulting congruent matrix.

Advanced 10 min read

What You'll Learn

  • Derive the matrix formula for substituting one set of variables for another
  • Distinguish a general substitution from an invertible change of variables
  • Compute the transformed matrix using exact matrix products
  • Check a transformed form by direct substitution
  • Explain why congruent matrices describe the same quadratic form in different coordinates
  • Avoid confusing congruence with a reversed transpose order or similarity

What Changes When the Variables Change?

A quadratic form assigns a scalar to each vector. Its matrix depends on the coordinates used to describe that vector: the same input can be written using one coordinate vector \(\mathbf{x}\), or using another coordinate vector \(\mathbf{y}\) related by a linear substitution. The value of the form does not change when we describe the input in new coordinates, but the matrix that computes the value generally does.

Throughout, the scalar field is \(\mathbb{R}\). Let \(\mathbf{A}\in\mathbb{R}^{n\times n}\) be symmetric, and write the quadratic form as \(q(\mathbf{x})=\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\). A change of variables has the form \(\mathbf{x}=\mathbf{P}\mathbf{y}\), where \(\mathbf{P}\in\mathbb{R}^{n\times n}\). If \(\mathbf{P}\) is invertible, each old coordinate vector \(\mathbf{x}\) corresponds to exactly one new coordinate vector \(\mathbf{y}\), and conversely. This invertibility condition is what makes the substitution a genuine change of coordinates rather than a map that may lose information.

Definition: If \(\mathbf{A}\in\mathbb{R}^{n\times n}\) is symmetric and \(\mathbf{P}\in\mathbb{R}^{n\times n}\) is invertible, the matrix \(\mathbf{B}=\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\) is the matrix of the quadratic form after the change of variables \(\mathbf{x}=\mathbf{P}\mathbf{y}\). The matrices \(\mathbf{A}\) and \(\mathbf{B}\) are called congruent.

The order of the factors records how the substitution acts. The vector \(\mathbf{y}\) is first sent to \(\mathbf{x}=\mathbf{P}\mathbf{y}\); the original form then evaluates \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\). Substituting this expression gives

$$ q(\mathbf{x}) =(\mathbf{P}\mathbf{y})^{\top}\mathbf{A}(\mathbf{P}\mathbf{y}) =\mathbf{y}^{\top}\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\mathbf{y}. $$

Here we used \((\mathbf{P}\mathbf{y})^{\top}=\mathbf{y}^{\top}\mathbf{P}^{\top}\), followed by associativity of matrix multiplication. Thus the new matrix is \(\mathbf{B}=\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\), not a matrix obtained by putting the transpose on the other side.

Why the Transformed Matrix Is Still Symmetric

A quadratic form is represented here by a symmetric matrix. The congruence formula respects that symmetry. Indeed, transposing a product reverses the factor order, and \(\mathbf{A}^{\top}=\mathbf{A}\), so

$$ (\mathbf{P}^{\top}\mathbf{A}\mathbf{P})^{\top} =\mathbf{P}^{\top}\mathbf{A}^{\top}\mathbf{P} =\mathbf{P}^{\top}\mathbf{A}\mathbf{P}. $$

This also gives a useful computational check: if the starting matrix is symmetric, the transformed matrix must be symmetric. A nonsymmetric result signals an error in the multiplication or transpose.

Theorem: Congruence by invertible real matrices is an equivalence relation on real symmetric matrices: every symmetric matrix is congruent to itself; if \(\mathbf{B}\) is congruent to \(\mathbf{A}\), then \(\mathbf{A}\) is congruent to \(\mathbf{B}\); and if \(\mathbf{B}\) is congruent to \(\mathbf{A}\) and \(\mathbf{C}\) is congruent to \(\mathbf{B}\), then \(\mathbf{C}\) is congruent to \(\mathbf{A}\).

Proof. For reflexivity, take \(\mathbf{P}=\mathbf{I}_n\). Then \(\mathbf{I}_n^{\top}\mathbf{A}\mathbf{I}_n=\mathbf{A}\). For symmetry, suppose \(\mathbf{B}=\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\) with \(\mathbf{P}\) invertible. Multiplying by \((\mathbf{P}^{-1})^{\top}\) on the left and by \(\mathbf{P}^{-1}\) on the right gives \(\mathbf{A}=(\mathbf{P}^{-1})^{\top}\mathbf{B}\mathbf{P}^{-1}\); since \(\mathbf{P}^{-1}\) is invertible, this exhibits \(\mathbf{A}\) as congruent to \(\mathbf{B}\). For transitivity, suppose \(\mathbf{B}=\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\) and \(\mathbf{C}=\mathbf{Q}^{\top}\mathbf{B}\mathbf{Q}\), with \(\mathbf{P}\) and \(\mathbf{Q}\) invertible. Substitution gives \(\mathbf{C}=\mathbf{Q}^{\top}\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\mathbf{Q}=(\mathbf{P}\mathbf{Q})^{\top}\mathbf{A}(\mathbf{P}\mathbf{Q})\). The product \(\mathbf{P}\mathbf{Q}\) is invertible, with inverse \(\mathbf{Q}^{-1}\mathbf{P}^{-1}\), so \(\mathbf{C}\) is congruent to \(\mathbf{A}\). \(\square\)

Computing the Congruent Matrix

For a practical calculation, first write the substitution explicitly as \(\mathbf{x}=\mathbf{P}\mathbf{y}\). Then calculate \(\mathbf{A}\mathbf{P}\), followed by \(\mathbf{P}^{\top}(\mathbf{A}\mathbf{P})\). Keeping the intermediate product visible helps prevent a common order error. Finally, compare the resulting quadratic expression with the original form after directly substituting for \(\mathbf{x}\).

Worked Example: A Shear in Two Variables

Let \(q(\mathbf{x})=2x_1^2+2x_1x_2+3x_2^2\), and use the substitution \(x_1=y_1+y_2,\;x_2=y_2\). Find the new matrix and check the transformed form.

The symmetric matrix of the original form is \(\mathbf{A}=\begin{bmatrix}2&1\\1&3\end{bmatrix}\). The substitution is \(\mathbf{x}=\mathbf{P}\mathbf{y}\), where \(\mathbf{P}=\begin{bmatrix}1&1\\0&1\end{bmatrix}\). Its determinant is not needed to multiply the matrices; its inverse \(\begin{bmatrix}1&-1\\0&1\end{bmatrix}\) confirms that the substitution is invertible.

$$ \mathbf{A}\mathbf{P} = \begin{bmatrix}2&1\\1&3\end{bmatrix} \begin{bmatrix}1&1\\0&1\end{bmatrix} = \begin{bmatrix}2&3\\1&4\end{bmatrix}. $$

Since \(\mathbf{P}^{\top}=\begin{bmatrix}1&0\\1&1\end{bmatrix}\), the transformed matrix is

$$ \mathbf{B} =\mathbf{P}^{\top}\mathbf{A}\mathbf{P} = \begin{bmatrix}1&0\\1&1\end{bmatrix} \begin{bmatrix}2&3\\1&4\end{bmatrix} = \begin{bmatrix}2&3\\3&7\end{bmatrix}. $$

Thus the new form is \(2y_1^2+6y_1y_2+7y_2^2\). Direct substitution checks the result: \(2(y_1+y_2)^2+2(y_1+y_2)y_2+3y_2^2=2y_1^2+6y_1y_2+7y_2^2\). For an additional numerical check, choose \(\mathbf{y}=\begin{bmatrix}1\\-1\end{bmatrix}\), so \(\mathbf{x}=\begin{bmatrix}0\\-1\end{bmatrix}\). The original form gives \(3\), and the transformed form gives \(2-6+7=3\).

The off-diagonal entries of a symmetric matrix contribute twice in its quadratic form: \(b_{12}y_1y_2+b_{21}y_2y_1=2b_{12}y_1y_2\). This is why the coefficient \(6\) on \(y_1y_2\) corresponds to entries \(3\) in positions \((1,2)\) and \((2,1)\) of \(\mathbf{B}\).

Worked Example: Scaling and Mixing Coordinates

Take \(q(\mathbf{x})=x_1^2+4x_1x_2+5x_2^2\), and substitute \(x_1=y_1,\;x_2=y_1+2y_2\). Compute the congruent matrix and verify it at a particular vector.

The matrix and substitution matrix are \(\mathbf{A}=\begin{bmatrix}1&2\\2&5\end{bmatrix}\) and \(\mathbf{P}=\begin{bmatrix}1&0\\1&2\end{bmatrix}\). The inverse substitution is \(y_1=x_1,\;y_2=(x_2-x_1)/2\), so this is an invertible change of variables. Multiply in the prescribed order:

$$ \mathbf{A}\mathbf{P} = \begin{bmatrix}1&2\\2&5\end{bmatrix} \begin{bmatrix}1&0\\1&2\end{bmatrix} = \begin{bmatrix}3&4\\7&10\end{bmatrix}, $$
$$ \mathbf{B} =\mathbf{P}^{\top}\mathbf{A}\mathbf{P} = \begin{bmatrix}1&1\\0&2\end{bmatrix} \begin{bmatrix}3&4\\7&10\end{bmatrix} = \begin{bmatrix}10&14\\14&20\end{bmatrix}. $$

The new form is \(10y_1^2+28y_1y_2+20y_2^2\). Substituting into the original expression gives \(y_1^2+4y_1(y_1+2y_2)+5(y_1+2y_2)^2=10y_1^2+28y_1y_2+20y_2^2\). For \(\mathbf{y}=\begin{bmatrix}1\\-1\end{bmatrix}\), we have \(\mathbf{x}=\begin{bmatrix}1\\-1\end{bmatrix}\); the original value is \(1-4+5=2\), while the new value is \(10-28+20=2\).

Invertibility and What the Change Preserves

The algebraic identity \(q(\mathbf{P}\mathbf{y})=\mathbf{y}^{\top}\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\mathbf{y}\) holds for any matrix \(\mathbf{P}\) of the appropriate size. But if \(\mathbf{P}\) is not invertible, some \(\mathbf{x}\) may not be expressible as \(\mathbf{P}\mathbf{y}\), and different \(\mathbf{y}\) values may give the same \(\mathbf{x}\). In that case it is a substitution, but not a change of coordinates covering the whole original space.

For an invertible \(\mathbf{P}\), every vector \(\mathbf{x}\in\mathbb{R}^n\) has the unique corresponding vector \(\mathbf{y}=\mathbf{P}^{-1}\mathbf{x}\). Consequently the set of values taken by the quadratic form is unchanged: evaluating the original form over all \(\mathbf{x}\) gives the same possible real numbers as evaluating the transformed form over all \(\mathbf{y}\). In particular, any statement that concerns only whether the form is positive, negative, or zero at every vector transfers between the two coordinate systems.

Theorem: Let \(\mathbf{A}\) be a real symmetric matrix and let \(\mathbf{P}\) be an invertible real matrix. The original and transformed forms take exactly the same set of values as their inputs range over \(\mathbb{R}^n\). In particular, \(q(\mathbf{x})\geq 0\) for every \(\mathbf{x}\in\mathbb{R}^n\) if and only if \(\mathbf{y}^{\top}\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\mathbf{y}\geq 0\) for every \(\mathbf{y}\in\mathbb{R}^n\).

Proof. For every \(\mathbf{y}\), the transformation identity gives \(\mathbf{y}^{\top}\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\mathbf{y}=q(\mathbf{P}\mathbf{y})\), so every value of the transformed form is a value of the original form. Conversely, for any \(\mathbf{x}\), invertibility gives \(\mathbf{y}=\mathbf{P}^{-1}\mathbf{x}\), and then \(\mathbf{P}\mathbf{y}=\mathbf{x}\). Therefore \(q(\mathbf{x})\) is a value of the transformed form as well. The two sets of values are equal. If the original form is nonnegative for every \(\mathbf{x}\), the identity makes the transformed form nonnegative for every \(\mathbf{y}\). If the transformed form is nonnegative for every \(\mathbf{y}\), use \(\mathbf{y}=\mathbf{P}^{-1}\mathbf{x}\) for each \(\mathbf{x}\) to conclude \(q(\mathbf{x})\geq0\). \(\square\)

Worked Example: A Three-Variable Triangular Change

Let \(q(\mathbf{x})=x_1^2+2x_2^2+3x_3^2\), and set \(x_1=y_1+y_2,\;x_2=y_2+y_3,\;x_3=y_3\). Find the transformed matrix and check the result.

Here \(\mathbf{A}=\begin{bmatrix}1&0&0\\0&2&0\\0&0&3\end{bmatrix}\) and \(\mathbf{P}=\begin{bmatrix}1&1&0\\0&1&1\\0&0&1\end{bmatrix}\). This substitution is invertible: \(y_3=x_3,\;y_2=x_2-x_3,\;y_1=x_1-x_2+x_3\). First multiply:

$$ \mathbf{A}\mathbf{P} = \begin{bmatrix}1&0&0\\0&2&0\\0&0&3\end{bmatrix} \begin{bmatrix}1&1&0\\0&1&1\\0&0&1\end{bmatrix} = \begin{bmatrix}1&1&0\\0&2&2\\0&0&3\end{bmatrix}. $$

Now use \(\mathbf{P}^{\top}=\begin{bmatrix}1&0&0\\1&1&0\\0&1&1\end{bmatrix}\):

$$ \mathbf{B} =\mathbf{P}^{\top}\mathbf{A}\mathbf{P} = \begin{bmatrix}1&0&0\\1&1&0\\0&1&1\end{bmatrix} \begin{bmatrix}1&1&0\\0&2&2\\0&0&3\end{bmatrix} = \begin{bmatrix}1&1&0\\1&3&2\\0&2&5\end{bmatrix}. $$

The transformed expression is \(y_1^2+2y_1y_2+3y_2^2+4y_2y_3+5y_3^2\). Direct substitution gives \((y_1+y_2)^2+2(y_2+y_3)^2+3y_3^2\), which expands to precisely that expression. For \(\mathbf{y}=\begin{bmatrix}1\\0\\-1\end{bmatrix}\), the corresponding \(\mathbf{x}\) is \(\begin{bmatrix}1\\-1\\-1\end{bmatrix}\). The original form gives \(1+2+3=6\), and the transformed form gives \(1+5=6\).

Common Pitfall: Reversing the Transpose

A frequent error is to use \(\mathbf{P}\mathbf{A}\mathbf{P}^{\top}\) in place of \(\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\). The error can still produce a symmetric matrix, so symmetry alone does not catch it. In the first worked example, the incorrect order gives

$$ \mathbf{P}\mathbf{A}\mathbf{P}^{\top} = \begin{bmatrix}1&1\\0&1\end{bmatrix} \begin{bmatrix}2&1\\1&3\end{bmatrix} \begin{bmatrix}1&0\\1&1\end{bmatrix} = \begin{bmatrix}7&4\\4&3\end{bmatrix}. $$

This would claim that the new form is \(7y_1^2+8y_1y_2+3y_2^2\). But at \(\mathbf{y}=\begin{bmatrix}1\\0\end{bmatrix}\), the substitution gives \(\mathbf{x}=\begin{bmatrix}1\\0\end{bmatrix}\), and the original form equals \(2\), not \(7\). The correction is to transpose the left factor in \((\mathbf{P}\mathbf{y})^{\top}\): it is \(\mathbf{y}^{\top}\mathbf{P}^{\top}\), which forces the order \(\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\).

Congruence should also not be confused with similarity. The expression for changing a quadratic form is \(\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\); similarity uses \(\mathbf{P}^{-1}\mathbf{A}\mathbf{P}\) and concerns a different transformation. For quadratic forms, the reliable procedure is to substitute \(\mathbf{x}=\mathbf{P}\mathbf{y}\) into \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\), multiply in that order, and check the resulting expression by direct substitution.

Check Your Understanding

For each question, keep track of the substitution and verify the transformed form by expansion.

  1. If \(\mathbf{A}=\begin{bmatrix}3&1\\1&2\end{bmatrix}\) and \(\mathbf{P}=\begin{bmatrix}1&0\\1&1\end{bmatrix}\), compute \(\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\).
  2. For \(q(\mathbf{x})=x_1^2+2x_1x_2+2x_2^2\), use \(x_1=y_1-y_2,\;x_2=y_2\) to find the transformed form.
  3. Explain why the formula \(q(\mathbf{P}\mathbf{y})=\mathbf{y}^{\top}\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\mathbf{y}\) holds even when \(\mathbf{P}\) is not invertible.
  4. Why does invertibility ensure that the original and transformed forms take the same set of values?
  5. For a symmetric \(\mathbf{A}\), verify algebraically that \(\mathbf{P}^{\top}\mathbf{A}\mathbf{P}\) is symmetric.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon