4

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?

Isky Mathews
  • 143
  • 3

1 Answers1

2

$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.

AHusain
  • 3,723
  • 2
  • 11
  • 18