# Can non-linear operations be implemented as a circuit on a quantum computer?

Suppose I have a Quantum circuit, which gives an output state $$|\psi \rangle$$ let's say. I wish to obtain the reduced density matrix by tracing out subsystem B, i.e. $$\rho = |\psi \rangle \langle \psi |$$, and : $$\rho_A = tr_B(\rho)$$. Finally, I wish to square $$\rho_A$$ and find its trace, i.e. $$tr_A(\rho_A^2)$$. I know there are methods in Qiskit to evaluate reduced density matrices and such. My question is: Is there a circuit formulation (without using pre-existing methods) that can do the following non-linear operation? For eg: any circuit that encodes information about the term $$tr_A(\rho_A^2)$$ in its output probabilities?I understand that I can reconstruct the state itself from the measurement outcomes, and then do classical computation to arrive at my result, but is there any better way to do it?

If you mean any kind of circuit, or more general quantum operation, that takes as input some $$\rho$$, and produces output probabilities equal to $$\operatorname{tr}(\rho_A^2)$$, or more generally a nonlinear function of $$\rho$$, then no, it's not possible.
That's easy to see: any unitary or non-unitary operation that is physically realisable is describable as a linear map applied to the input density matrix. And the function sending output states into output probabilities is also linear. Therefore it's not possible to ever have a nonlinear function of input density matrices into the output probabilities. In fact, any possible circuit or combination of a physical operation and any kind of measurement can be described concisely as some effective POVM applied to the input state, and therefore the output probabilities always have the form $$p_b(\rho)=\operatorname{tr}(\mu_b\rho)$$ for some "effective POVM" $$(\mu_b)_b$$. If you allow for linear post-processing of probabilities, then the same argument tells you you can get functions of the form $$\operatorname{tr}(\mathcal O \rho)$$ for some observable $$\mathcal O$$. Either way, these are linear in $$\rho$$.
Of course, if your input is multiple copies of the same state, say $$\rho\otimes\rho$$, then you can get things like $$\operatorname{tr}(\rho_A^2)$$, because those are linear in $$\rho\otimes\rho$$.
If you have two copies of $$|\psi\rangle$$, you simply perform the swap test on the "A" components.
• The swap test between two density matrices $\rho_A$ and $\rho_B$ basically evaluates $\text{Tr}(\rho_A\rho_B)$. So if I set $\rho_B=\rho_A$, it does exactly what you're asking for. Commented Jun 19 at 12:02