1.1.18Linear Algebra Essentials

Quadratic forms

1,606 words7 min readdifficulty · medium2 backlinks

WHAT is a quadratic form?

WHY symmetric? Only the symmetric part of AA affects QQ. Split A=S+KA = S + K where S=12(A+A)S=\tfrac12(A+A^\top) is symmetric and K=12(AA)K=\tfrac12(A-A^\top) is skew. Then xKx=0\mathbf{x}^\top K \mathbf{x}=0 always (a scalar equals its transpose: xKx=(xKx)=xKx=xKx\mathbf{x}^\top K\mathbf{x}=(\mathbf{x}^\top K\mathbf{x})^\top=\mathbf{x}^\top K^\top\mathbf{x}=-\mathbf{x}^\top K\mathbf{x}, so it's 0). So we always assume AA symmetric — nothing is lost.


HOW to expand it (derivation from scratch)

Start with the double sum and see where each piece comes from. Take n=2n=2: xAx=[x1x2][abbc][x1x2].\mathbf{x}^\top A\mathbf{x} = \begin{bmatrix}x_1 & x_2\end{bmatrix}\begin{bmatrix}a & b\\ b & c\end{bmatrix}\begin{bmatrix}x_1\\x_2\end{bmatrix}.

Step 1 — inner multiply AxA\mathbf{x}: Ax=[ax1+bx2bx1+cx2].A\mathbf{x} = \begin{bmatrix}a x_1 + b x_2\\ b x_1 + c x_2\end{bmatrix}. Why this step? Matrix–vector product first collapses one dimension, leaving a vector.

Step 2 — dot with x\mathbf{x}^\top: Q=x1(ax1+bx2)+x2(bx1+cx2)=ax12+2bx1x2+cx22.Q = x_1(a x_1 + b x_2) + x_2(b x_1 + c x_2) = a x_1^2 + 2b\,x_1 x_2 + c\,x_2^2. Why this step? The cross terms bx1x2b x_1x_2 appear twice (from A12A_{12} and A21A_{21}), producing the factor 2b2b. This is the key reading rule.


Definiteness — the shape of the bowl

HOW to test it — via eigenvalues (derivation). Since AA is symmetric, the Spectral Theorem gives an orthonormal eigenbasis A=QΛQA = Q\Lambda Q^\top with QQ=IQ^\top Q = I. Substitute y=Qx\mathbf{y}=Q^\top\mathbf{x} (a rotation, y=x\|\mathbf y\|=\|\mathbf x\|): xAx=xQΛQx=yΛy=i=1nλiyi2.\mathbf{x}^\top A\mathbf{x} = \mathbf{x}^\top Q\Lambda Q^\top\mathbf{x} = \mathbf{y}^\top\Lambda\mathbf{y} = \sum_{i=1}^n \lambda_i\, y_i^2.

Figure — Quadratic forms

Worked examples


Common mistakes


Recall Explain to a 12-year-old (Feynman)

Imagine a landscape. You stand at the origin (the flat point) and a machine tells you how "high" the ground is a step away in any direction. A quadratic form is that machine: give it a direction arrow x\mathbf x, it returns a height. The matrix AA secretly stores how steeply the ground bends. If it bends up in every direction, you're at the bottom of a bowl (positive definite). If it bends up one way and down another, you're on a horse saddle (indefinite). The eigenvectors are the special "downhill/uphill" directions, and the eigenvalues say how sharply it bends there.


Recall flashcards

What is a quadratic form?
The scalar Q(x)=xAx=ijAijxixjQ(\mathbf x)=\mathbf x^\top A\mathbf x=\sum_{ij}A_{ij}x_ix_j, a degree-2 function of x\mathbf x.
Why can we always take AA symmetric?
The skew part contributes zero: xKx=0\mathbf x^\top K\mathbf x=0, so only 12(A+A)\tfrac12(A+A^\top) matters.
How do you read the matrix off ax12+bx1x2+cx22ax_1^2+bx_1x_2+cx_2^2?
A=[ab/2b/2c]A=\begin{bmatrix}a & b/2\\ b/2 & c\end{bmatrix} — halve the cross term.
Definition of positive definite?
xAx>0\mathbf x^\top A\mathbf x>0 for all x0\mathbf x\neq 0.
Eigenvalue test for definiteness?
In eigen-coords Q=λiyi2Q=\sum\lambda_i y_i^2; all λi>0\lambda_i>0 ⟺ positive definite; mixed signs ⟺ indefinite.
Sylvester's criterion (2×2)?
Positive definite ⟺ A11>0A_{11}>0 and detA>0\det A>0.
What does completing the square reveal?
A sum of weighted perfect squares; positive coefficients ⟺ positive definite (this is LDLLDL^\top).
Geometric meaning of eigenvectors of AA?
Principal axes of the quadratic surface; eigenvalues are curvatures along them.
Why is definiteness important in ML?
A positive-definite Hessian ⟹ convex bowl ⟹ unique minimum ⟹ well-behaved optimization.

Connections

  • Symmetric matrices — quadratic forms are defined by them.
  • Eigenvalues and eigenvectors — decide definiteness and give principal axes.
  • Spectral theorem — justifies the λiyi2\sum\lambda_i y_i^2 rewrite.
  • Positive definite matrices — the "bowl" case.
  • Convex optimization / Hessian matrix — second-order behaviour of loss functions.
  • PCA — maximizing xΣx\mathbf x^\top \Sigma\mathbf x under x=1\|\mathbf x\|=1 is a quadratic form problem.
  • Cholesky decomposition — algorithmic completing-the-square.

Concept Map

expands to

assumes

discards

contributes 0

derivation gives

reading rule

classified by

enables

substitute y=QTx

signs give

determines

measures

Quadratic form Q = xT A x

Double sum of degree-2 terms

Symmetric matrix A

Skew part K

Expand: a x1^2 + 2b x1x2 + c x2^2

Off-diagonal coefficient halved

Definiteness = shape of bowl

Spectral Theorem A = Q Lambda QT

Diagonalized sum lambda_i y_i^2

Eigenvalue sign test

Cost / energy in ML

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, quadratic form ka matlab simple hai: aap ek vector x\mathbf x lete ho aur usse xAx\mathbf x^\top A\mathbf x ke through ek single number nikaalte ho. Ye bilkul scalar ax2ax^2 ka bada bhai hai — bas ab ek matrix AA beech me baitha hai jo har direction me "curvature" store karta hai. Result hamesha degree-2 polynomial hota hai, jisme sirf xi2x_i^2 aur xixjx_ix_j type ke terms aate hain.

Ek important reading rule yaad rakho: agar polynomial me 6x1x26x_1x_2 likha hai, to matrix me A12A_{12} me 66 mat daalo — usko aadha karo, kyunki cross term do baar count hota hai (A12A_{12} aur A21A_{21} dono). Ye sabse common galti hai exam me.

Ab shape ki baat: symmetric matrix ke eigenvalues nikaalo. Rotate karke form ban jaata hai λiyi2\sum \lambda_i y_i^2. Agar saare eigenvalues positive hain to surface ek bowl (positive definite) hai — matlab ek unique minimum, gradient descent khush. Agar signs mixed hain to saddle (indefinite) — optimization phasti hai. ML me ye directly Hessian aur convexity se juda hai: positive definite Hessian = convex loss = clean minimum.

Yaad rakhne ka mantra: "Cross term aadha karo, phir axes ke signs check karo." Positive diagonal dekh ke mat fool ho jaana — off-diagonal bada ho to woh sab bigaad sakta hai, isliye hamesha eigenvalues ya leading minors (Sylvester) se confirm karo.

Go deeper — visual, from zero

Test yourself — Linear Algebra Essentials

Connections