# Does the gradient commute with the partial trace?

Suppose I have a parameterized quantum state: $$\rho(\theta) = U(\theta) \rho U^\dagger(\theta)$$. I am curious to know whether the following holds: $$\frac{\partial \text{Tr}_A (\rho(\theta))}{\partial \theta} = \text{Tr}_A \Big(\frac{\partial \rho(\theta)}{\partial \theta} \Big)$$, where $$\text{Tr}_A$$ is a partial trace over any subsystem of the original Hilbert space. Also, it would be wonderful if anyone can point me towards to relevant references.

In brief: it is because differentiation and (partial) traces are linear operations, so we can pull them through each other.

Physically, one might interpret this as the fact that it doesn't matter whether we consider taking the derivative of the reduced state ($$\partial(\mathrm{tr}_A(\rho(\theta)))/\partial\theta$$), or taking the reduced "state" of the derivative ($$\mathrm{tr}_A(\partial\rho(\theta)/\partial\theta)$$). I say "state" in quotes in the latter because the derivative of $$\rho(\theta)$$ is not a state itself, but nonetheless it is an operator whose partial trace we can evaluate.

In somewhat excessive detail, one can work out using the definitions of the partial derivative and partial trace to see that they indeed commute. Let $$\{|i\rangle_A\}_i$$ be an orthonormal basis on subsystem $$A$$ and $$B = A^\perp$$ be the rest of the system. The partial trace of $$\rho(\theta)$$ is

$$\mathrm{tr}_A(\rho(\theta)) = \sum_{i} (\langle i |_A \otimes \mathbb{I}_B) \rho(\theta) (|i \rangle_A \otimes \mathbb{I}_B).$$

The derivative of this object is (supposing $$\theta \in \mathbb{R}$$ is a single parameter for simplicity)

\begin{align} \frac{\partial}{\partial\theta} \mathrm{tr}_A(\rho(\theta)) &= \lim_{h \to 0} \left[ \frac{\sum_{i} (\langle i |_A \otimes \mathbb{I}_B) \rho(\theta + h) (|i \rangle_A \otimes \mathbb{I}_B) - \sum_{i} (\langle i |_A \otimes \mathbb{I}_B) \rho(\theta) (|i \rangle_A \otimes \mathbb{I}_B)}{h} \right]\\ &= \sum_{i} (\langle i |_A \otimes \mathbb{I}_B) \lim_{h \to 0} \left(\frac{\rho(\theta + h) - \rho(\theta)}{h}\right) (|i \rangle_A \otimes \mathbb{I}_B)\\ &= \sum_{i} (\langle i |_A \otimes \mathbb{I}_B) \frac{\partial \rho(\theta)}{\partial\theta} (|i \rangle_A \otimes \mathbb{I}_B)\\ &= \mathrm{tr}_A \left(\frac{\partial \rho(\theta)}{\partial\theta}\right). \end{align}

The argument for differentiating with respect to multiple parameters is completely analogous.

Partial traces are linear operations, so they commute with the derivative. You can express this as

$$Tr(\rho) = \sum_{a} \langle a| \rho |a\rangle$$

So

$$\frac{\partial Tr(\rho (\theta))}{\partial \theta} = \sum_{a} \langle a| \frac{\partial \rho (\theta)}{\partial \theta} |a\rangle,$$

assuming that the basis $$a$$ is independent of $$\theta$$.