Multi-Qubit Gates

In general, a unitary operator \(U:\mathcal{H}^{2^n}\rightarrow\mathcal{H}^{2^n}\) acting on a register of \(n\) qubits is represented by a \(2^n    imes2^n\) matrix. Let \(U_A:\mathcal{H}_A
ightarrow\mathcal{H}_A\) and \(U_B:\mathcal{H}_B\rightarrow\mathcal{H}_B\) be two unitary operators acting on the Hilbert spaces \(\mathcal{H}_A\) and \(\mathcal{H}_B\), respectively. Define the tensor product of two operators \(U_A\) and \(U_B\) as the operator
 \[U_{A\otimes B}\equiv U_A\otimes U_B: \mathcal{H}_A\otimes\mathcal{H}_B \rightarrow\mathcal{H}_A\otimes\mathcal{H}_B,\] which maps the arbitrary states \(\left|\psi_A\right>\in\mathcal{H}_A\) and \(\left|\psi_B\right>\in\mathcal{H}_B\) to
 \[U_{A\otimes B}(\left|\psi_A\right>\left|\psi_B\right>)=U_A\left|\psi_A\right>U_B\left|\psi_A\right>.\]
 If
\[U_A=
\begin{pmatrix}
  a_{11}&a_{12}& \cdots &a_{1n}\\
  a_{21}&a_{22}& \cdots &a_{2n}\\
  \vdots &\vdots &\ddots & \vdots \\
  a_{n1}&a_{n2}& \cdots & a_{nn}\end{pmatrix}\]
and
\[U_B=
 \begin{pmatrix}
  b_{11}&b_{12}& \cdots &b_{1m}\\
  b_{21}&b_{22}& \cdots &b_{2m}\\
  \vdots &\vdots &\ddots & \vdots \\
  b_{m1}&b_{m2}& \cdots & b_{mm}
  \end{pmatrix}\]
are the matrix representations of the operators on the spaces with dimensions \(n\) and \(m\) respectively, then the tensor product is given by the \(nm\times nm\) matrix of the form
\[U_{A\otimes B}=
\begin{pmatrix}
  a_{11}U_B&a_{12}U_B& \cdots &a_{1n}U_B\\
  a_{21}U_B&a_{22}U_B& \cdots &a_{2n}U_B\\
  \vdots &\vdots &\ddots & \vdots \\
  a_{n1}U_B&a_{n2U_B}& \cdots & a_{nn}U_B
  \end{pmatrix},\]
where each \(a_{ij}U_B\) represents a \(m\times m\) block given by multiplying the matrix \(U_B\) by the coefficient \(a_{ij}\) of \(U_A\).

 Tensor products of any number of operators acting on their respective Hilbert spaces can be defined in this manner to an operator that acts on the system described by the tensor product of the spaces. For a register of \(n\) single qubits, the operator on \(\mathcal{H}^{2^n}\) that applies a single qubit operator \(U\) on \(\mathcal{H}^2\) on say the \(i^{th}\) qubit of the register can be written as the \(n\)-fold tensor product
 \[I\otimes ...\otimes I\otimes U\otimes I \otimes ... \otimes I,\]
 where \(I\) is the identity operator on a  single qubit, and \(U\) appears in the \(i^{th}\) position of the tensor product. In this way, the tensor product of single qubit gates can be built up from the sum of matrices of this form.