What are for a square matrix and , and how do you derive them?
Linear algebra and optimisation, Matrix calculus
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can differentiate vector expressions reliably, including when is not symmetric.
Key idea
Write the scalar out with indices, , and differentiate one coordinate at a time. You get , which equals only when is symmetric.
Steps
- Write and differentiate with respect to one coordinate . The terms with give , and the terms with give .
- Collect the coordinates into a vector: . Check with one dimension: has derivative .
- Expand the second expression: .
- Differentiate term by term. is symmetric, so the first term gives ; and gives . So .
- Mention the use. Setting this to zero gives the normal equations of least squares. The Hessian (matrix of second derivatives) is , which is PSD (positive semidefinite), so least squares is convex.
Common mistakes
- Writing when is not symmetric.
- Writing . Check the sizes: the gradient must be the same size as , which needs .
- Switching between layout conventions (gradient as a row or as a column) halfway through.
How long your answer should be
5–6 lines of derivation; 2–3 minutes.
Read this
Previous in Linear algebra and optimisation: How do you show that the negative log-likelihood of logistic regression is convex in the weights ?
Next in Linear algebra and optimisation: Which of these functions are convex, and why: (a) ; (b) ; (c) on ; (d) ; (e) the hinge loss as a function of ?