2

I have a question about how to transform a quantum gate into the matrix representation. For example, we all know the 2-qubit gate--CNOT, can be written like \begin{pmatrix} 1& 0& 0& 0 \\ 0& 1& 0& 0 \\ 0& 0& 0& 1 \\ 0& 0& 1& 0 \\ \end{pmatrix} and its image is shown on the lefe side of the following picture: enter image description here

However, I don't konw how to transform the 3-qubit gate into matrix representation. It doesn't look like to directly utilize tensor product technique, and therefore I want to know how to transform them? Probabily in $C_1T_3Q_3$ or in $C_2T_5Q_6$ these more general situation, where $C_k$ stands for the k-th control qubit, $Q_j$ stands for the j-th target qubit, and $Q_i$ means that there are i qubits in total.

glS
  • 27,510
  • 7
  • 37
  • 125
Vertero
  • 23
  • 3

1 Answers1

0

One fairly straightforward method is to enumerate all the computational basis states in order: 000, 001, 010, 011, 100, 101, 110, 111. You can label each row and column in order. So, for example, the bottom-left matrix element has a column label 000 and row label 111. For each such matrix element, (say, row: a, column: b), you act your gate $U$ on the basis state $|a\rangle$ and ask what its amplitude is for producing $|b\rangle$. That's the matrix element: $U_{a,b}=\langle b|U|a\rangle$.

Remember that if you ever find an element has absolute value 1, all other elements in that row and column are 0. So, for the toffoli gate, I might look at $U|000\rangle$. This tells me what the first column is: 1 in the top left element (the 000 row) and 0 everywhere else.

DaftWullie
  • 62,671
  • 4
  • 55
  • 140