Let A be a $d\times m$ matrix with $d \leq m$ and $b \in \mathbb{R}$, i have the following function $f$ $$\eqalignno{ &\mathop{\max}_{A,b}f(A,b)= {\lambda\over \Vert S+D\Vert} (\mathop{\sum}_{p\in S}\log(QCS(X_{p},Y_{p}))+\cr &\qquad\qquad\qquad\qquad\quad\mathop{\sum}_{n\in D}\log (1-QCS(X_{n},Y_{n})))-(1-\lambda)Tr(M)},$$ where $QCS(X,Y)=\displaystyle\frac{1}{1+e^{-(b-dist_{a}(X,Y))}}$, $X$ and $Y$ are $1\times m$ vectors and $$ dist (X, Y)_{A}= dist(\widehat{X},\widehat{Y})= \sum\limits_{i=1}^{d} {(\widehat{x_{i}}-\widehat{y_{i}})^{2} \over \widehat{x_{i}}+\widehat{y_{i}}}= \sum\limits_{i=1}^{d} {(A_{i}X-A_{i}Y)^{2}\over A_{i}X+A_{i}Y}$$
I Must find the gradient of $f$ so by this i must take the derivatve of $f$ regards to $A$, i was traying to use the chain and sum rules for derivatives in vector spaces but then i got to a place where i must obtain the derivative of $dist_{A}$ regards to $A$ and thats where i got caught
For convenience, let's use $$\eqalign{ m &= X - Y \cr p &= X + Y \cr }$$ to write the function in a form which makes its $A$-dependence very clear $$\eqalign{ \phi &= dist(X,Y)_A \cr &= Am\odot Am : \frac{1}{Ap}\cr }$$ In that last expression,
$\odot$ denotes the elementwise/Hadamard product,
$\frac{a}{b}$ represents elementwise/Hadamard division, and
: denotes the trace/Frobenius product, i.e. $\,\,A:B={\rm tr}(A^TB)$.
Calculate the differential, then the gradient $$\eqalign{ d\phi &= 2Am\odot d(Am) : \frac{1}{Ap} - Am\odot Am : \frac{d(Ap)}{Ap\odot Ap} \cr &= \frac{2Am}{Ap}:dA\,m - \frac{Am\odot Am}{Ap\odot Ap}:dA\,p \cr &= \frac{2Am}{Ap}:dA\,m - \frac{Am\odot Am}{Ap\odot Ap}:dA\,p \cr &= \Big(\frac{2Am}{Ap}\,m^T - \frac{Am\odot Am}{Ap\odot Ap}\,p^T\Big):dA \cr \cr \frac{\partial\phi}{\partial A} &= 2\Big(\frac{Am}{Ap}\Big)\,m^T - \Big(\frac{Am\odot Am}{Ap\odot Ap}\Big)\,p^T \cr\cr }$$ Denoting the vector common to each expression as $$r=\frac{Am}{Ap}$$ allows the result to be written more succinctly
$$\eqalign{ \frac{\partial\phi}{\partial A} &= (r+r)\,m^T - (r\odot r)\,p^T \cr\cr }$$