Skip to content
Glacius
Linear algebraConcept reference

Quadratic forms

A quadratic form takes a vector x, transforms it with a square matrix A, and dots the result with x.

On this page 7 sections
  1. Overview
  2. A vector becomes a scalar cost
  3. Transform, then dot
  4. Inspect the result
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01A vector becomes a scalar cost#

A quadratic form takes a vector xx, transforms it with a square matrix AA, and dots the result with xx. Its value is a scalar. Quadratic forms describe costs that depend on how coordinates interact.

q(x)=xTAx.q(x)=x^TAx.

For an nn-entry column vector, the shapes are (1×n)(n×n)(n×1)(1\times n)(n\times n)(n\times1). The final shape is 1×11\times1. Computing AxAx first makes the two operations clear.

02Transform, then dot#

Let AA have rows (2,1),(1,3)(2,1),(1,3) and let x=(1,2)x=(1,2). The matrix-vector product is Ax=(4,7)Ax=(4,7). Dotting with xx gives 1(4)+2(7)=181(4)+2(7)=18.

Expanding directly gives the same result: 2x12+x1x2+x2x1+3x222x_1^2+x_1x_2+x_2x_1+3x_2^2. Both off-diagonal entries contribute. Counting just the diagonal would miss the cross-coordinate terms.

Check your reasoning

A is diagonal with entries (2,3), and x=(1,2). Find xᵀAx.

  1. A14
  2. B8
  3. C(2,6)
Show answer and explanation
14

Ax=(2,6), then x dot Ax=2+12=14.

03Inspect the result#

A scalar result need not be positive. If AA has diagonal entries 1,11,-1 and all other entries zero, then x=(0,2)x=(0,2) gives q(x)=4q(x)=-4. Classifying matrices whose forms are always nonnegative comes later.

If you replace xx by cxcx, the form is multiplied by c2c^2: the scale appears in each copy of the vector. Negating the whole vector therefore leaves the value unchanged.

Check your reasoning

For a square matrix A and column vector x, what type of result is xᵀAx?

  1. AA vector shaped like x
  2. BA scalar
  3. CA matrix shaped like A
Show answer and explanation
A scalar

The product shapes reduce to one by one.

Keep the intermediate vector AxAx separate from the final scalar xTAxx^TAx. This distinction also matters when differentiating the form: a scalar function can have a vector gradient.

Key takeaway

Evaluate a quadratic form on a supplied vector.

  • Evaluate a quadratic form on a supplied vector.

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Quadratic forms.” Math behind ML. /learn/la-quadratic