# Partial trace and SWAP in the basis of subsystems

I'm trying to derive equation $$(1)$$ on p.2 in Lloyd et al, 2013 which reads

$$\text{Tr}_A\left[\exp(-i\theta S_{AB}) (\rho_A \otimes \sigma_B) \exp(i\theta S_{AB}) \right] = (\cos^2 \theta) \sigma_B + (\sin^2 \theta) \rho_B - i \sin \theta [\rho_B, \sigma_B]$$

where $$S_{AB}$$ is a swap operator for the two systems. My approach so far is to write the operator as $$\exp(i\theta S_{AB}) = \begin{pmatrix} e^{i\theta} & 0 & 0 & 0 \\ 0 & \cos \theta & i \sin\theta & 0 \\ 0 & i \sin \theta & \cos \theta & 0 \\ 0 & 0 & 0 & e^{i\theta} \end{pmatrix} \begin{matrix} \leftarrow\rho_A \otimes \rho_B \\ \leftarrow\rho_A \otimes \sigma_B\\ \leftarrow\sigma_A \otimes \rho_B \\ \leftarrow\sigma_A\otimes \sigma_B \end{matrix}$$

where the labels describe how each input is affected by this operation if the possible state configurations are represented as a column vector, e.g. $$\rho\otimes \sigma \sim \hat{e}_1$$ would become $$\cos\theta (\rho\otimes \sigma) + \sin \theta (\sigma \otimes \rho) \sim \cos\theta \hat{e}_1 + \sin \theta \hat{e}_2$$.

However, I haven't been able to carry out the calculation since I'm unsure how to apply the operator or partial trace on $$(\rho\otimes \sigma)$$ when I set up operators like this. Is there anything pathological about this representation of a SWAP, and if so what is the right approach to deriving the above equation?

For any $$\theta\in\mathbb{R}$$ and any operator $$T$$ such that $$T^2=I$$ we have

$$\exp(i\theta T) = I\cos\theta + i T\sin\theta$$

(c.f. exercise 4.2 on p.175 in Nielsen & Chuang). Therefore,

$$\exp(i\theta S_{AB}) = I \cos\theta + i S_{AB} \sin\theta$$

and we have

$$\exp(-i\theta S_{AB}) (\rho_A \otimes \sigma_B) \exp(i\theta S_{AB}) = \\ \rho_A\otimes\sigma_B \cos^2\theta - i S_{AB} \rho_A\otimes\sigma_B \cos\theta\sin\theta + \\ + i \rho_A\otimes\sigma_B S_{AB} \cos\theta\sin\theta + \sigma_A\otimes\rho_B \sin^2\theta.\tag1$$

By definition

$$\mathrm{tr}_A(\rho_A\otimes\sigma_B) = \sigma_B \\ \mathrm{tr}_A(\sigma_A\otimes\rho_B) = \rho_B.\tag2$$

The partial trace of $$S_{AB}\rho_A\otimes\sigma_B$$ is represented by the tensor network

which shows that

$$\mathrm{tr}_A(S_{AB}\rho_A\otimes\sigma_B) = \rho_B\sigma_B.\tag{3a}$$

Similarly,

$$\mathrm{tr}_A(\rho_A\otimes\sigma_BS_{AB}) = \sigma_B\rho_B.\tag{3b}$$

Finally, tracing over $$A$$ in $$(1)$$ and substituting $$(2)$$, $$(3a)$$ and $$(3b)$$, we get

$$\mathrm{tr}_A\left[\exp(-i\theta S_{AB}) (\rho_A \otimes \sigma_B) \exp(i\theta S_{AB})\right] = \\ \sigma_B\cos^2\theta + \rho_B\sin^2\theta - i\rho_B\sigma_B\cos\theta\sin\theta + i\sigma_B\rho_B\cos\theta\sin\theta = \\ \sigma_B\cos^2\theta + \rho_B\sin^2\theta - i[\rho_B, \sigma_B]\cos\theta\sin\theta.\tag4$$

This result differs from the paper. I think the formula in the paper contains a mistake. Set $$\theta=\frac{\pi}{2}$$. In this case

$$\exp\left(-\frac{i\pi S_{AB}}{2}\right) (\rho_A \otimes \sigma_B) \exp\left(\frac{i\pi S_{AB}}{2}\right) = S_{AB} (\rho_A \otimes \sigma_B) S_{AB} = \sigma_A \otimes \rho_B$$

and the partial trace over $$A$$ yields $$\rho_B$$. This special case agrees with $$(4)$$ and disagrees with the formula in the paper since the latter preserves the term with the commutator when $$\theta=\frac{\pi}{2}$$.

Using the fact $$e^{i\theta S} = \text{cos}(\theta) \cdot I + i \cdot \text{sin}(\theta) \cdot S$$, we calculate

\begin{align*} e^{-i\theta S} (\rho \otimes \sigma) e^{i\theta S} & = (\text{cos}(\theta) \cdot I - i \cdot \text{sin}(\theta) \cdot S) \big(\rho \otimes \sigma \big) (\text{cos}(\theta) \cdot I + i \cdot \text{sin}(\theta) \cdot S) \\ & = \text{cos}^2(\theta) (\rho \otimes \sigma) + \text{sin}^2(\theta) (\sigma \otimes \rho) - i \text{sin}(\theta) \text{cos}(\theta) \cdot \big( S(\rho \otimes \sigma) - (\rho \otimes \sigma)S \big) \end{align*}

Now we need only to calculate $$\text{Tr}_A S(\rho \otimes \sigma)$$.

Let $$\rho = \sum_i p_i |x_i \rangle \langle x_i|$$ and $$\sigma = \sum_i q_i |y_i \rangle \langle y_i|$$.

\begin{align*} \text{Tr}_A S(\rho \otimes \sigma) &= \sum_{i,j} p_i q_j \text{Tr}_A [S \big(|x_i y_j \rangle \langle x_i y_j| \big)] \\ &= \sum_{i,j} p_i q_j \text{Tr}_A [\big(|y_j x_i \rangle \langle x_i y_j| \big)]\\ &= \sum_{i,j} p_i q_j \langle x_i | y_j \rangle \cdot|x_i \rangle \langle y_j| = \rho\sigma \end{align*} A similar calculation shows that $$\text{Tr}_A (\rho \otimes \sigma)S = \sigma \rho$$.

Finally: $$\text{Tr}_A e^{-i\theta S} (\rho \otimes \sigma) e^{i\theta S} = \text{cos}^2(\theta) \sigma + \text{sin}^2(\theta) \rho - i \frac{\text{sin}(2\theta)}{2} \cdot [\rho, \sigma]$$