Matrix calculus: change of variable Suppose we have a matrix $M_{ij}^{n\times n}$ (symmetric and invertible) and a function of the matrix elements $f(M_{ij})$ (the function is analytic). Now we want to study the derivatives of $f(M_{ij})$.
Let us do a change of variable to separate the determinant part and the rest, define
$m =\det M, \quad h_{ij} =\frac{ M_{ij} }{(\det M)^{1/n}}$ 
$m, h_{ij}$ should contain the same number of independent variables as  $M_{ij}$, therefore 
$\frac{\partial f}{\partial M_{ij}} = \frac{\partial f}{\partial m} \frac{\partial m}{\partial M_{ij}} + \frac{\partial f}{\partial h_{kl}} \frac{\partial  h_{kl}}{\partial M_{ij}} $
where repeated indices are summed over. However, it is confusing since $h_{ij}$ is symmetric, should I really sum over all the indices in the second term?
Later on, I encounter something like $ \delta_{kl}\frac{\partial f}{\partial(\ln h)_{kl}} $. Since $\det h =1$, $\delta_{kl}(\ln h)_{kl} = \ln \det h =0$, what does it imply for $ \delta_{kl}\frac{\partial f}{\partial(\ln h)_{kl}}$?
Thanks in advance!
 A: Since you don't tell us anything about the function $f$, I'll assume that you already know how to calculate $\Big\{\frac{\partial f}{\partial m}, \frac{\partial f}{\partial h}\Big\}$ and want to to be able to use them to calculate $\frac{\partial f}{\partial M}$ 
Let's start with the differentials of your two main variables
$$\eqalign{
  m &= \det M \cr
 dm &= d\det M = m M^{-T}:dM \cr\cr
  h &= \frac{M}{m^{1/n}} \cr
 dh &= \frac{dM}{m^{1/n}} - \frac{h\,dm}{nm} \cr
    &= \Big(\frac{\mathbb E}{m^{1/n}} - \frac{h\star M^{-T}}{n}\Big):dM \cr
}$$
where
$(\star)$ represents the dyadic (aka tensor) product,
$(:)$ represents the Frobenius product, e.g. $\,\,A:B=\operatorname{tr}(A^TB),\,\,$and 
${\mathbb E}$ is the 4th-order tensor which acts as an identity element for the Frobenius product.
Now find the differential and gradient of the function itself
$$\eqalign{
 df &= \frac{\partial f}{\partial h}:dh+\frac{\partial f}{\partial m}\,dm\cr
  &= \frac{\partial f}{\partial h}:\Big(\frac{\mathbb E}{m^{1/n}} - \frac{h\star M^{-T}}{n}\Big):dM+m\frac{\partial f}{\partial m}\,M^{-T}:dM \cr\cr
\frac{\partial f}{\partial M} &= \frac{\partial f}{\partial h}:\Big(\frac{\mathbb E}{m^{1/n}} - \frac{h\star M^{-T}}{n}\Big) + m\frac{\partial f}{\partial m}\,M^{-T} \cr
   &= \frac{1}{m^{1/n}}\frac{\partial f}{\partial h} - \Big(\frac{h}{n}:\frac{\partial f}{\partial h}\Big)M^{-T} + m\frac{\partial f}{\partial m}\,M^{-T} \cr
   &= \Bigg(\frac{1}{m^{1/n}}\Bigg)\frac{\partial f}{\partial h} \,+\, \Bigg(m\frac{\partial f}{\partial m} - \frac{h}{n}:\frac{\partial f}{\partial h}\Bigg)\,M^{-T} \cr
\cr
}$$
Finally, after all of this hard work, you want to constrain $M$ to be symmetric. 
So first define the function
$$\eqalign{
\operatorname{csym}(X) &= X+X^T-I\odot X \cr
}$$where
$(\odot)$ represents the Hadamard (aka elementwise) product and $I$ is the identity matrix.
Then the constrained gradient is given by
$$\eqalign{
 G &= \operatorname{csym}\Big(\frac{\partial f}{\partial M}\Big) \cr
}$$
