3
$\begingroup$

Suppose I have a quantum gate $U$ and it's a controlled gate. In particular, I have a $2\times 2$ matrix formulation of the gate's action on 2 adjacent qubits.

How can I make this work on an $n$-bit system?

To explain precisely what I mean, if I wanted to implement a controlled $U$ gate on a 3 qubit system where the first 2 bits have the $U$ acting on them and the third qubit is kept the same, I would get the corresponding matrix by working out $U\otimes I$. However, I could not do any similar product to get the gate on 3 qubits in which the first bit is "controlled", the second bit is kept the same and the third bit has $U$ acting on it.

So how do I make the matrix which allows me to "control" the $m$th bit and use $U$ conditionally on the $n$th bit out of a bunch of $k$ qubits?

$\endgroup$
  • $\begingroup$ Hi Isky! Welcome to QCSE! If I understand your question correctly, why not just use a $2$-qubit gate acting on the $m$th and $n$th qubit? $\endgroup$ – Mark S Jun 26 at 17:19
  • $\begingroup$ Hello! My question is how to write that down in an easily computable way in matrix form (my motivation is that this is the last piece of the puzzle in my own simulation of the QFT). $\endgroup$ – Isky Mathews Jun 26 at 18:22
  • $\begingroup$ U should be 4 by 4 in order to act on 2 qubits. $\endgroup$ – AHusain Jun 26 at 21:07
  • $\begingroup$ @AHusain d'oh! of course. $\endgroup$ – Mark S Jun 26 at 23:09
2
$\begingroup$

$U$ actually means the 4 by 4 matrix acting on both the control and the affected qubits. You are mixing up this $U$ with the 2 by 2 block inside it. To avoid that from now on, just take $U$ to be the 4 by 4 one.

Now that that is clarified. Rearrange things with a swap.

So if the first is control and third is acted on you should do:

$$ (I_2 \otimes S) (U \otimes I_2) (I_2 \otimes S) $$

where $S$ is a 4 by 4 unitary matrix that swaps two qubits. By it's positioning in $I_2 \otimes S$ it is acting on qubits 2 and 3 in this case.

$$ \begin{pmatrix} 1&0&0&0\\ 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1\\ \end{pmatrix} $$

$(U \otimes I_2)$ had the first as control and the second affected. By conjugating by this swap we changed the roles of second and third qubit. So the combined result has the first as control and the third affected.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.