# How to apply gates on a subspace of a superposition of qubits?

Let us say that I have the state $$a|00\rangle + b|01\rangle + c|10\rangle + d|11\rangle$$. I wish to apply a one-qubit unitary (a $$2\times2$$ matrix) U on the subspace spanned by $$|01\rangle$$ and $$|10\rangle$$ (equivalently $$|00\rangle$$ and $$|01\rangle$$, after shifting the basis). Essentially I want the state $$|\psi\rangle = U(b|01\rangle + c|10\rangle) + a|00\rangle + d|11\rangle$$.

How can I do this in Qiskit? I tried methods which involve resetting the one qubit to 0 or involving mid-circuit measurements, but they seem to destroy the superposition of states, which I want to preserve.

• $U$ is a one-qubit unitary, but you apply it on two-qubits basis states. Does it apply only on one of the two qubits? Commented May 22 at 11:29
• This could be helpful. quantumcomputing.stackexchange.com/q/15532/21801 Commented May 22 at 22:15
• @TristanNemoz the idea is that the 2 by 2 unitary matrix acts on the two dimensional subspace spanned by 01 and 10. Alternatively using a change of basis you can make it act on the subspace spanned by 00 and 01 which effectively means to act on the second qubit given the first qubit is in the zero state Commented May 23 at 16:31

$$U = \left( {\begin{array}{*{20}{c}} u_{00}&u_{01} \\ u_{10}&u_{11} \end{array}} \right)$$ Then, you want to apply the two-level unitary $$\left( {\begin{array}{*{20}{c}} 1&0&0&0 \\ 0&u_{00}&u_{01}&0 \\ 0&u_{10}&u_{11}&0 \\ 0&0&0&1 \end{array}} \right)$$ to the two-qubit state $$a|00\rangle + b|01\rangle + c|10\rangle + d|11\rangle$$.
• Step 1: Permute the computational basis states such that $$|01⟩$$ becomes $$|11⟩$$ but $$|10⟩$$ remains $$|10⟩$$