From a Matrix to a Scalar-Valued Expression
A matrix can turn a vector into another vector, but the expression \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\) turns a vector into a single real number. This scalar depends quadratically on the coordinates of \(\mathbf{x}\). Reading the expression as a polynomial reveals which terms come from the diagonal of \(\mathbf{A}\) and how pairs of off-diagonal entries contribute to mixed terms. That relationship is worth tracking carefully: for a general matrix, a mixed-term coefficient is not necessarily twice either one of the entries on its own.
Throughout this tutorial, \(\mathbf{x}\) is a column in \(\mathbb{R}^n\), and \(\mathbf{A}\) is an \(n\times n\) real matrix. The transpose \(\mathbf{x}^{\top}\) is a row, so the product \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\) is a \(1\times1\) matrix, identified with its real entry. Write \(\mathbf{x}=(x_1,\dots,x_n)^{\top}\) and let \(a_{ij}\) denote the entry of \(\mathbf{A}\) in row \(i\), column \(j\).
No symmetry assumption is needed in this definition. A quadratic form is homogeneous of degree two: each term in its coordinate expansion has total degree two. The matrix multiplication can be evaluated in two useful stages. First compute \(\mathbf{y}=\mathbf{A}\mathbf{x}\); then compute the dot product \(\mathbf{x}^{\top}\mathbf{y}\). Alternatively, expand the product directly to read off its polynomial terms.
Identifying the Degree-Two Terms
The entry in row \(i\) of \(\mathbf{A}\mathbf{x}\) is \(a_{i1}x_1+\cdots+a_{in}x_n\). Multiplying this entry by \(x_i\) and adding over all rows gives the full expansion. The diagonal entries contribute squared-coordinate terms. For each pair of distinct coordinates, the two corresponding matrix entries contribute to the same mixed term.
Proof. By the definition of matrix multiplication, the \(i\)-th entry of \(\mathbf{A}\mathbf{x}\) is \(\sum_{j=1}^n a_{ij}x_j\). Therefore $$ \mathbf{x}^{\top}\mathbf{A}\mathbf{x} =\sum_{i=1}^n x_i\left(\sum_{j=1}^n a_{ij}x_j\right) =\sum_{i=1}^n\sum_{j=1}^n a_{ij}x_ix_j. $$ The terms with \(i=j\) are exactly \(\sum_{i=1}^n a_{ii}x_i^2\). For each distinct pair of indices \(i<j\), the double sum contains the two terms \(a_{ij}x_ix_j\) and \(a_{ji}x_jx_i\). Since real multiplication gives \(x_jx_i=x_ix_j\), their sum is \((a_{ij}+a_{ji})x_ix_j\). Every term in the double sum is either diagonal or belongs to exactly one such pair, which proves the formula. \(\square\)
If \(\mathbf{A}\) is symmetric, then \(a_{ij}=a_{ji}\), so the coefficient of \(x_ix_j\) becomes \(2a_{ij}\). The diagonal coefficient remains \(a_{ii}\), not \(2a_{ii}\): a diagonal term occurs just once in the expansion. When the matrix is not symmetric, use the sum \(a_{ij}+a_{ji}\), rather than assuming the symmetric shortcut.
Worked Example: Expanding a Symmetric Two-by-Two Matrix
Let $$ \mathbf{A}=\begin{bmatrix}3&2\\2&5\end{bmatrix}, \qquad \mathbf{x}=\begin{bmatrix}x_1\\x_2\end{bmatrix}. $$ Find the polynomial for \(q(\mathbf{x})=\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\), then evaluate it at \(\mathbf{x}=(1,-2)^{\top}\).
The diagonal entries give \(3x_1^2\) and \(5x_2^2\). The two off-diagonal entries both equal \(2\), so their combined contribution is \((2+2)x_1x_2=4x_1x_2\). Hence $$ q(\mathbf{x})=3x_1^2+4x_1x_2+5x_2^2. $$
For the specified vector, first multiply the matrix by the column: $$ \mathbf{A}\mathbf{x} =\begin{bmatrix}3&2\\2&5\end{bmatrix} \begin{bmatrix}1\\-2\end{bmatrix} =\begin{bmatrix}3-4\\2-10\end{bmatrix} =\begin{bmatrix}-1\\-8\end{bmatrix}. $$ Then $$ q(\mathbf{x}) =\begin{bmatrix}1&-2\end{bmatrix} \begin{bmatrix}-1\\-8\end{bmatrix} =-1+16=15. $$
Check: Substitution into the expanded polynomial gives \(3(1)^2+4(1)(-2)+5(-2)^2=3-8+20=15\), agreeing with the matrix product.
When the Matrix Is Not Symmetric
The definition permits nonsymmetric matrices, and the expansion theorem still applies without change. In particular, the entry \(a_{ij}\) and the entry \(a_{ji}\) may be different; both must be included to find the coefficient of \(x_ix_j\). In the next example, this pairing matters for all three mixed terms.
Worked Example: Combining Unequal Off-Diagonal Entries
For $$ \mathbf{A}=\begin{bmatrix}1&4&-1\\2&3&5\\3&-1&2\end{bmatrix}, \qquad \mathbf{x}=\begin{bmatrix}x_1\\x_2\\x_3\end{bmatrix}, $$ write \(q(\mathbf{x})=\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\) as a polynomial and evaluate it at \((1,2,-1)^{\top}\).
The diagonal entries give \(x_1^2+3x_2^2+2x_3^2\). For \(x_1x_2\), the paired entries are \(a_{12}=4\) and \(a_{21}=2\), giving coefficient \(6\). For \(x_1x_3\), the entries are \(-1\) and \(3\), giving coefficient \(2\). For \(x_2x_3\), the entries are \(5\) and \(-1\), giving coefficient \(4\). Thus $$ q(\mathbf{x})=x_1^2+3x_2^2+2x_3^2+6x_1x_2+2x_1x_3+4x_2x_3. $$
For \(\mathbf{x}=(1,2,-1)^{\top}\), compute each row of \(\mathbf{A}\mathbf{x}\): $$ \mathbf{A}\mathbf{x} =\begin{bmatrix} 1+8+1\\ 2+6-5\\ 3-2-2 \end{bmatrix} =\begin{bmatrix}10\\3\\-1\end{bmatrix}. $$ Therefore $$ q(\mathbf{x})=\begin{bmatrix}1&2&-1\end{bmatrix} \begin{bmatrix}10\\3\\-1\end{bmatrix} =10+6+1=17. $$
Check: Substitution into the polynomial gives \(1+12+2+12-2-8=17\). This matches the direct matrix evaluation.
In general, the expansion has one squared term for each coordinate and one mixed term for each unordered pair of distinct coordinates. There are no terms such as \(x_1x_2x_3\), because every term in the matrix product uses exactly two coordinates, counted with repetition. This also explains why diagonal entries control squared terms, while off-diagonal entries are grouped by coordinate pair.
Scaling a Vector Scales the Value Quadratically
Proof. The scalar \(t\) multiplies every entry of the column \(\mathbf{x}\), and it also multiplies every entry of the transpose \(\mathbf{x}^{\top}\). Using associativity of matrix multiplication and pulling scalar factors out of the product gives $$ q(t\mathbf{x})=(t\mathbf{x})^{\top}\mathbf{A}(t\mathbf{x}) =t\mathbf{x}^{\top}\mathbf{A}t\mathbf{x} =t^2\mathbf{x}^{\top}\mathbf{A}\mathbf{x} =t^2q(\mathbf{x}). $$ This computation holds for every real \(t\), including \(t=0\), in which case both sides are \(0\). \(\square\)
One immediate consequence is \(q(-\mathbf{x})=q(\mathbf{x})\), since \((-1)^2=1\). Also \(q(\mathbf{0})=0\). These are useful arithmetic checks when evaluating a form: replacing the input by its negative must not change the value, and the zero column must produce zero.
Worked Example: Reading and Checking a Three-Variable Form
Let $$ \mathbf{A}=\begin{bmatrix}2&-3&1\\-3&4&2\\1&2&-1\end{bmatrix}, \qquad \mathbf{x}=\begin{bmatrix}2\\-1\\3\end{bmatrix}. $$ Identify the polynomial terms and evaluate the form.
The diagonal entries give \(2x_1^2+4x_2^2-x_3^2\). The entries paired across the diagonal give \((-3-3)x_1x_2=-6x_1x_2\), \((1+1)x_1x_3=2x_1x_3\), and \((2+2)x_2x_3=4x_2x_3\). Therefore $$ q(\mathbf{x})=2x_1^2+4x_2^2-x_3^2-6x_1x_2+2x_1x_3+4x_2x_3. $$
Evaluate by matrix multiplication: $$ \mathbf{A}\mathbf{x} =\begin{bmatrix} 4+3+3\\ -6-4+6\\ 2-2-3 \end{bmatrix} =\begin{bmatrix}10\\-4\\-3\end{bmatrix}, \qquad q(\mathbf{x})=2(10)+(-1)(-4)+3(-3)=20+4-9=15. $$
Check: Substituting the coordinates into the polynomial gives \(8+4-9+12+12-12=15\). The two evaluations agree.
Common Pitfall: Doubling the Wrong Entry
For a symmetric matrix, it is convenient to double one off-diagonal entry to get its mixed-term coefficient. Applying that shortcut to a nonsymmetric matrix can produce the wrong polynomial. For example, take $$ \mathbf{B}=\begin{bmatrix}1&4\\2&3\end{bmatrix}. $$ The incorrect calculation \(2a_{12}=8\) would assign \(8x_1x_2\). But \(\mathbf{B}\) is not symmetric: \(a_{12}=4\) and \(a_{21}=2\). The correct coefficient is their sum, \(4+2=6\), so $$ \mathbf{x}^{\top}\mathbf{B}\mathbf{x}=x_1^2+6x_1x_2+3x_2^2. $$
At \(\mathbf{x}=(1,1)^{\top}\), the incorrect polynomial gives \(1+8+3=12\). Direct multiplication instead gives $$ \mathbf{B}\mathbf{x}=\begin{bmatrix}5\\5\end{bmatrix}, \qquad \mathbf{x}^{\top}\mathbf{B}\mathbf{x} =\begin{bmatrix}1&1\end{bmatrix}\begin{bmatrix}5\\5\end{bmatrix} =10. $$ The correct expansion also gives \(1+6+3=10\). The correction is to combine the two entries for each mixed term; use \(2a_{ij}\) only when symmetry has been established.
When working with a particular quadratic form, a reliable sequence is to record the diagonal terms first, then list each distinct index pair once and add the two corresponding matrix entries. Finally, evaluate either the resulting polynomial or the original matrix product. Agreement between those calculations checks both the coefficient bookkeeping and the arithmetic of the evaluation.
Check Your Understanding
For each question, keep the vectors as columns and use the paired-entry rule for mixed terms.
- For \(\mathbf{A}=\begin{bmatrix}2&-1\\3&4\end{bmatrix}\), write \(\mathbf{x}^{\top}\mathbf{A}\mathbf{x}\) as a polynomial in \(x_1,x_2\).
- Evaluate the form from question 1 at \(\mathbf{x}=(2,-1)^{\top}\), using matrix multiplication and the polynomial.
- For \(\mathbf{C}=\begin{bmatrix}1&2&0\\2&-1&3\\0&3&5\end{bmatrix}\), identify the coefficient of each squared term and each mixed term.
- Explain why \(q(-\mathbf{x})=q(\mathbf{x})\) for every real quadratic form.
- Give the mixed-term coefficient for \(x_1x_2\) when \(a_{12}=-5\) and \(a_{21}=2\). Why would doubling \(a_{12}\) be incorrect unless the matrix is symmetric?