If I have this formula in a project: $(\mathbf{A}\mathbf{B}\mathbf{C})_r^T(\mathbf{A}_i\mathbf{B})^T$,
where $\mathbf{A}\in\mathbb{R}^{N\times N}$, $\mathbf{B}\in\mathbb{R}^{N\times N}$,$\mathbf{C}\in\mathbb{R}^{N\times R}$, $\mathbf{A}_i\in\mathbb{R}^{1\times N}$ means the $i$-th row of $\mathbf{A}$, $(\mathbf{A}\mathbf{B}\mathbf{C})_r$ means the $r$-th column of $\mathbf{A}\mathbf{B}\mathbf{C}$.
I want to calculate the derivation respect to $\mathbf{A}_i$. How can I solve it?
Let $\{e_k\}$ denote the standard basis vectors and define the variables $$\eqalign{ \def\p{F_{ri}} \def\Sk{\sum_{k=1}^n\:} \def\LR#1{\left(#1\right)} \def\grad#1#2{\frac{\partial #1}{\partial #2}} \def\op#1{\operatorname{#1}} \def\trace#1{\op{Tr}\LR{#1}} \def\frob#1{\left\| #1 \right\|_F} X &= A^T \\ x_i &= Xe_i \,\equiv\, A_i^T \\ }$$ and use a colon to denote the Frobenius product $$\eqalign{ X:Y &= \sum_{i=1}^m\sum_{j=1}^n X_{ij}Y_{ij} \;=\; \trace{X^TY} \\ X:X &= \frob{X}^2 \qquad \{ {\rm Frobenius\;norm} \}\\ X:Y &= Y:X \;=\; Y^T:X^T \\ \LR{XY}:Z &= X:\LR{ZY^T} \;=\; Y:\LR{X^TZ} \\ }$$ You want the gradient of the following scalar function $$\eqalign{ \p &= \LR{ABCe_r}^T \LR{B^TA^Te_i} \\ &= e_r^T\LR{C^TB^TA^TB^TA^T}e_i \\ &= \LR{e_re_i^T}:\LR{C^TB^TA^TB^TA^T} \\ &= \LR{e_re_i^T}:\LR{C^TB^TXB^TX} \\ &= \LR{BCe_re_i^T}:\LR{XB^TX} \\ }$$ First calculate the differential and the gradient wrt $X$ $$\eqalign{ d\p &= \LR{BCe_re_i^T}:\LR{XB^TdX+dX\,B^TX} \\ &= \LR{BX^TBCe_re_i^T + BCe_re_i^TX^TB}:dX \\ &= \LR{BABCe_re_i^T + BCe_re_i^TAB}:dX \\ \grad{\p}{X} &= \LR{BABCe_re_i^T + BCe_re_i^TAB} \;\equiv\; G \\ }$$ Then the gradient wrt $x_k\,$ is $\;{\large\grad{\p}{x_k}} = Ge_k$
Note that $\p$ is the $(r,i)$ component of the matrix $$ F = C^TB^TA^TB^TA^T $$