Quadratic Forms & Definiteness
Feed a direction into xᵀAx and one number pops out — a warped 'size'. Sweep the direction around and a surface appears: a bowl, a saddle, an upside-down bowl. The eigenvalue signs set the shape, and the extreme values on the unit sphere are the largest and smallest eigenvalues — the heart of PCA.
What you'll learn
- A quadratic form is xᵀAx with A symmetric
- Positive definite ⇔ all eigenvalues > 0; positive semidefinite ⇔ all eigenvalues ≥ 0
- On ‖x‖ = 1, max xᵀAx = largest eigenvalue, min = smallest eigenvalue
- A Gram matrix XᵀX is always positive semidefinite
Before you start
The last lesson kept running into symmetric matrices and promised a payoff: feed a
direction x into the expression xᵀAx and one number pops out — a warped “size” of
x in that direction.
A symmetric matrix hides a whole landscape this way. Plug in a direction, read off a height; sweep the direction around and a surface emerges:
- maybe a bowl
- maybe an upside-down bowl
- maybe a saddle
That expression is a quadratic form, and its shape is set entirely by the eigenvalues of
A. Reading the curvature off them is what definiteness means — the engine behind PCA
and behind every “is this minimum really a minimum?” in optimisation.
The form and its curvature
For a symmetric A, the quadratic form is the scalar xᵀAx. With
A = [[a, b], [b, c]] in two dimensions it expands to a pure degree-2 expression:
xᵀAx = a·x₁² + 2b·x₁x₂ + c·x₂²
Run that on real entries once, so the symbols have somewhere to land. Take
A = [[6, 2], [2, 6]], so a = 6, b = 2, c = 6, and the form is
6x₁² + 4x₁x₂ + 6x₂². At x = (1, 1)/√2 each of x₁², x₁x₂, x₂² equals ½, giving
3 + 2 + 3 = 8.
At x = (1, −1)/√2 only the cross term flips sign, giving
3 − 2 + 3 = 4. Two unit directions, two very different heights on the same surface.
Hold on to those numbers, because 8 and 4 are precisely the eigenvalues of A.
The geometry of the whole surface is fixed by the signs of the eigenvalues:
Definiteness names the form by those signs (always with A symmetric):
- Positive definite:
xᵀAx > 0for allx ≠ 0⇔ all eigenvalues> 0(a bowl). - Positive semidefinite (PSD):
xᵀAx ≥ 0for allx⇔ all eigenvalues≥ 0. - Negative definite / semidefinite: flip the inequalities (all
< 0/≤ 0). - Indefinite: eigenvalues of both signs — a saddle.
The prefix semi deserves a moment, because it is not a hedge: semidefinite is definite
plus permission to hit zero. Positive definite means no non-zero direction is ever
flattened, so A is invertible.
Positive semidefinite allows some v ≠ 0 with vᵀAv = 0. Such a v is an eigenvector with
eigenvalue 0, which makes A singular. One zero eigenvalue is the entire difference
between the two words.
A Gram matrix XᵀX is always PSD, because xᵀ(XᵀX)x = (Xx)ᵀ(Xx) = ‖Xx‖² ≥ 0 for
every x. It is never guaranteed definite, for exactly the reason above: if X has a
non-trivial null space, some x ≠ 0 gives ‖Xx‖² = 0. Covariance matrices are Gram-like,
which is exactly why they come out PSD.
The optimisation fact behind PCA
Here is the result GATE tests most. Constrain x to the unit sphere (‖x‖ = 1) and
ask how large xᵀAx can grow. Diagonalise A = QΛQᵀ and write x in the orthonormal
eigenbasis with coordinates y = Qᵀx (so ‖y‖ = 1):
xᵀAx = λ₁y₁² + λ₂y₂² + … + λₙyₙ², with y₁² + … + yₙ² = 1
That is a weighted average of the eigenvalues, weights yᵢ² summing to 1. A weighted
average is biggest when all the weight piles onto the largest eigenvalue, smallest
when it piles onto the smallest:
So max₍‖x‖=1₎ xᵀAx = λ_max (at the top eigenvector) and the minimum is λ_min.
PCA is exactly this: the first principal direction maximises the variance xᵀΣx on
the unit sphere, so it is the top eigenvector of the covariance Σ.
Reshape the cloud below. The longest arrow, the direction of maximum spread, always lands
along the top eigenvector. The variance along it is the maximum of xᵀΣx.
Drag points — watch the principal axes re-fit live
A worked example — the 2026 maximisation question
Let
Abe symmetric with eigenvalues5and2. Find the maximum and minimum ofxᵀAxsubject to‖x‖ = 1.
Write x in A’s orthonormal eigenvectors, coordinates y₁, y₂ with y₁² + y₂² = 1,
then substitute y₂² = 1 − y₁²:
xᵀAx = 5·y₁² + 2·y₂² = 5y₁² + 2(1 − y₁²) = 2 + 3y₁²
This grows with y₁², largest (= 1) at the eigenvector for λ = 5 → maximum 5.
It is smallest (y₁² = 0) at the eigenvector for λ = 2 → minimum 2. The constrained
range is exactly [2, 5], smallest to largest eigenvalue — no calculus, no matrix entries.
A question to carry forward
To prove this we leaned on writing A as a product, A = QΛQᵀ — a decomposition that
laid its action bare. Factoring a matrix into a useful product is a recurring trick.
Here is the thread onward: the row-elimination you ran back in lesson four can itself be packaged as a product of two triangular matrices, so that the expensive part is done once and reused. What is that factorisation, and why would you ever want it?
In one breath
- A quadratic form
xᵀAx(symmetricA) is a warped “size” — sweepxand you trace a bowl, saddle, or dome set by eigenvalue signs. - Definiteness: positive definite ⇔ all
λ > 0; PSD ⇔ allλ ≥ 0; indefinite ⇔ mixed signs (saddle). - Gram matrix
XᵀXis always PSD (xᵀXᵀXx = ‖Xx‖² ≥ 0) — why covariance matrices are PSD. - On
‖x‖ = 1:max xᵀAx = λ_max,min = λ_min(at the matching eigenvectors). PCA’s top direction = top eigenvector ofΣ. - Trap: it’s the eigenvalues, not the entries —
[[2,−1],[−1,2]]is positive definite despite a negative entry.
Practice
Quick check
Practice this in an interview
All questionsPCA centers data and finds orthogonal directions that maximize variance, usually through the covariance matrix's eigenvectors or an SVD, then projects observations onto the leading directions. Choose the component count using cumulative explained variance or reconstruction needs for compression, and cross-validated downstream performance for prediction; standardize first only when feature scales should contribute equally.
PCA finds the orthogonal directions of maximum variance in the data and projects onto a lower-dimensional subspace, reducing features while retaining most information. It is most useful before distance-based models or when training is bottlenecked by dimensionality. Its main limits are loss of interpretability, sensitivity to scale, and an assumption of linear structure.
Under full column rank, OLS sets the gradient of the squared-error objective to zero, giving the normal equations and the unique coefficient vector β = (XᵀX)⁻¹Xᵀy. In rank-deficient or numerical settings, use the pseudoinverse or a least-squares solver rather than explicitly forming the inverse.
PCA is an unsupervised linear projection that preserves high-variance directions, not necessarily target-predictive directions. It can hurt when the signal is low-variance or nonlinear, scaling or outliers dominate, too many components are dropped, or component mixing damages the model or its interpretability; preprocessing must be fit on training data only.