Tutorials › Linear Algebra › Translating Quadratic Polynomials Into Matrices

Quadratic Forms and Definiteness · Tutorial 758 of 1000

Translating Quadratic Polynomials Into Matrices

Translate a quadratic polynomial into a symmetric matrix expression, including the linear and constant terms when needed.

Advanced 9 min read

What You'll Learn

  • Identify the quadratic, linear, and constant parts of a polynomial.
  • Construct a symmetric matrix by placing half of each mixed-term coefficient in both matching off-diagonal entries.
  • Write a quadratic form and a full polynomial using matrix notation.
  • Encode linear and constant terms with an augmented symmetric matrix.
  • Recover a polynomial from its matrix and check the coefficients by expansion.

From Polynomial Terms to Matrix Entries

A quadratic polynomial can be written compactly using a symmetric matrix, but the entries do not copy every coefficient directly. A squared term such as \(3x^2\) determines one diagonal entry, while a mixed term such as \(8xy\) comes from two equal off-diagonal entries. Keeping track of both contributions is the key to translating correctly.

Throughout, the variables and coefficients are real. For variables \(x_1,\dots,x_n\), write \(\mathbf{x}=(x_1,\dots,x_n)^{\top}\) as a column. A polynomial of degree at most two has quadratic terms, linear terms, and possibly a constant term. Its quadratic part is the sum of the terms of degree two. In this tutorial we focus on polynomials in two or three variables, while writing the rule in a form that also explains the general pattern.

Definition: A quadratic form in \(\mathbf{x}\) is a homogeneous polynomial of degree two that can be written \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\), where \(\mathbf{A}\) is a symmetric real matrix. A general polynomial of degree at most two also has linear and constant terms, so it can be written \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}+\mathbf{b}^{\top}\mathbf{x}+c\), with \(\mathbf{b}\) a column vector and \(c\in\mathbb{R}\).

For example, if \(\mathbf{A}\) is a symmetric \(2\times2\) matrix, then

$$ \begin{bmatrix}x&y\end{bmatrix} \begin{bmatrix}a&d\\d&e\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix} =ax^2+2dxy+ey^2. $$

The mixed term appears twice: once from the entry in row 1, column 2, and once from the entry in row 2, column 1. Therefore, to represent a mixed-term coefficient \(m\), use \(m/2\) in each of those two positions. This is also why the matrix is symmetric: the two contributions are equal.

The Coefficient Rule

Theorem (Matrix representation of a quadratic polynomial): Let \(p\) be a real polynomial of degree at most two in \(n\) variables, where \(n=2\) or \(n=3\). Write its terms as \(p(\mathbf{x})=\sum_{i=1}^{n}a_i x_i^2+\sum_{1\le i<j\le n}d_{ij}x_ix_j+\sum_{i=1}^{n}b_i x_i+c\). Define \(\mathbf{A}\) by \(a_{ii}=a_i\) and \(a_{ij}=a_{ji}=d_{ij}/2\) for \(i<j\), and define \(\mathbf{b}=(b_1,\dots,b_n)^{\top}\). Then \(p(\mathbf{x})=\mathbf{x}^{\top}\mathbf{A}\mathbf{x}+\mathbf{b}^{\top}\mathbf{x}+c\). These coefficients determine \(\mathbf{A}\), \(\mathbf{b}\), and \(c\) uniquely.

Proof. By matrix multiplication, the diagonal entry \(a_{ii}\) contributes \(a_{ii}x_i^2\). For each pair \(i<j\), the two off-diagonal entries contribute \(a_{ij}x_ix_j+a_{ji}x_jx_i\). Since \(a_{ij}=a_{ji}=d_{ij}/2\) and \(x_jx_i=x_ix_j\), their sum is \(d_{ij}x_ix_j\). Thus \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\) has exactly the stated quadratic terms. The dot product \(\mathbf{b}^{\top}\mathbf{x}\) is \(\sum_{i=1}^{n}b_i x_i\), and adding \(c\) gives \(p\). For uniqueness, suppose another symmetric matrix \(\mathbf{A}'\), vector \(\mathbf{b}'\), and scalar \(c'\) give the same polynomial. Comparing coefficients of \(x_i^2\) gives \(a'_{ii}=a_i\); comparing coefficients of \(x_ix_j\) gives \(2a'_{ij}=d_{ij}\), hence \(a'_{ij}=a'_{ji}=d_{ij}/2\). Comparing the coefficients of \(x_i\) gives \(b'_i=b_i\), and comparing constants gives \(c'=c\). Every entry and scalar therefore agrees with the construction. \(\square\)

In practice, first sort the terms by degree. Read each squared-term coefficient onto the diagonal, halve each mixed-term coefficient for its two symmetric positions, and put the linear coefficients into \(\mathbf{b}\). Keep the constant \(c\) separate unless you choose to use augmented coordinates, described below.

Worked Conversions

Worked Example: A Polynomial in Two Variables

Write \(p(x,y)=3x^2+8xy-2y^2+5x-6y+4\) in symmetric matrix form.

The squared-term coefficients are \(3\) and \(-2\), so they go on the diagonal. The coefficient of \(xy\) is \(8\), so each off-diagonal entry is \(8/2=4\). The linear coefficient vector is \(\mathbf{b}=(5,-6)^{\top}\), and the constant is \(4\). Therefore,

$$ p(x,y)= \begin{bmatrix}x&y\end{bmatrix} \begin{bmatrix}3&4\\4&-2\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix} + \begin{bmatrix}5&-6\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix} +4. $$

To check, multiply the matrix by the variable column first:

$$ \begin{bmatrix}3&4\\4&-2\end{bmatrix} \begin{bmatrix}x\\y\end{bmatrix} = \begin{bmatrix}3x+4y\\4x-2y\end{bmatrix}. $$

Taking the dot product with \(\begin{bmatrix}x&y\end{bmatrix}\) gives \(3x( x)+4xy+4yx-2y(y)=3x^2+8xy-2y^2\). The linear part is \(5x-6y\), and adding \(4\) reproduces the original polynomial.

Worked Example: A Polynomial in Three Variables

Represent \(q(x,y,z)=2x^2-6xy+4xz+y^2+10yz-3z^2+7x-2y+6z-5\) using a symmetric matrix and its linear and constant terms.

The diagonal entries are \(2,1,-3\). The mixed coefficients \(-6,4,10\) are halved to give \(-3,2,5\), respectively. Thus

$$ \mathbf{A}= \begin{bmatrix} 2&-3&2\\ -3&1&5\\ 2&5&-3 \end{bmatrix}, \qquad \mathbf{b}= \begin{bmatrix}7\\-2\\6\end{bmatrix}, \qquad c=-5. $$

Multiplying \(\mathbf{A}\) by the variable column gives

$$ \begin{bmatrix} 2&-3&2\\ -3&1&5\\ 2&5&-3 \end{bmatrix} \begin{bmatrix}x\\y\\z\end{bmatrix} = \begin{bmatrix} 2x-3y+2z\\ -3x+y+5z\\ 2x+5y-3z \end{bmatrix}. $$

Now take the dot product with \(\begin{bmatrix}x&y&z\end{bmatrix}\). The result is \(2x^2-3xy+2xz-3xy+y^2+5yz+2xz+5yz-3z^2 =2x^2-6xy+4xz+y^2+10yz-3z^2\). The linear part is \(7x-2y+6z\), and adding \(c=-5\) gives exactly \(q\).

Putting the Whole Polynomial in One Matrix

There is a convenient way to include the linear and constant terms in a single symmetric matrix expression. Append a final coordinate equal to \(1\), and set \(\mathbf{u}=(x_1,\dots,x_n,1)^{\top}\). The quadratic coefficients remain in the upper-left block. To produce \(b_i x_i\), put \(b_i/2\) in each of the two symmetric positions linking \(x_i\) to the final coordinate. Put \(c\) in the bottom-right entry.

