1
$\begingroup$

Let $A$ be some matrix function of $x$, $A:\mathbb{R}^n \to \mathbb{R}^{n\times n}$.

My question is, is there some general formula for the gradient of

$$f(x) =\dfrac{1}{2} x^TA(x)x$$

I only know some special cases:

  • $A$ is a constant, symmetric matrix, then $\nabla f(x) = Ax$

    $A$ is a constant, assymmetric matrix, then $\nabla f(x) = \dfrac{1}{2} (A^T+A)x$

    $A$ is $\text{diag}(x)$, then $\nabla f(x) = \dfrac{3}{2} Ax$

I'm stuck because I don't understand how to find a simpler expression for the derivative $D[A(x)x]$, where,

\begin{align*} \nabla f(x) &= \nabla \dfrac{1}{2} x^TA(x)x\\ &= \nabla \dfrac{1}{2} x^Tg(x) \\ &= \dfrac{1}{2}A(x)x + \dfrac{1}{2}x^TD[A(x)x] \end{align*}

$\endgroup$
2
  • $\begingroup$ Hi .. So you're looking for a way to reduce the term $D[A(x)x]$ even more ? $\endgroup$ Commented Sep 9, 2018 at 3:30
  • $\begingroup$ Have you considered looking up rayleigh quotient. $\endgroup$
    – user3417
    Commented Sep 9, 2018 at 4:02

3 Answers 3

1
$\begingroup$

I assume you mean $A: \mathbb R^n \to \mathbb R^{n\times n}$ so that $A$ takes in a vector and gives a matrix. I'll operate under this assumption.

We see $$f(x) = \frac 1 2\sum_{i,j = 1}^n x_ix_jA_{ij}(x).$$ Now fix $k \in \{ 1,\ldots, n\}$, Then by the product rule $$\frac{\partial f }{\partial x_k}(x) = \frac{1}{2} \sum^n_{i,j=1} \left( x_ix_j\frac{\partial A_{ij}}{\partial x_k}(x) + \delta_{ik} x_j A_{ij}(x) + \delta_{jk} x_i A_{ij}(x)\right) $$ where $\delta_{ab} = \left\{\begin{smallmatrix} 1, & a = b, \\ 0, & a \neq b.\end{smallmatrix} \right.$ Resolving these $\delta$'s, we see $$\frac{\partial f }{\partial x_k}(x) = \frac{1}{2} \left(\sum^n_{i,j=1} x_ix_j\frac{\partial A_{ij}}{\partial x_k}(x) \right) + \frac 1 2 \left( \sum_{j=1}^n x_j A_{kj}(x)\right) + \frac 1 2\left( \sum^n_{i=1} x_i A_{ik}(x)\right).$$ Now the latter two terms turn into $\frac 1 2(A(x) + A^T(x))x$ when you put everything together. For the first term, you sort of need to invent notation (actually we'll use tensor notation), and what you have is $$\frac 1 2 x^T(\nabla \circ A)(x)x$$ where $\nabla \circ A: \mathbb R^n \to \mathbb R^{n\times n \times n}$ is given by $(\nabla \circ A)_{ijk}(x) = \frac{\partial A_{ij}}{\partial x_k}(x).$ Note that $x^T (\nabla\circ A)(x) x \in \mathbb R^n$ for any $x \in \mathbb R^n$ and by convention the inner products operate on the first two dimensions of $\nabla \circ A$. Then you can write $$\nabla f(x) = \frac 1 2 (x^T(\nabla\circ A)(x) x + A(x)x + A^T(x) x).$$

$\endgroup$
0
$\begingroup$

I am just going to write some stuff. Let $ A \in \mathbb{R}^{ n \times n} x \in \mathbb{R}^{n}$

$$ r(x) = \frac{x^{T}Ax}{x^{T}x} \in \mathbb{R} \tag{1}$$

is called the Rayleigh quotient. If $x$ is an eigenvector of $A$ then $Ax=\lambda x$

$$ r(x) = \frac{\lambda x^{T}x}{x^{T}x} = \lambda \tag{2}$$

you can show in general $ \lambda_{min} \leq r(x) \leq \lambda_{max}$

now then

$$\nabla r(x) = \frac{2}{x^{T}x}((Ax) -(r(x)x) \tag{3}$$

$r(x)$ is simply $\frac{2}{x^{T}x}$ times $f(x)$

$\endgroup$
2
  • $\begingroup$ What has this got to do with the question??? $\endgroup$
    – copper.hat
    Commented Sep 9, 2018 at 5:05
  • $\begingroup$ The expression appears to be the rayleigh quotient without the normalization. The article gives a simple expression for what he asked $\endgroup$
    – user3417
    Commented Sep 9, 2018 at 13:54
0
$\begingroup$

Consider that $$x^T A \,x = \sum_{i=1}^{n}\sum_{j=1}^n x_i a_{ij} \, x_j$$

where $x_i$ are the entries of $x$ and $a_{ij}$ are the entries of $A$.

Then all you need is to differentiate this expression with respect to any component $x_i$ to get the entries of the gradient (careful with the $i=j$ cases in the sum, and also with the fact that the entries of $A$ may depend on $x$.)

$\endgroup$
2
  • 1
    $\begingroup$ I think you meant to say "differentiate this expression with respect to any component $x_i$" and also OP should be careful that $a_{ij}$ is a function of all $x_i's$ $\endgroup$
    – Mark
    Commented Sep 9, 2018 at 5:37
  • $\begingroup$ Right! I meant $x_i$. As for the $a_{ij}$'s I believe the OP is aware that may depend on $x $ since it was him/herself who asked about this general case. Anyway, it's still a good reminder. I've edited my answer. $\endgroup$
    – Javi
    Commented Sep 9, 2018 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .