Derivative of inverse of matrix-vector product

inverselinear algebramatricesmatrix-calculus

I need the derivative of the following

$$ \Biggl\| \frac{\mathbf{1}^{T}(M – M_0) }{\mathbf{1}^{T}M}\Biggr\|_2^2 $$

w.r.t. the matrix $M \in \mathbb{R}^{B \times N}$ where $\mathbf{1}^{B \times 1}$ is a column vector of ones and $M_0$ is a constant of the same dimension as $M$.

Best Answer

For convenience, define the ${\tt1}\in{\mathbb R}^B$ all-ones vector and the following ${\mathbb R}^N$ vectors $$\eqalign{ a &= M^T{\tt1},\quad b = M_0^T{\tt1},\quad c = \frac{a-b}{a}= ({\tt1}-b\oslash a) \\ w &= 2\,c\odot b\oslash a\oslash a \\ }$$ and the associated diagonal matrices $$\eqalign{ A &= {\rm Diag}(a),\quad B= {\rm Diag}(b),\quad C= {\rm Diag}(c)= (I-BA^{-1}) \\ W &= 2BCA^{-2}\\ dC &= -B\,dA^{-1}= BA^{-2}dA \\ }$$

Then the function of interest can be written as $$\eqalign{ \phi &= \|c\|^2 \\&= C:C \\ d\phi &= 2C:dC \\ &= 2C:BA^{-2}dA \\ &= W:dA \\ &= w:da \\ &= w : dM^T{\tt1} \\ &= {\tt1}w^T : dM \\ \frac{\partial\phi}{\partial M} &= {\tt1}w^T \\ \\ }$$ In the above, the symbol $(\odot)$ denotes elementwise multiplication, $(\oslash)$ denotes elementwise division, and $(:)$ represents the trace/Frobenius product, i.e. $$A:B = {\rm Tr}(A^TB)$$ Note that the $\{A,B,C,W\}$ matrices are diagonal and therefore they commute with each other, while the $M$ matrix is rectangular and does not commute with anything.

Related Question