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?
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