1

There was a similar post 1 day ago, can find him anymore, but there was no answer so far.

I have some problems to find the correct second derivative of $f(x) = \frac{x^TDx}{a^2 + x^TDx}$, while $D \in \mathbb{R}^{n \times n}$ is a diagonal matrix, $a\in \mathbb{R}$ and $x \in \mathbb{R}^n$

The first derivative should look like this -if I did not miss something-:

$\nabla f(x) = \frac{2x^TD \cdot (a^2 + x^TDx) - x^TDx \cdot 2x^TD}{(a^2 + x^TDx)^2} = \frac{2x^TD \cdot a^2}{(a^2 + x^TDx)^2}$

and the second like this

$\begin{align*} \nabla^2 f(x) &= \frac{2Da^2 \cdot (a^2 + x^TDx)^2 - 2x^TDa^2 \cdot 2(a^2 + x^TDx) 2x^TD}{(a^2 + x^TDx)^4} \\ &= \frac{2a^2D \cdot (a^2 + x^TDx) - 8a^2x^TDx^TD}{(a^2 + x^TDx)^3} \\ &= \frac{2a^4D + 2a^2D \cdot x^TDx) - 8a^2x^TDx^TD}{(a^2 + x^TDx)^3}. \end{align*}$

But if you take a look at $2a^2D \cdot x^TDx$ especially $D \cdot x^TDx$ in the numerator, then we have $D$ with dimension $ n \times n$ multiplied with $x^T$ with dimension $1 \times n$ and this cannot be. The question would be now, where is the mistake in my calculation?

  • @Digitallis Thx for you answer. I think it depends on the convention ? (https://math.stackexchange.com/questions/485351/matrix-differentiation-of-xtax or https://math.stackexchange.com/questions/312077/differentiate-fx-xtax)

    Seems like everyone has its own solution, that's why I'm so confused about the topic of derive functions with matrices and vectors.

    – Frederick Oct 29 '21 at 20:36
  • Ho ! I've made a mistake :/ I failed to notice the fact that the matrix $D$ is diagonal. This means that $D$ is symetric so we have $D = D^T$ so the the partial derivate with respect to $x_k$ will be the $k-$th component $2Dx$. Notice that it is also the $k$-th component of $2x^TD$ (again by symmetry). Notice that $2Dx$ is a column vector while while $2x^TD$ is a line vector. So depending on if you consider $\nabla f(x)$ to be a line or column vector (which is matter of convention) you should choose one or the other.. – Digitallis Oct 30 '21 at 00:23
  • @Digitallis This helps my understanding very much, thank you. But the real question is, how does the second derivative look like? – Frederick Oct 30 '21 at 10:37
  • How do you define "derivative"? Because what you are doing doesn't agree with the usual interpretation of the term. And you seem to be applying one-variable differentiation rules, which make little sense in n your setting. – Martin Argerami Oct 30 '21 at 13:09
  • @MartinArgerami That's a good question. My prof said we should derive the function f two times. – Frederick Oct 30 '21 at 13:23
  • Like I said, it's hard to comment when you don't say what "derivative" is supposed to mean. I haven't seen a definition of derivative for a function $f:\mathbb R^n\to\mathbb R$ that produces a function $\mathbb R^n\to\mathbb R^n$. Usually, the derivative is, at every point, a linear map. – Martin Argerami Oct 30 '21 at 13:30

0 Answers0