Formula: With \(\mathbf{A}\), \(\mathbf{b}\), and \(c\) as above, define \(\mathbf{M}=\begin{bmatrix}\mathbf{A}&\mathbf{b}/2\\\mathbf{b}^{\top}/2&c\end{bmatrix}\). For \(\mathbf{u}=(\mathbf{x}^{\top},1)^{\top}\), the full polynomial is \(p(\mathbf{x})=\mathbf{u}^{\top}\mathbf{M}\mathbf{u}\).

This formula follows by block multiplication: the upper-left block contributes \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\); the two off-diagonal blocks contribute \(\mathbf{x}^{\top}\mathbf{b}/2+\mathbf{b}^{\top}\mathbf{x}/2=\mathbf{b}^{\top}\mathbf{x}\); and the last entry contributes \(c\cdot1\cdot1=c\). Thus the halving rule applies to linear terms too, when they are represented as mixed terms with the appended coordinate.

Worked Example: Recovering a Polynomial from an Augmented Matrix

Translate the symmetric matrix below into a polynomial, using \(\mathbf{u}=(x,y,1)^{\top}\):

$$ \mathbf{M}= \begin{bmatrix} 1&-2&3/2\\ -2&0&-4\\ 3/2&-4&7 \end{bmatrix}. $$

The diagonal entries give \(x^2\), no \(y^2\) term, and the constant \(7\). The entry \(-2\) appears twice in the \(x,y\) positions, giving \(-4xy\). The entries \(3/2\) give \(3x\) in total, and the entries \(-4\) give \(-8y\). Hence the polynomial is \(x^2-4xy+3x-8y+7\).

Check by multiplying:

$$ \mathbf{M}\mathbf{u} = \begin{bmatrix} x-2y+3/2\\ -2x-4\\ 3x/2-4y+7 \end{bmatrix}, \qquad \mathbf{u}^{\top}\mathbf{M}\mathbf{u} =x(x-2y+3/2)+y(-2x-4)+(3x/2-4y+7). $$

Expanding gives \(x^2-2xy+3x/2-2xy-4y+3x/2-4y+7=x^2-4xy+3x-8y+7\), as claimed.

Common Mistakes and a Reliable Check

Common mistake: placing the full mixed coefficient in both entries. For a term \(6xy\), a tempting choice is to put \(6\) in both off-diagonal positions. But then the matrix expression contains \(6xy+6yx=12xy\), not \(6xy\). The correction is to place \(3\) in each position: \(3xy+3yx=6xy\).

Common mistake: forgetting the two contributions in an augmented matrix. If a polynomial contains \(5x\), the entries connecting \(x\) and the final coordinate must each be \(5/2\), not \(5\). With \(5\) in both positions, the resulting terms are \(5x+5x=10x\). When checking any translation, expand one off-diagonal pair explicitly; its two contributions should sum to the intended coefficient.

These matrix expressions are useful because they organize all degree-two coefficients in one object. They also let us keep the quadratic part distinct from linear and constant terms: \(\mathbf{A}\) records the quadratic coefficients, \(\mathbf{b}\) records the linear ones, and \(c\) records the constant. For a full polynomial, the augmented form is a compact alternative, but the variable column must include the final \(1\). Without that coordinate, the matrix product represents only a quadratic form and cannot produce linear or constant terms.

As a final check, compare coefficients rather than judging by the appearance of the matrix: diagonal entries must match square-term coefficients, twice each off-diagonal entry must match its mixed-term coefficient, and the linear and constant terms must be accounted for separately or through the augmented matrix.

Check Your Understanding

For each question, use expansion to verify the matrix expression you construct or interpret.

  1. Write \(4x^2-10xy+3y^2+2x-9\) as \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}+\mathbf{b}^{\top}\mathbf{x}+c\).
  2. For \(x^2+6xz-2y^2+8yz\), state the symmetric \(3\times3\) matrix of its quadratic form.
  3. Write the augmented symmetric matrix for \(p(x,y)=2x^2+4xy-y^2-6x+10y+3\).
  4. What polynomial is represented by \(\begin{bmatrix}2&1\\1&5\end{bmatrix}\) as a quadratic form in \(x,y\)?
  5. Explain why the entries linking \(x_i\) to the appended coordinate are half the coefficient of \(x_i\).

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