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.
For example, if \(\mathbf{A}\) is a symmetric \(2\times2\) matrix, then
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
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,
To check, multiply the matrix by the variable column first:
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
Multiplying \(\mathbf{A}\) by the variable column gives
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.
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}\):
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:
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.
- Write \(4x^2-10xy+3y^2+2x-9\) as \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}+\mathbf{b}^{\top}\mathbf{x}+c\).
- For \(x^2+6xz-2y^2+8yz\), state the symmetric \(3\times3\) matrix of its quadratic form.
- Write the augmented symmetric matrix for \(p(x,y)=2x^2+4xy-y^2-6x+10y+3\).
- What polynomial is represented by \(\begin{bmatrix}2&1\\1&5\end{bmatrix}\) as a quadratic form in \(x,y\)?
- Explain why the entries linking \(x_i\) to the appended coordinate are half the coefficient of \(x_i\).