Equation For a CNOT Gate Matrix, that works on multiple qubits

431 Views Asked by At

So Say I have 3 qubits, $\lvert000\rangle$, And I want to apply a Pauli-X Gate to the second qubit.

I know that I can create the matrix that will act on those qubits, using this equation: $$ X_{2,3} = Id \otimes X \otimes Id $$ Where Id is a 2x2 identity matrix.


How would I do something similar to that with a CNOT Gate? (A General Equation for creating that would be great)

1

There are 1 best solutions below

1
On

Note that when we write the matrix of a transformation, we take our basis to be in lexicographical order. In particular, our basis will be in the order $$ \{|000\rangle, |001\rangle,|010\rangle, \dots\} $$ With that in mind: to compute the overall matrix of this transformation, we use the Kronecker product. In particular: $$ I \otimes X \otimes I = I \otimes\left[ \pmatrix{0&1\\1&0} \otimes \pmatrix{1&0\\0&1}\right] = \pmatrix{1&0\\0&1} \otimes \pmatrix{ 0&0&1&0\\ 0&0&0&1\\ 1&0&0&0\\ 0&1&0&0}=\\ \pmatrix{ 0&0&1&0&0&0&0&0\\ 0&0&0&1&0&0&0&0\\ 1&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0\\ 0&0&0&0&0&0&1&0\\ 0&0&0&0&0&0&0&1\\ 0&0&0&0&1&0&0&0\\ 0&0&0&0&0&1&0&0} $$ That should help you with the CNOT as well.