\section{Quantum Gates} In the previous section, we stated that a quantum gate is a linear map. \par Let's complete that definition. \definition{} A quantum gate is a \textit{orthonormal matrix}, which means any gate $G$ satisfies $GG^\text{T} = I$. \par This implies the following: \par \begin{itemize} \item $G$ is square \par \note{ If we think of $G$ as a map, this implies it has as many inputs as it has outputs. \\ This makes sense---we stated earlier that quantum gates do not destroy or create qubits. } \item $G$ preserves lengths; i.e $|x| = |Gx|$. \par \note{This ensures that $G\ket{\psi}$ is always a valid state!} \end{itemize} (You will prove all these properties in any introductory linear algebra course. \\ This isn't a lesson on linear algebra, so you may take them as given today.) \definition{} Let $\mathbb{U} \subset \mathbb{R}^2$ be the set of points in the unit circle. \par We can restate the above definition as follows: \par A quantum gate is an invertible map from $\mathbb{U}^n$ to $\mathbb{U}^n$. \definition{} Let $G$ be a quantum gate. \par Since quantum gates are, by definition, \textit{linear} maps, the following holds: \par \begin{equation*} G\bigl(a_0 \ket{0} + a_1\ket{1}\bigr) = a_0G\ket{0} + a_1G\ket{1} \end{equation*} \problem{} Consider the \textit{controlled not} (or \textit{cnot}) gate, defined by the following table: \par \begin{itemize} \item $\text{X}_\text{c}\ket{00} = \ket{00}$ \item $\text{X}_\text{c}\ket{01} = \ket{11}$ \item $\text{X}_\text{c}\ket{10} = \ket{10}$ \item $\text{X}_\text{c}\ket{11} = \ket{01}$ \end{itemize} In other words, the cnot gate inverts its first bit if its second bit is $\ket{1}$. \par Find the matrix that applies the cnot gate. \begin{solution} \begin{equation*} \text{CNOT} = \left[\begin{smallmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{smallmatrix}\right] \end{equation*} \vspace{4mm} If $\ket{a}$ is $\ket{0}$, $\ket{a} \otimes \ket{b}$ is $ \left[ \begin{smallmatrix} \left[ \begin{smallmatrix} b_1 \\ b_2 \end{smallmatrix} \right] \\ 0 \\ 0 \end{smallmatrix} \right] $, and the \say{not} portion of the matrix is ignored. \vspace{4mm} If $\ket{a}$ is $\ket{1}$, $\ket{a} \otimes \ket{b}$ is $ \left[ \begin{smallmatrix} 0 \\ 0 \\ \left[ \begin{smallmatrix} b_1 \\ b_2 \end{smallmatrix} \right] \end{smallmatrix} \right] $, and the \say{identity} portion of the matrix is ignored. The state of $\ket{a}$ is always preserved, since it's determined by the position of $\left[\begin{smallmatrix}b_1 \\ b_2\end{smallmatrix}\right]$ in the tensor product. If $\left[\begin{smallmatrix}b_1 \\ b_2\end{smallmatrix}\right]$ is on top, $\ket{a}$ is $\ket{0}$, and if $\left[\begin{smallmatrix}b_1 \\ b_2\end{smallmatrix}\right]$ is on the bottom, $\ket{a}$ is $\ket{1}$. \end{solution} \vfill \generic{Remark:} Note that a quantum gate is fully defined by the place it maps our basis states $\ket{0}$ and $\ket{1}$ (or,$\ket{00...0}$ through $\ket{11...1}$ for multi-qubit gates). This directly follows from \ref{qgateislinear}. \pagebreak \problem{} Evaluate the following: \begin{equation*} \text{X}_\text{C} \Bigl( \frac{1}{2}\ket{00} + \frac{1}{2}\ket{01} - \frac{1}{2}\ket{10} - \frac{1}{2}\ket{11} \Bigr) \end{equation*} \vfill \problem{} If we measure the result of \ref{applycnot}, what are the probabilities of getting each state? \vfill %\problem{} %Now, modify the CNOT gate so that it inverts $\ket{a}$ whenever it is applied. % %\begin{solution} % \begin{equation*} % \text{CNOT}_{\text{mod}} = \begin{bmatrix} % 0 & 1 & 0 & 0 \\ % 1 & 0 & 0 & 0 \\ % 0 & 0 & 1 & 0 \\ % 0 & 0 & 0 & 1 % \end{bmatrix} % \end{equation*} %\end{solution} \vfill \pagebreak %\problem{} %Finally, modify the original CNOT gate so that the roles of its bits are reversed: \par %$\text{CNOT}_{\text{flip}} \ket{ab}$ should invert $\ket{a}$ iff $\ket{b}$ is $\ket{1}$. % % %\begin{solution} % \begin{equation*} % \text{CNOT}_{\text{flip}} = \begin{bmatrix} % 1 & 0 & 0 & 0 \\ % 0 & 0 & 0 & 1 \\ % 0 & 0 & 1 & 0 \\ % 0 & 1 & 0 & 0 \\ % \end{bmatrix} % \end{equation*} %\end{solution} % %\vfill \definition{} The \textit{Hadamard Gate} $H$, is given by the following matrix: \par \begin{equation*} H = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} \end{equation*} \note[Note]{Note that we divide by $\sqrt{2}$, since $H$ must be orthonormal} \problem{} What is $HH$? \par Using this result, find $H^{-1}$. \begin{solution} $HH = I$, so $H^{-1} = H$ \end{solution} \vfill \begin{ORMCbox}{Review: Matrix Multiplication}{black!10!white}{black} Matrix multiplication works as follows: \begin{equation*} AB = \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} \begin{bmatrix} a_0 & b_0 \\ a_1 & b_1 \\ \end{bmatrix} = \begin{bmatrix} 1a_0 + 2a_1 & 1b_0 + 2b_1 \\ 3a_0 + 4a_1 & 3b_0 + 4b_1 \\ \end{bmatrix} \end{equation*} Note that this is very similar to multiplying each column of $B$ by $A$. \par The product $AB$ is simply $Ac$ for every column $c$ in $B$: \begin{equation*} Ac_0 = \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} \begin{bmatrix} a_0 \\ a_1 \end{bmatrix} = \begin{bmatrix} 1a_0 + 2a_1 \\ 3a_0 + 4a_1 \end{bmatrix} \end{equation*} This is exactly the first column of the matrix product. \end{ORMCbox} \pagebreak