The matrix of a form and its definiteness. Covariance, AᵀA and the Hessian test depend on it.
Open the interactive lessons →Quadratic Forms and Definiteness past questions
Contents
- From polynomial to matrix
- Testing definiteness
- Properties and Gram matrices
- Semidefinite forms and extrema
1. From polynomial to matrix
Squares go on the diagonal; each cross term is split in two.
how to write a quadratic form as $x^TAx$ with a symmetric $A$
The question this lesson answers. How does a formula in $x$ and $y$ turn into a matrix?
The $xy$ term belongs to two mirror places of the matrix, so each gets half.
A quadratic form in $x\in\mathbb R^n$ is a function $Q(x)=x^TAx$: a sum of terms of degree exactly two. There is always exactly one symmetric matrix $A$ that represents it.
Why it works this way. Expanding $x^TAx$ produces $a_{12}xy$ and $a_{21}yx$. With a symmetric matrix these are equal, so together they must give the coefficient.
Expand the product for two variables: $$\begin{bmatrix}x&y\end{bmatrix}\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}=ax^2+(b+c)\,xy+dy^2.$$ Only the sum $b+c$ appears. So infinitely many matrices give the same function. We pick the symmetric one, $b=c=$ half the coefficient of $xy$. In $n$ variables:
- $a_{ii}$ = coefficient of $x_i^2$.
- $a_{ij}=a_{ji}$ = half the coefficient of $x_ix_j$.
- A missing term means a zero entry.
Read the order of terms carefully. Questions often list the cross terms first and the squares last, with negative signs. Match each coefficient to its variables, not to its position in the sentence.
If a question gives a non-symmetric matrix $B$, the form $x^TBx$ equals $x^TAx$ with $A=\tfrac12(B+B^T)$, called the symmetric part. The other half, $\tfrac12(B-B^T)$, contributes nothing: for a skew-symmetric $K$, the number $x^TKx$ equals its own negative.
$$Aq=\lambda q,\ \lVert q\rVert=1\ \Rightarrow\ Q(q)=q^TAq=\lambda$$ So each eigenvalue is a value the form actually takes on the unit circle.
Worked example: Two variables
Problem.
Find the symmetric matrix of $Q=3x^2-8xy+5y^2$.
Idea.
Diagonal from the squares, half of the cross term off it.
- Diagonal entries 3 and 5.
- Cross coefficient $-8$ gives $-4$ in both off-diagonal places.
Answer.
$\begin{bmatrix}3&-4\\-4&5\end{bmatrix}$.
Common mistake.
Writing $-8$ in both places, which doubles the cross term.
Worked example: Three variables in mixed order
Problem.
Find $A$ for $Q=4x_1x_3-2x_2^2+6x_1x_2-x_1^2$.
Idea.
Fill one entry per term.
- Squares: $a_{11}=-1$, $a_{22}=-2$, $a_{33}=0$.
- $6x_1x_2$ gives $a_{12}=a_{21}=3$.
- $4x_1x_3$ gives $a_{13}=a_{31}=2$. No $x_2x_3$ term, so $a_{23}=0$.
Answer.
$\begin{bmatrix}-1&3&2\\3&-2&0\\2&0&0\end{bmatrix}$.
Common mistake.
Forgetting that the missing $x_3^2$ means a zero.
Check an option by evaluating at $x=(1,1,\dots,1)$: the value $x^TAx$ is the sum of all entries of $A$, and must equal the sum of all coefficients.
Worked example: A non-symmetric matrix
Problem.
For $\begin{bmatrix}1&4\\0&1\end{bmatrix}$, is $x^TBx$ positive for every non-zero $x$?
Idea.
Use the symmetric part.
- The symmetric part is $\begin{bmatrix}1&2\\2&1\end{bmatrix}$.
- Its determinant is $-3$, so the form takes both signs.
Answer.
No.
Common mistake.
Reading the eigenvalues 1, 1 of $B$ and answering yes.
Squares on the diagonal, half the cross terms off it.
Method for any exam question
| Step | Do this |
|---|---|
| 1 | Put each square coefficient on the diagonal. |
| 2 | Halve each cross coefficient. |
| 3 | Place the half in both mirror positions. |
2. Testing definiteness
Find out whether the form is a bowl, a dome, a trough or a saddle.
the three tests and when each is safe
The question this lesson answers. Can you tell whether a quadratic form is always positive without trying every vector?
The five classes for a symmetric $A$
| Class | Values of $x^TAx$ for $x\ne0$ | Eigenvalues |
|---|---|---|
| positive definite | always $>0$ | all $>0$ |
| positive semidefinite | always $\ge0$ | all $\ge0$ |
| negative definite | always $<0$ | all $<0$ |
| negative semidefinite | always $\le0$ | all $\le0$ |
| indefinite | both signs | both signs |
Why it works this way. In the eigenvector axes, the form is a sum of eigenvalues times squares. The signs of the eigenvalues therefore decide the signs the form can take.
Every positive definite matrix is also positive semidefinite. When a question offers both and the matrix is definite, the stronger name is intended.
Test 1: eigenvalue signs. Always valid for symmetric matrices. Best for $2\times2$, where determinant and trace give the signs without solving: if $\det<0$ the signs differ, so the matrix is indefinite; if $\det>0$ they agree, and the trace tells which sign.
Test 2: leading principal minors (Sylvester). Let $D_k$ be the determinant of the top-left $k\times k$ block. Positive definite exactly when all $D_k>0$. Negative definite exactly when the signs alternate starting negative: $D_1<0$, $D_2>0$, $D_3<0$.
Test 3: completing the square. Rewrite $Q$ as a sum of squares with signs.
Two warnings. First, leading minors $\ge0$ do not prove semidefiniteness. The matrix $\begin{bmatrix}0&0\\0&-1\end{bmatrix}$ has $D_1=0$, $D_2=0$, yet it takes negative values. For semidefiniteness every principal minor (any choice of the same rows and columns) must be non-negative, or just use eigenvalues. Second, for a non-symmetric matrix none of these tests apply directly. Form the symmetric part first.
Picture the height $z=Q(x,y)$. A bowl is positive definite, a dome negative definite, a saddle indefinite, and a straight trough is semidefinite. The picture stops at two variables; the algebra continues in any dimension.
The third leading minor is the full $3\times3$ determinant: $a(ei-fh)-b(di-fg)+c(dh-eg)$. It is worked through in [the first eigenvalue lesson](#topic/eigen-diagonalization/lesson/s1).
Worked example: Two by two by determinant
Problem.
Classify $\begin{bmatrix}2&6\\6&7\end{bmatrix}$.
Idea.
Sign of the determinant.
- $\det=14-36=-22<0$.
- The eigenvalues have opposite signs.
Answer.
Indefinite.
Common mistake.
Seeing positive entries and answering positive definite.
Worked example: Sylvester on three by three
Problem.
Classify $\begin{bmatrix}3&1&0\\1&2&1\\0&1&2\end{bmatrix}$.
Idea.
Symmetric, so use leading minors.
- $D_1=3$.
- $D_2=6-1=5$.
- $D_3=3(4-1)-1(2-0)+0=9-2=7$.
Answer.
All positive: positive definite.
Common mistake.
Computing only the determinant of the whole matrix.
Worked example: A non-symmetric matrix
Problem.
Is $x^TBx>0$ for all $x\ne0$ when $B=\begin{bmatrix}4&3\\-3&-2\end{bmatrix}$?
Idea.
Use the symmetric part.
- $\tfrac12(B+B^T)=\begin{bmatrix}4&0\\0&-2\end{bmatrix}$.
- At $(0,1)$ the value is $-2$; at $(1,0)$ it is $4$.
Answer.
No. The form is indefinite, although both eigenvalues of $B$ itself equal $1$.
Common mistake.
Using the eigenvalues of $B$.
One negative diagonal entry and one positive diagonal entry already prove "indefinite", because $e_i^TAe_i=a_{ii}$.
$\begin{bmatrix}1&2\\2&1\end{bmatrix}$ has only positive entries, yet its eigenvalues are $3$ and $-1$, so it is indefinite.
Eigenvalue signs decide everything.
Method for any exam question
| Step | Do this |
|---|---|
| 1 | Make the matrix symmetric. |
| 2 | For two variables, read the determinant first. |
| 3 | Use leading minors for definiteness. |
| 4 | Mixed signs mean indefinite. |
3. Properties and Gram matrices
Positive eigenvalues give an inverse; squared lengths are never negative.
what follows from positive definiteness, and why $A^TA$ is never negative
The question this lesson answers. Why is $A^TA$ never negative, whatever $A$ is?
The form of $A^TA$ is the squared length of $Ax$, and a squared length cannot be negative.
Facts about a real symmetric positive definite $A$
| Statement | Reason |
|---|---|
| $A$ is invertible | no eigenvalue is 0 |
| $A^{-1}$ is positive definite | eigenvalues $1/\lambda>0$ |
| $A^3+A$ is positive definite | eigenvalues $\lambda^3+\lambda>0$ |
| diagonal entries are positive | $a_{ii}=e_i^TAe_i$ |
| $\det A>0$ | product of positive numbers |
The converse of the last row is false: $\begin{bmatrix}-1&0\\0&-1\end{bmatrix}$ has determinant 1 and is negative definite. A diagonal matrix with positive diagonal entries is positive definite, since its form is $\sum d_ix_i^2$.
Gram matrices. For any real $m\times n$ matrix $A$, the matrix $A^TA$ is $n\times n$ and symmetric: $(A^TA)^T=A^TA$. And $$x^T(A^TA)x=(Ax)^T(Ax)=\lVert Ax\rVert^2\ge0.$$ So $A^TA$ is always positive semidefinite, whether or not $A$ is square or symmetric. It is positive definite exactly when $Ax=0$ forces $x=0$, that is, when the columns of $A$ are independent. The same holds for $AA^T$, using $\lVert A^Tx\rVert^2$. The two have different sizes in general, so they need not be equal.
Because $A^TA$ is real symmetric, it is orthogonally diagonalisable. Its eigenvalues are non-negative, and their square roots are the singular values of $A$. So singular values are never negative. For a symmetric positive definite matrix the singular values equal the eigenvalues, so all are positive. If every singular value of a matrix is zero, then $\operatorname{tr}(A^TA)=\sum a_{ij}^2=0$, so $A=0$.
Worked example: A Gram matrix
Problem.
$A=\begin{bmatrix}1&0\\1&1\\0&1\end{bmatrix}$. Is $A^TA$ positive definite?
Idea.
Compute and test.
- $A^TA=\begin{bmatrix}2&1\\1&2\end{bmatrix}$.
- $D_1=2$, $D_2=3$.
Answer.
Yes. The columns of $A$ are independent.
Common mistake.
Saying a non-square $A$ cannot produce a positive definite matrix.
Worked example: The inverse
Problem.
$S$ is symmetric positive definite with eigenvalues 2 and 5. Classify $S^{-1}$.
Idea.
Reciprocate the eigenvalues.
- $S^{-1}$ is symmetric.
- Its eigenvalues are $\tfrac12$ and $\tfrac15$.
Answer.
Always positive definite.
Common mistake.
Reading "may also be" as "only sometimes". It is true every time.
Worked example: A Gram matrix that is only semidefinite
Problem.
$A$ is the zero matrix. What is the definiteness of $A^TA$?
Idea.
Check whether $Ax=0$ has non-zero solutions.
- Every $x$ gives $Ax=0$.
- So the form is always 0.
Answer.
Positive semidefinite (and also negative semidefinite), not definite.
Common mistake.
Calling every $A^TA$ positive definite.
- Any expression that can be written as a sum of squares is at least semidefinite.
- To test whether $A^TA$ is positive definite, check only whether the columns of $A$ are independent.
- Fewer rows than columns means dependent columns, so $A^TA$ cannot be positive definite.
$A^TA$ is always semidefinite; definite with independent columns.
Method for any exam question
| Step | Do this |
|---|---|
| 1 | Write the form as a squared length. |
| 2 | Ask whether $Ax=0$ has a non-zero solution. |
| 3 | None: positive definite. Some: only semidefinite. |
4. Semidefinite forms and extrema
A bowl has a lowest point and no highest one.
what definiteness says about smallest and largest values
The question this lesson answers. Where is a quadratic form smallest or largest?
A bowl has one lowest point, a dome one highest, a trough a whole line of lowest points, and a saddle neither.
Every quadratic form satisfies $Q(0)=0$. What happens elsewhere decides the extrema over all of $\mathbb R^n$. It helps to remember that $Q(tx)=t^2Q(x)$: along any line through the origin, the form is a parabola that either opens up, opens down or stays flat.
Why it works this way. Along a line through the origin the form is $t^2$ times a fixed number. The sign of that number decides whether it rises, falls or stays flat.
Extrema of a quadratic form on $\mathbb R^n$
| Class | Global minimum | Global maximum |
|---|---|---|
| PD | 0, only at the origin | none |
| PSD, not zero | 0, along a whole flat set | none |
| ND | none | 0, only at the origin |
| NSD, not zero | none | 0, along a flat set |
| indefinite | none | none (saddle) |
Why is there no maximum for a positive semidefinite form that is not identically zero? There is some $x$ with $Q(x)>0$, and then $Q(tx)=t^2Q(x)$ grows without bound. The one exception is the zero form $Q\equiv0$, which is both PSD and NSD and has 0 as both extremes. Exam statements usually ignore this trivial case.
For a function that is not a pure quadratic form, such as $x^TAx+b^Tx+c$ with $A$ positive definite, the minimum moves away from the origin but is still unique. When a question speaks of a "positive semidefinite function", it means a quadratic form with a positive semidefinite matrix.
The flat directions of a PSD form are exactly the null space of its matrix: if $A=B^TB$ then $x^TAx=0$ means $Bx=0$.
Worked example: Minimum of a trough
Problem.
Describe the minima of $Q=(x-y)^2$.
Idea.
A square is at least 0.
- $Q\ge0$ always.
- $Q=0$ exactly when $x=y$.
Answer.
Minimum value 0 on the whole line $x=y$. No maximum.
Common mistake.
Expecting a single minimising point.
Worked example: Bounds on the unit circle
Problem.
Find the largest and smallest values of $x^2+4xy+y^2$ with $x^2+y^2=1$.
Idea.
They are the extreme eigenvalues.
- Matrix $\begin{bmatrix}1&2\\2&1\end{bmatrix}$.
- Eigenvalues $3$ and $-1$.
Answer.
Maximum 3, minimum $-1$.
Common mistake.
Forgetting that the constraint changes the answer: without it the form is unbounded.
Worked example: Leading minors can mislead
Problem.
For $\begin{bmatrix}0&0\\0&-1\end{bmatrix}$ both leading minors are $0$. Is the matrix positive semidefinite?
Idea.
Leading minors are not enough for semidefiniteness.
- $e_2^TAe_2=-1<0$.
- One negative value is decisive.
Answer.
No.
Common mistake.
Accepting it because no leading minor is negative.
- On the unit sphere the largest value is the largest eigenvalue, and it is reached at its unit eigenvector.
- If the constraint is $\lVert x\rVert=r$, multiply both extreme values by $r^2$.
- Read the matrix from the form correctly: half of each cross-term coefficient goes in each off-diagonal place.
On the unit sphere the form runs from the smallest eigenvalue to the largest.
Method for any exam question
| Step | Do this |
|---|---|
| 1 | Classify the matrix. |
| 2 | Definite: the only extreme is at the origin. |
| 3 | Semidefinite: the extreme is taken on the null space. |
| 4 | On the unit circle, use the extreme eigenvalues. |