1

What is the derivative of $f: \mathbb R^n \to \mathbb R, f(x) = x^\top A x$, where $A$ is an $n \times n$ real matrix?

My answer is below. Is it correct? And is there a simpler way to derive this (one that doesn't need to use sums over indexes)?


Notation: $\sum_i$ means $\sum_{1 \leq i \leq n}$.

$$\begin{align*}f(x) &= x^\top A x \\ &= \sum_i x_i [Ax]_i \\ &= \sum_i x_i [\sum_j A_{ij} x_j] \\ &= \sum_{i,j} A_{ij} x_i x_j. \\ \end{align*}$$

Therefore $$[Df(x)]_k = \sum_{i,j}A_{ij}d_{ij}(x_i, x_j)$$ where $$d_{ij}(u,v) = \begin{cases} 0 & \text{if } i \neq k, j \neq k \\ v & \text{if } i = k, j \neq k \\ u & \text{if } i \neq k, j = k \\ u + v & \text{if } i = k, j = k. \\ \end{cases}$$ Simplifying, we get $$\begin{align*}[Df(x)]_k &= \sum_i[A_{ik} + A_{ki}]x_i\\ Df(x) &= (A + A^\top)x.\end{align*}$$

SRobertJames
  • 6,117
  • 1
  • 12
  • 40
  • You can expand $f(x + \Delta x)$, omit the quadratic term (tiny, negligible), then compare with $f(x + \Delta x) \approx f(x) + f’(x) \Delta x$ to discover the formula for $f’(x)$. (This is often a nice way to compute derivatives in multivariable calculus.) – littleO Jun 30 '23 at 00:45
  • 1
    Does this answer your question? derivative with respect to a vector/matrix - found using an Approach0 search. Note this answer there uses a similar approach to yours, with the other answer using a fairy different one. FYI, there are also related questions, e.g., Hessian matrix of a quadratic form. – John Omielan Jun 30 '23 at 00:46
  • @JohnOmielan Thank you for finding that reference. Is my approach correct? That is, in addition to knowing the answer, I'd like to know if my proof is correct. – SRobertJames Jun 30 '23 at 02:22
  • @JohnOmielan What I'm most unsure of is the use (and switching around) of indexes, which gets tricky and hard to verify. – SRobertJames Jun 30 '23 at 02:44
  • @SRobertJames What you did there looks fine to me, but perhaps somebody else, especially if they are more experienced and knowledgeable, can also confirm that for you. Since you got the correct answer, it usually indicates (but, of course, not always!) that you didn't make any mistakes. – John Omielan Jun 30 '23 at 02:49
  • 1
    Please search the site. Asked at https://math.stackexchange.com/q/312077/321264, https://math.stackexchange.com/q/189434/321264 – StubbornAtom Jun 30 '23 at 07:08

0 Answers0