# Fidelity (overlap) test over reduced density matrices on quantum circuit

The inner product between two quantum states $$\rho(x_1) = U(x_1)|0\rangle\langle 0| U^\dagger(x_1)$$ and $$\rho(x_2) = U(x_2)|0\rangle\langle 0| U^\dagger(x_2)$$ can be calculated analytically with $$Tr[\rho(x_1) \rho(x_2)]$$, but when implementing through a quantum circuit it has to be estimated using the 'fidelity' (aka 'overlap') test, evolving $$\rho_0$$ by $$U = U(x_1) U^\dagger(x_2)$$, measuring in the computational basis and calculating the probability of outcome corresponding to projector $$|0\rangle\langle 0 |$$.

Can I generalize the fidelity test to calculate the inner product between two reduced density matrices $$Tr[\tilde\rho(x_1) \tilde\rho(x_2)]$$, where $$\tilde\rho(x) = Tr_{n \neq k}[\rho(x)]$$ is the reduced density matrices obtained by measuring all qubits except $$k$$? Do I need to rely on the SWAP (aka Hadamard overlap) test to run this calculation on a quantum circuit?

Let's write this explicitly. We take three modes, one for the control that I'll initialize in $$|0\rangle$$ and one each for $$\rho_1$$ and $$\rho_2$$, no matter where these density matrices originated (they can be unitarily evolved from something, the result of a partial trace from something else aka a subsystem of a larger system, etc.). Start with a Hadamard gate on the first state; now the overall state is $$\varrho=|+\rangle\langle+|\otimes \rho_1\otimes\rho_2.$$ We'll need an eigendecomposition of the density matrices if we want to easily inspect the action of the SWAP gate, so we write, without loss of generality: $$\varrho=|+\rangle\langle+|\otimes \sum_m\psi_m |\psi_m\rangle\langle \psi_m|\otimes \sum_n\phi_n |\phi_n\rangle\langle \phi_n|.$$ Now the SWAP gate is defined by its action $$S(\alpha|0\rangle+\beta|1\rangle)\otimes|\psi\rangle\otimes|\phi\rangle=(\alpha|0\rangle\otimes|\psi\rangle\otimes|\phi\rangle+\beta|1\rangle\otimes|\phi\rangle\otimes|\psi\rangle).$$ Acting on our state in question gives u \begin{align} S\varrho S^\dagger=\frac{1}{2}\sum_{mn}\psi_m\phi_n \left(|0,\psi_m,\phi_n\rangle\langle 0,\psi_m,\phi_n|+|0,\psi_m,\phi_n\rangle\langle 1,\phi_n,\psi_m|+|1,\phi_n,\psi_m\rangle\langle 0,\psi_m,\phi_n|+|1,\phi_n,\psi_m\rangle\langle 1,\phi_n,\psi_m|\right). \end{align} To do the measurement, we apply another Hadamard gate to the control qubit before measuring it in the computational basis: \begin{align} (H\otimes\mathbb{I}\otimes\mathbb{I})(S\varrho S^\dagger (H\otimes\mathbb{I}\otimes\mathbb{I})^\dagger=\frac{1}{4}\sum_{mn}\psi_m\phi_n \left(|0,\psi_m,\phi_n\rangle\langle 0,\psi_m,\phi_n|+|1,\psi_m,\phi_n\rangle\langle 0,\psi_m,\phi_n|+|0,\psi_m,\phi_n\rangle\langle 1,\psi_m,\phi_n|+|1,\psi_m,\phi_n\rangle\langle 1,\psi_m,\phi_n| \right.\\ \left. -|0,\psi_m,\phi_n\rangle\langle 1,\phi_n,\psi_m|-|1,\psi_m,\phi_n\rangle\langle 1,\phi_n,\psi_m|+|0,\psi_m,\phi_n\rangle\langle 0,\phi_n,\psi_m|+|1,\psi_m,\phi_n\rangle\langle 0,\phi_n,\psi_m|\right.\\ \left.-|1,\phi_n,\psi_m\rangle\langle 0,\psi_m,\phi_n|-|1,\phi_n,\psi_m\rangle\langle 1,\psi_m,\phi_n|+|0,\phi_n,\psi_m\rangle\langle 0,\psi_m,\phi_n|+|0,\phi_n,\psi_m\rangle\langle 1,\psi_m,\phi_n|\right.\\ \left.+|1,\phi_n,\psi_m\rangle\langle 1,\phi_n,\psi_m|-|0,\phi_n,\psi_m\rangle\langle 1,\phi_n,\psi_m|-|1,\phi_n,\psi_m\rangle\langle 0,\phi_n,\psi_m|+|0,\phi_n,\psi_m\rangle\langle 0,\phi_n,\psi_m|\right). \end{align} Instead of collecting terms, we just look at the probability of measuring $$|0\rangle$$ for the control: \begin{align} \langle 0|(H\otimes\mathbb{I}\otimes\mathbb{I})(S\varrho S^\dagger (H\otimes\mathbb{I}\otimes\mathbb{I})^\dagger|0\rangle_c=&\frac{1}{4}\sum_{mn}\psi_m\phi_n \mathrm{Tr}\left(|\psi_m,\phi_n\rangle\langle \psi_m,\phi_n|+|\psi_m,\phi_n\rangle\langle \phi_n,\psi_m|+|\phi_n,\psi_m\rangle\langle \psi_m,\phi_n|+|\phi_n,\psi_m\rangle\langle \phi_n,\psi_m|\right)\\ =&\frac{1}{2}\sum_{mn}\psi_m\phi_n \left(1+|\langle\psi_m|\phi_n\rangle|^2\right)\\ =&\frac{1}{2}+\frac{1}{2}\sum_{mn}\psi_m\phi_n |\langle\psi_m|\phi_n\rangle|^2\\ =&\frac{1}{2}+\frac{1}{2}\mathrm{Tr}(\rho_1\rho_2). \end{align} Of course, one finds the alternate result $$|1\rangle$$ with complementary probability $$\frac{1}{2}-\frac{1}{2}\mathrm{Tr}(\rho_1\rho_2)$$.
• Thank you! Any chance you can achieve the same result with the fidelity test, e.g. $|xx’\rangle = U^\dagger(x’)U(x) |0\rangle$, trace out all qubits except the k-th and measuring k-th qubit? Is that meaningful? Feb 4 at 13:23
• @incud any test that works for density matrices will work for reduced density matrices. If you have a test that only works for pure states then it will only work on reduced states if the reduced state is pure (ie the global state is separable). So if your fidelity test is the swap test then yes! I'm not sure if your state $|xx^\prime\rangle=|x\rangle\otimes|x^\prime\rangle$ or if you're writing a single-mode state that depends on both $x$ and $x^\prime$ Feb 4 at 13:56