[Math] Derivative of diagonal matrix with respect to vector composed of some elements of the diagonal

linear algebramatricesmatrix-calculus

Let $n\times1$ vector $\vec{a}$ and $A=\mathrm diag(a)$. Let $\vec{a}_i$ $k\times 1$ subvector of $\vec{a}$ ($k<n$), given by the relation $\vec{a}=K\vec{a}_i$, where $K$ is an $n\times k$ matrix ($n,k\in\mathbb{N}$). I would like to compute the derivative $\dfrac{dA}{d\vec{a}_i}$.

Best Answer

There are too many $A$'s in this question for my taste, so allow me to denote the subvector as $x$. Then we have $$ A = {\rm Diag}(Kx) $$ the differential of which is $$ dA = {\rm Diag}(K\,dx) $$ The derivative will be a $3^{rd}$ order tensor, so let's look at the derivative with respect to the $j^{th}$ component of $x$, which is merely a matrix $$\eqalign{ dA &= {\rm Diag}(Ke_j)\,dx_j \cr &= {\rm Diag}(k_j)\,dx_j \cr \frac{\partial A}{\partial x_j} &= {\rm Diag}(k_j) \cr }$$ where $k_j$ is the $j^{th}$ column of $K$.