# Dimension reduction to subsystem in Pauli-Liouville basis: How to implement partial trace of Pauli-Transfer Matrices?

I have a complementary question to my previous (thankfully answered, but I can't verify for larger systems) question: Multi-qubit quantum channels in Pauli-Liouville basis: Tensor product of Pauli-Transfer Matrices?

How can we represent the partial trace operation, to project into the lower dimension of the subystem, in Pauli-Liouville representation (aka Pauli-Transfer Matrices)? And, how can we code it up (say in Python)?

Let's say we have the $$n$$ qubit Pauli-Liouville basis set given as $$B_{PL} = \left\{I/\sqrt{2}, X/\sqrt{2},Y/\sqrt{2},Z/\sqrt{2} \right\}^{\otimes n}$$. Also, let's say we use a standard quaternary convention (base 4 numbers) to enumerate these bases. e.g., For a 2 qubit system of parties $$A$$ and $$B$$ the first basis $$P_0^{AB}=0.5I^A\otimes I^B$$, can be denoted as $$\tilde{P}_0^A = \tilde{P}_0^B I/\sqrt{2}$$. Similarly the second basis $$P_1^{AB}=0.5I^A\otimes X^B$$, can be denoted as $$\tilde{P}_0^A = I/\sqrt{2}$$, and $$\tilde{P}_0^B X/\sqrt{2}$$, and so on. In this PL basis we expand our density matrix in this complete, orthonormal basis set by projecting via Hilbert-Schmidt norm, $$\langle{A}|B\rangle{} = \text{Tr}\left[A^{\dagger}B\right]$$, such that expansion looks like the following.

$$\rho = \sum_i c_i P_i \;\;\; \rightarrow \;\;\; c_i = \text{Tr}\left[\rho P_i\right]$$

Because of this summation notation, we can vectorize our density operator in real numbers as $$||\rho\rangle\rangle_i = c_i$$. Here $$c_i \in \mathcal{R}^{2n \times 1}$$. For example, a single qubit ground state $$\rho_{GS}=|0\rangle\langle{0}|=(1/\sqrt{2})I/\sqrt{2} + (1/\sqrt{2})Z/\sqrt{2}$$ such that the PL vectorized form is the column vector $$||\rho\rangle\rangle_{GS} = [1/\sqrt{2},0,0,1/\sqrt{2}]^T$$. Since (partial)trace is a linear operation, we could apply to each constituent Pauli-string term $$P_i$$ in the sum.

$$\rho_B = \text{Tr}_B\left(\rho\right) = \sum_i c_i \text{Tr}_A\left(P_i\right)$$

For the two-qubit case, we can dig deeper to get an intuition. As expressed in the answer to my previous question, if we denote the (quaternary notation) Pauli-string index with a double-index (for each qubit) as $$i = i_1 i_2$$. such that $$i=0 \leftarrow i_1=0,\; i_2 =0$$, $$i=1\leftarrow 01$$ and so on, we can write each Pauli-string term as $$P_i^{AB} = P_{i_1}\otimes P_{i_2}$$. In this case, we can write the sum above as the following as the partial trace turns to a normal trace for the $$A$$ subsystem Pauli-strings because this is the partial-trace of a tensor-product.

$$\rho_B = \sum_{i_1i_2}c_{i_1i_2}\text{Tr}\left(P_{i_1}\right)P_{i_2}=\sqrt{2}\sum_{i_1=0,i_2}c_{i_1i_2}P_{i_2} = \sqrt{2}\sum_{i < 4 }c_i P_i$$

Here the trace operation "killed" (zeroed) $$P_{i_1}$$ elements that are not identity (i.e., $$i_1 \neq 0$$ in the standard quaternary notation) because the trace of each Pauli matrix is zero, $$0=\text{Tr}\left(P_{i_1}\right)|_{i_1 \neq 0}$$, and the $$\sqrt{2}$$ on the front is coming from $$\sqrt{2}=\text{Tr}\left(P_{i_1}\right)|_{i_1 =0}=\text{Tr}\left(I\right)/\sqrt{2}$$. This means that when we trace out the qubit $$A$$ only the first four elements related to the partial-trace of the elements with indices $$i=0 \leftarrow 00$$, $$i=1 \leftarrow 01$$, $$i=2 \leftarrow 02$$, $$i=3 \leftarrow 03$$ survive with an extra multiplicative factor $$\sqrt{2}$$. Similarly, tracing out the subsystem B should also correspond to reducing the vector in $$PL$$ basis with respect to the demarcation points in Pauli-string enumeration convention, and multiplying with a factor. $$\rho_A = \sqrt{2}\sum_{i_1,i_2=0}c_{i_1i_2}P_{i_1i_2}=\sqrt{2}\sum_{i \in \text{Demarcation}=[0,4,8,12]} c_i P_i$$

For example, the density operator for two uncorrelated qubits that were initialized in the ground state is given as $$\rho_{AB}=\rho_{GS}^{A}\otimes\rho_{GS}^B = |0\rangle_A\langle{0}_A|\otimes |0\rangle_B\langle{0}_B|$$. The combined system and its partial-traces verifies this fact.

\begin{align*} ||\rho\rangle\rangle^{AB} &= ||\rho\rangle\rangle_{GS}\otimes||\rho\rangle\rangle_{GS} \\ &=[1/\sqrt{2},0,0,1/\sqrt{2}]^T\otimes[1/\sqrt{2},0,0,1/\sqrt{2}]^T \\ &=[1/2,0,0,1/2,0,\dots,0,1/2,0,0,1/2]^T \end{align*}

And, going back to the original state, the Pauli-Liouville version of the partial-trace I defined above verifies this,

$$||\rho\rangle\rangle_i^{A}=||\rho\rangle\rangle_i^{B}=\sqrt{2}c_{i<4}=\sqrt{2}c_{i \in \text{Demarcation}=[0,4,8,12]} = [1/\sqrt{2},0,0,1/\sqrt{2}]^T$$

Can we say that tracing out multiple subsystems, such as $$BCD$$ in $$ABCD$$ to get $$A$$, also amounts to identifying the correct demarcation points in the Pauli-string enumeration convention and the correct multiplicative factor? Can we generalize this?

$$\rho_A = 2^{3/2}\sum_{i_1i_2i_3i_4\in \text{Demarcation}}c_{i_1i_2i_3i_4}P_{i_4}$$

PS: Again $$i_4 \in \text{Demarcation}$$ denotes the standard quaternary notation (base 4) indices $$i_1i_2i_3i_4$$ where the last digit $$i_4 = 0$$.