Quadratic-Form Gradients
In q(x)=x^TAx, the input vector occurs on both sides of the fixed matrix.
On this page 7 sections
01The variable occurs twice#
In , the input vector occurs on both sides of the fixed matrix. Changing one coordinate can affect terms through either occurrence. The gradient must include both contributions.
Write . Differentiating with respect to collects the terms where and those where :
Those sums are the th entries of and .
02Use a nonsymmetric matrix#
Let have rows and . Then and . Adding gives the gradient .
Expanding gives . Its partial derivatives are and , again giving at .
A has rows (1,2),(0,3); x=(1,1). Find ∇(xᵀAx).
Show answer and explanation
A+Aᵀ has rows (2,2),(2,6); multiply by x.
03When the shorter rule works#
If , the two contributions match and the gradient becomes . Without symmetry, that shortcut can fail: in the worked example , which is incorrect.
For symmetric A, what is the gradient of xᵀAx/2?
Show answer and explanation
The factor one-half cancels the factor two.
A leading factor of one-half halves the gradient. Keep the fixed matrix and the differentiating variable explicit. This lesson computes the gradient; deciding whether the quadratic has a minimum requires additional structure.
Compute the gradient of xᵀAx as (A + Aᵀ)x for a constant real square matrix A.
- Compute the gradient of xᵀAx as (A + Aᵀ)x for a constant real square matrix A.
Sources & further reading
- [1]MIT 6.390, Appendix A: Matrix Calculus ↗introml.mit.edu · Article
- [2]Boyd and Vandenberghe, Introduction to Applied Linear Algebra ↗stanford.edu · Article