# Confusion on metric determinant derivative

Maybe it is a stupid confusion. I need to compute the derivative of the metric determinant with respect to the metric itself, i.e., $$\partial g/\partial g_{\mu\nu}$$, but I have an indices confusion in the final obtention of this expression. Recall the Jacobi's formula $$\det e^{B}=e^{tr B}$$, where $$B$$ is a matrix. Then, if $$e^B=A$$, we can write \begin{align} \det A=e^{tr \ln A}. \end{align} Applying logarithms to both sides, we have \begin{align} \ln \det A=tr \ln A. \end{align} Now, applying the partial derivative with respect to matrix $$A$$, we arrive to \begin{align} \frac{1}{\det A}\frac{\partial \det A}{\partial A}=tr\left(A^{-1}\right). \end{align} I think that at this point, everything is ok. Now, if we set $$A_{ \mu \nu}=g_{ \mu \nu}$$, where $$g_{\mu\nu}$$ is the metric of a certain spacetime, then we obtain \begin{align} \frac{1}{g}\frac{\partial g}{\partial g_{\mu\nu}}=tr(g^{\mu\nu}), \end{align} or, using the fact that the trace of the inverse matrix can be written in components as $$tr(g^{\mu\nu})=g_{\mu\nu}g^{\mu\nu}$$ (it is convenient for me to write the trace in components), \begin{align} \frac{\partial g}{\partial g_{\mu\nu}}=g g_{\mu\nu}g^{\mu\nu}. \end{align} On the left-hand side, we have $$\frac{\partial g}{\partial g_{\mu\nu}}$$, a tensor that depends on two contravariant indices, while on the right-hand side, we have no indices. I am confused. What I am doing wrong?

We have $$\ln \det A = \text{Tr} \ln A$$ When you take a derivative, we find $$\frac{1}{\det A} \frac{\partial \det A}{ \partial A_{ij} } = \frac{\partial }{ \partial A_{ij} } \text{Tr} \ln A = (A^{-1})^{ij}$$ Then, $$\frac{ \partial g}{ \partial g_{\mu\nu}} = g g^{\mu\nu}$$
• @SoniaLlambias Choose an eigenbasis of $A$ then $\operatorname{tr}\ln A=\sum_k \ln \lambda_{k}$. In this basis the matrix is diagonal with $\lambda_k = A_{kk}$, so $$\operatorname{tr}\ln A=\sum_k \ln A_{kk}.$$ It follows that $$\dfrac{\partial}{\partial A_{ij}}\operatorname{tr}\ln A = \sum_k \dfrac{1}{A_{kk}}\dfrac{\partial A_{kk}}{\partial A_{ij}}=\sum_k \dfrac{1}{A_{kk}} \delta_{ik}\delta_{kj} = \dfrac{1}{A_{ii}}\delta_{ij}.$$ In this basis we also have $(A^{-1})^{ij}= \frac{1}{A_{ii}}\delta_{ij}$, so the RHS is really $(A^{-1})^{ij}$ as we wanted to show.
Personally I think it's clearer when expressed in terms of variations (the first order variation is always the derivative, but for matrices the derivative can easily be missunderstood): let $$g^{\mu\nu} \to g^{\mu\nu} + \delta g^{\mu\nu}$$. Now use $$\ln \mathrm{det}\,M = \mathrm{tr}\ln M$$ and vary \begin{align*} \ln\det(g + \delta g) = \ln (\det(g) + \delta \det(g) + \mathcal{O}(\delta^2)) = \ln \det(g) + \frac{1}{\det(g)}\delta \det(g) + \mathcal{O}(\delta^2) \end{align*} and the RHS \begin{align*} \mathrm{tr}\ln(g + \delta g) = \mathrm{tr}\left[\ln(g) + \ln(1 + g^{-1}\delta g)\right] = \mathrm{tr}\ln(g) + \mathrm{tr}\left[g^{-1}\delta g + \mathcal{O}(\delta^2)\right] \end{align*} Comparing the terms at $$\mathcal{O}(\delta)$$ you find \begin{align*} \frac{1}{\det(g)}\delta \det(g) = \mathrm{tr}(g^{-1}\delta g) \end{align*} So for the differential of the determinant you get \begin{align*} \delta \det(g) = \det(g)\mathrm{tr}\left(g^{\mu\nu}\delta g_{\nu\sigma}\right) = \det(g) g^{\mu\nu}\delta g_{\nu\mu} \end{align*} Now you can basically read of the derivative \begin{align*} \frac{\partial \det(g)}{\partial g_{\mu\nu}} = \frac{\delta \det(g)}{\delta g_{\mu\nu}} = \det(g) g^{\mu\nu} \end{align*}
From here you can also find the derivative wrt. the inverse metric easily: to find the variation of the metric note that \begin{align*} \delta^{\alpha}_\beta = g^{\alpha\lambda}g_{\lambda\beta} \to g^{\alpha\lambda}g_{\lambda\beta} + g^{\alpha\lambda}\delta g_{\lambda \beta} + \delta g^{\alpha\lambda} g_{\lambda\beta} + \mathcal{O}(\delta g^2) \end{align*} so we require that \begin{align*} 0 &= g^{\alpha\lambda}\delta g_{\lambda\beta} + \delta g^{\alpha\lambda}g_{\lambda\beta} \\ g_{\gamma\alpha}g^{\alpha\lambda} \delta g_{\lambda\beta} &= - g_{\gamma\alpha} g_{\lambda\beta}\delta g^{\alpha\lambda} \\ \delta g_{\gamma\beta} &= - g_{\gamma\alpha} g_{\lambda\beta} \delta g^{\alpha\lambda} \end{align*} Now just plug this into the differential of the determinant to get \begin{align*} \frac{\partial \det(g)}{\partial g^{\mu\nu}} &= \frac{\delta \det(g)}{\delta g^{\mu\nu}} = \frac{1}{\delta g^{\mu\nu}} \det(g) g^{\alpha\beta}(-g_{\alpha\gamma}g_{\beta\delta} \delta g^{\gamma\delta}) = - \det(g) g_{\mu\nu} \end{align*}