Let's say that you have a 6 qubit system and you want to apply a Hadamard gate to qubits 2 and 4.

How would you construct a matrix that did that, while leaving the state of the other qubits alone?


Imagine that the qubits were $0$ and $1$ (or $1$ and $2$, depending on your numbering scheme). You want to apply the Hadamard gate on the first two coordinates, and nothing – the identity – on the rest. This leads to a block diagonal matrix whose second block is the $4\times 4$ identity.

Now make the necessary arrangements for the qubits you're interesting it.

  • $\begingroup$ My question is specifically, what are the necessary arrangements when not using neighboring qubits? :p $\endgroup$ – Alan Wolfe Oct 18 '15 at 20:48
  • $\begingroup$ You take the tensor product of your gate and the identity on the rest of the bits. I don't know what you mean by arrangement. In terms of matrices, this is just a block diagonal matrices with its rows and columns shuffled. $\endgroup$ – Yuval Filmus Oct 18 '15 at 20:53
  • $\begingroup$ It turns out I didn't ask the question I intended to ask, due to incomplete understanding. Sorry about that Yuval and thanks for your answer! $\endgroup$ – Alan Wolfe Oct 21 '15 at 14:59
  • $\begingroup$ Yuval, I meant to ask about a multi qubit gate. For instance, let's say you wanted to apply a controlled not to qubits 2 and 4, in a 6 qubit system. I'd like to ask a new question for that, but the title is going to be the same as the title of this question so not sure. Think I ought to delete this one?? $\endgroup$ – Alan Wolfe Oct 28 '15 at 5:08
  • 1
    $\begingroup$ I just went ahead and asked a new one, in case you want some more points hehe. cs.stackexchange.com/questions/48834/… $\endgroup$ – Alan Wolfe Oct 29 '15 at 4:05

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.