Quantum edits
This commit is contained in:
parent
2303155cd5
commit
689d085e6f
@ -44,6 +44,55 @@
|
|||||||
\input{parts/02.00 half a qubit}
|
\input{parts/02.00 half a qubit}
|
||||||
\input{parts/02.01 two halves}
|
\input{parts/02.01 two halves}
|
||||||
\input{parts/03.00 logic gates}
|
\input{parts/03.00 logic gates}
|
||||||
%\input{parts/03.01 quantum gates}
|
\input{parts/03.01 quantum gates}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
The SWAP gate swaps two bits: $\text{SWAP}\ket{ab} = \ket{ba}$. \par
|
||||||
|
Find its matrix.
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
\begin{equation*}
|
||||||
|
\text{SWAP} = \begin{bmatrix}
|
||||||
|
1 & 0 & 0 & 0 \\
|
||||||
|
0 & 0 & 1 & 0 \\
|
||||||
|
0 & 1 & 0 & 0 \\
|
||||||
|
0 & 0 & 0 & 1 \\
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{equation*}
|
||||||
|
\end{solution}
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
% \problem{}
|
||||||
|
% The $T$ gate is a three-bit gate that inverts its right bit iff its left and middle inputs are both $\ket{1}$. \par
|
||||||
|
% In other words, $T\ket{11x} = \ket{11}\ket{\text{not } x}$, and $T\ket{abx} = \ket{abx}$ for all other inputs. \par
|
||||||
|
% Find the $T$ gate's matrix. \par
|
||||||
|
% \note{
|
||||||
|
% This gate is particularly interesting because it's a \textit{universal quantum gate}: \\
|
||||||
|
% like NOR and NAND in classical logic, any quantum gate may emulated by only applying $T$ gates.
|
||||||
|
% }
|
||||||
|
%
|
||||||
|
% \begin{solution}
|
||||||
|
% \begin{equation*}
|
||||||
|
% \text{T} = \begin{bmatrix}
|
||||||
|
% 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
|
||||||
|
% 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
|
||||||
|
% 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
|
||||||
|
% 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
|
||||||
|
% 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
|
||||||
|
% 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
|
||||||
|
% 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
|
||||||
|
% 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
|
||||||
|
% \end{bmatrix}
|
||||||
|
% \end{equation*}
|
||||||
|
% \end{solution}
|
@ -108,5 +108,38 @@ Factor the following product state:
|
|||||||
\end{solution}
|
\end{solution}
|
||||||
|
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
Show that the following is an entangled state.
|
||||||
|
\begin{equation*}
|
||||||
|
\frac{1}{\sqrt{2}}\ket{00} + \frac{1}{\sqrt{2}}\ket{11}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
$
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
|
a_0 \\ a_1
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right]
|
||||||
|
\otimes
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
|
b_0 \\ b_1
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right]
|
||||||
|
=
|
||||||
|
a_0b_0\ket{00} + a_0b_1\ket{01} + a_1b_0\ket{10} + a_1b_1\ket{11}
|
||||||
|
$
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
So, we have that $a_1b_1 = a_0b_0 = \sqrt{2}^{-1}$ \par
|
||||||
|
But $a_0b_1 = a_1b_0 = 0$, so one of $a_0$ and $b_1$ must be zero. \par
|
||||||
|
We thus have a contradiction.
|
||||||
|
\end{solution}
|
||||||
|
|
||||||
|
|
||||||
\vfill
|
\vfill
|
||||||
\pagebreak
|
\pagebreak
|
@ -1,38 +1,78 @@
|
|||||||
\section{Quantum Gates}
|
\section{Quantum Gates}
|
||||||
|
|
||||||
|
|
||||||
|
In the previous section, we stated that a quantum gate is a linear map. \par
|
||||||
|
Let's complete that definition.
|
||||||
|
|
||||||
\definition{}
|
\definition{}
|
||||||
The quantum analog of a logic gate is a \textit{quantum gate,} \par
|
A quantum gate is a \textit{orthonormal matrix}, which means any gate $G$
|
||||||
which we'll define as a linear map from $\mathbb{B}^n$ to $\mathbb{B}^n$. \par
|
satisfies $GG^\text{T} = I$. \par
|
||||||
\note[Note]{This definition is temporary, we'll extend it soon.}
|
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{}<qgateislinear>
|
||||||
|
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{}
|
\problem{}
|
||||||
Consider the CNOT (controlled not) gate. \par
|
Consider the \textit{controlled not} (or \textit{cnot}) gate, defined by the following table: \par
|
||||||
When applied to a two-bit state $\ket{ab}$, CNOT inverts $b$ iff $a$ is $\ket{1}$. \par
|
\begin{itemize}
|
||||||
Find the matrix that represents the CNOT gate. \par
|
\item $\text{X}_\text{c}\ket{00} = \ket{00}$
|
||||||
\hint{what are the dimensions of this matrix?}
|
\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{solution}
|
||||||
\begin{equation*}
|
\begin{equation*}
|
||||||
\text{CNOT} = \begin{bmatrix}
|
\text{CNOT} = \left[\begin{smallmatrix}
|
||||||
1 & 0 & 0 & 0 \\
|
1 & 0 & 0 & 0 \\
|
||||||
0 & 1 & 0 & 0 \\
|
0 & 1 & 0 & 0 \\
|
||||||
0 & 0 & 0 & 1 \\
|
0 & 0 & 0 & 1 \\
|
||||||
0 & 0 & 1 & 0 \\
|
0 & 0 & 1 & 0 \\
|
||||||
\end{bmatrix}
|
\end{smallmatrix}\right]
|
||||||
\end{equation*}
|
\end{equation*}
|
||||||
|
|
||||||
\vspace{4mm}
|
\vspace{4mm}
|
||||||
|
|
||||||
If $\ket{a}$ is $\ket{0}$, $\ket{a} \otimes \ket{b}$ is
|
If $\ket{a}$ is $\ket{0}$, $\ket{a} \otimes \ket{b}$ is
|
||||||
$
|
$
|
||||||
\begin{bmatrix}
|
\left[
|
||||||
\begin{bmatrix}
|
\begin{smallmatrix}
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
b_1 \\ b_2
|
b_1 \\ b_2
|
||||||
\end{bmatrix} \\ 0 \\ 0
|
\end{smallmatrix}
|
||||||
\end{bmatrix}
|
\right]
|
||||||
|
\\ 0 \\ 0
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right]
|
||||||
$, and the \say{not} portion of the matrix is ignored.
|
$, and the \say{not} portion of the matrix is ignored.
|
||||||
|
|
||||||
|
|
||||||
@ -40,12 +80,16 @@ Find the matrix that represents the CNOT gate. \par
|
|||||||
|
|
||||||
If $\ket{a}$ is $\ket{1}$, $\ket{a} \otimes \ket{b}$ is
|
If $\ket{a}$ is $\ket{1}$, $\ket{a} \otimes \ket{b}$ is
|
||||||
$
|
$
|
||||||
\begin{bmatrix}
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
0 \\ 0 \\
|
0 \\ 0 \\
|
||||||
\begin{bmatrix}
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
b_1 \\ b_2
|
b_1 \\ b_2
|
||||||
\end{bmatrix}
|
\end{smallmatrix}
|
||||||
\end{bmatrix}
|
\right]
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right]
|
||||||
$, and the \say{identity} portion of the matrix is ignored.
|
$, and the \say{identity} portion of the matrix is ignored.
|
||||||
|
|
||||||
|
|
||||||
@ -55,479 +99,141 @@ Find the matrix that represents the CNOT gate. \par
|
|||||||
and if $\left[\begin{smallmatrix}b_1 \\ b_2\end{smallmatrix}\right]$ is on the bottom, $\ket{a}$ is $\ket{1}$.
|
and if $\left[\begin{smallmatrix}b_1 \\ b_2\end{smallmatrix}\right]$ is on the bottom, $\ket{a}$ is $\ket{1}$.
|
||||||
\end{solution}
|
\end{solution}
|
||||||
|
|
||||||
\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
|
|
||||||
|
|
||||||
\iffalse
|
|
||||||
\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
|
|
||||||
\fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
The SWAP gate swaps two bits: $\text{SWAP}\ket{ab} = \ket{ba}$. \par
|
|
||||||
Find its matrix.
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
\begin{equation*}
|
|
||||||
\text{SWAP} = \begin{bmatrix}
|
|
||||||
1 & 0 & 0 & 0 \\
|
|
||||||
0 & 0 & 1 & 0 \\
|
|
||||||
0 & 1 & 0 & 0 \\
|
|
||||||
0 & 0 & 0 & 1 \\
|
|
||||||
\end{bmatrix}
|
|
||||||
\end{equation*}
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
\vfill
|
\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}.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
The $T$ gate is a three-bit gate that inverts its right bit iff its left and middle inputs are both $\ket{1}$. \par
|
|
||||||
In other words, $T\ket{11x} = \ket{11}\ket{\text{not } x}$, and $T\ket{abx} = \ket{abx}$ for all other inputs. \par
|
|
||||||
Find the $T$ gate's matrix. \par
|
|
||||||
\note{
|
|
||||||
This gate is particularly interesting because it's a \textit{universal quantum gate}: \\
|
|
||||||
like NOR and NAND in classical logic, any quantum gate may emulated by only applying $T$ gates.
|
|
||||||
}
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
\begin{equation*}
|
|
||||||
\text{T} = \begin{bmatrix}
|
|
||||||
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
|
|
||||||
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
|
|
||||||
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
|
|
||||||
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
|
|
||||||
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
|
|
||||||
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
|
|
||||||
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
|
|
||||||
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
|
|
||||||
\end{bmatrix}
|
|
||||||
\end{equation*}
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
\vfill
|
|
||||||
\pagebreak
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}<applycnot>
|
||||||
|
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*}
|
||||||
The last thing we need is a way to draw complex sequences of gates. \par
|
|
||||||
We already know how to do this with classical gates, \'a la logic circuit:
|
|
||||||
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[circuit logic US, scale=1.5]
|
|
||||||
\node[and gate] (and) at (0,-0.8) {\tiny\texttt{and}};
|
|
||||||
\draw ([shift={(-0.5, 0)}] and.input 1) node[left] {\texttt{1}} -- (and.input 1);
|
|
||||||
\draw ([shift={(-0.5, 0)}] and.input 2) node[left] {\texttt{0}} -- (and.input 2);
|
|
||||||
\draw (and.output) -- ([shift={(0.5, 0)}] and.output) node[right] {\texttt{0}};
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
|
|
||||||
We draw quantum circuits in a very similar way. \par
|
|
||||||
For example, here a simple three-bit circuit consisting of a CNOT gate on the first bit, \par
|
|
||||||
controlled by the third. The first bit is inverted iff the third bit is $\ket{1}$:
|
|
||||||
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[scale=1]
|
|
||||||
\node[qubit] (a) at (0, 0) {$\ket{0}$};
|
|
||||||
\node[qubit] (b) at (0, -1) {$\ket{0}$};
|
|
||||||
\node[qubit] (c) at (0, -2) {$\ket{1}$};
|
|
||||||
|
|
||||||
\draw[wire] (a) -- ([shift={(4, 0)}] a.center) node[qubit] {$\ket{1}$};
|
|
||||||
\draw[wire] (b) -- ([shift={(4, 0)}] b.center) node[qubit] {$\ket{0}$};
|
|
||||||
\draw[wire] (c) -- ([shift={(4, 0)}] c.center) node[qubit] {$\ket{1}$};
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(1,0)}] a)!0.5!([shift={(3,0)}] a)$) --
|
|
||||||
($([shift={(1,0)}] c)!0.5!([shift={(3,0)}] c)$)
|
|
||||||
;
|
|
||||||
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(1,0)}] c)!0.5!([shift={(3,0)}] c)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
|
|
||||||
\qubox{a}{1}{a}{3}{CNOT}
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
|
||||||
Draw the CNOT gate as a classical logic circuit. \par
|
|
||||||
\hint{This can be done with one gate.}
|
|
||||||
|
|
||||||
\begin{solution}
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[circuit logic US, scale=2]
|
|
||||||
\node[xor gate] (xor) at (0, 0) {\tiny\texttt{xor}};
|
|
||||||
\draw (xor.input 1) ++(-0.5, 0) coordinate (start);
|
|
||||||
\draw (xor.input 1) ++(-0.25, 0) coordinate (startjoin);
|
|
||||||
\draw (xor.input 1) -- (xor.input 1 -| start) node[left] {$a$};
|
|
||||||
\draw (xor.input 2) -| (0,-0.25 -| startjoin) |- (0,-0.25, -| start) node[left] {$b$};
|
|
||||||
\filldraw (0,-0.25, -| startjoin) circle[radius=0.3mm] coordinate(dot);
|
|
||||||
\draw (dot) -- (dot -| 1,0) node[right] {$b_\text{out}$};
|
|
||||||
\draw (xor.output) -- (xor.output -| 1,0) node[right] {$a_\text{out}$};
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
\end{solution}
|
|
||||||
|
|
||||||
|
|
||||||
\vfill
|
\vfill
|
||||||
|
|
||||||
Gate controls may be marked with a filled circle or an empty circle. \par
|
|
||||||
Empty circles denote \textit{inverse controls,} which (of course) have an inverse effect. \par
|
|
||||||
For example, the two circuits below are identical:
|
|
||||||
|
|
||||||
\null\hfill
|
|
||||||
\begin{minipage}{0.48\textwidth}
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[scale=1]
|
|
||||||
\node[qubit] (a) at (0, 0) {$\ket{0}$};
|
|
||||||
\node[qubit] (b) at (0, -1) {$\ket{0}$};
|
|
||||||
|
|
||||||
\draw[wire] (a) -- ([shift={(4, 0)}] a.center) node[
|
|
||||||
qubit] {$\ket{a}$};
|
|
||||||
\draw[wire] (b) -- ([shift={(4, 0)}] b.center) node[
|
|
||||||
qubit] {$\ket{b}$};
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(1,0)}] a)!0.5!([shift={(3,0)}] a)$) --
|
|
||||||
($([shift={(1,0)}] b)!0.5!([shift={(3,0)}] b)$)
|
|
||||||
;
|
|
||||||
|
|
||||||
\draw[wireijoin]
|
|
||||||
($([shift={(1,0)}] b)!0.5!([shift={(3,0)}] b)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
|
|
||||||
\qubox{a}{1}{a}{3}{CNOT}
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
\end{minipage}
|
|
||||||
\hfill
|
|
||||||
\begin{minipage}{0.48\textwidth}
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[scale=1]
|
|
||||||
\node[qubit] (a) at (0, 0) {$\ket{0}$};
|
|
||||||
\node[qubit] (b) at (0, -1) {$\ket{0}$};
|
|
||||||
|
|
||||||
\draw[wire] (a) -- ([shift={(4, 0)}] a.center) node[
|
|
||||||
qubit] {$\ket{a}$};
|
|
||||||
\draw[wire] (b) -- ([shift={(4, 0)}] b.center) node[
|
|
||||||
qubit] {$\ket{b}$};
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(1.5,0)}] a)!0.5!([shift={(2.5,0)}] a)$) --
|
|
||||||
($([shift={(1.5,0)}] b)!0.5!([shift={(2.5,0)}] b)$)
|
|
||||||
;
|
|
||||||
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(1.5,0)}] b)!0.5!([shift={(2.5,0)}] b)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\qubox{a}{1}{a}{3}{CNOT}
|
|
||||||
\qubox{b}{0.5}{b}{1.5}{X}
|
|
||||||
\qubox{b}{2.5}{b}{3.5}{X}
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
\end{minipage}
|
|
||||||
\hfill\null
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
\problem{}
|
||||||
What are $\ket{a}$ and $\ket{b}$ in the diagrams above?
|
If we measure the result of \ref{applycnot}, what are the probabilities of getting each state?
|
||||||
|
|
||||||
\begin{solution}
|
\vfill
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[scale=1]
|
|
||||||
\node[qubit] (a) at (0, 0) {$\ket{0}$};
|
|
||||||
\node[qubit] (b) at (0, -1) {$\ket{0}$};
|
|
||||||
|
|
||||||
\draw[wire] (a) -- ([shift={(4, 0)}] a.center) node[
|
|
||||||
qubit] {$\ket{1}$};
|
|
||||||
\draw[wire] (b) -- ([shift={(4, 0)}] b.center) node[
|
|
||||||
qubit] {$\ket{0}$};
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(1,0)}] a)!0.5!([shift={(3,0)}] a)$) --
|
|
||||||
($([shift={(1,0)}] b)!0.5!([shift={(3,0)}] b)$)
|
|
||||||
;
|
|
||||||
|
|
||||||
\draw[wireijoin]
|
%\problem{}
|
||||||
($([shift={(1,0)}] b)!0.5!([shift={(3,0)}] b)$)
|
%Now, modify the CNOT gate so that it inverts $\ket{a}$ whenever it is applied.
|
||||||
circle[radius=0.1] coordinate(dot)
|
%
|
||||||
;
|
%\begin{solution}
|
||||||
|
% \begin{equation*}
|
||||||
\qubox{a}{1}{a}{3}{CNOT}
|
% \text{CNOT}_{\text{mod}} = \begin{bmatrix}
|
||||||
\end{tikzpicture}
|
% 0 & 1 & 0 & 0 \\
|
||||||
\end{center}
|
% 1 & 0 & 0 & 0 \\
|
||||||
\end{solution}
|
% 0 & 0 & 1 & 0 \\
|
||||||
|
% 0 & 0 & 0 & 1
|
||||||
|
% \end{bmatrix}
|
||||||
|
% \end{equation*}
|
||||||
|
%\end{solution}
|
||||||
|
|
||||||
\vfill
|
\vfill
|
||||||
\pagebreak
|
\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*}
|
||||||
As we noted before, quantum gates don't \textit{consume} bits, they \textit{transform} them. \par
|
\note[Note]{Note that we divide by $\sqrt{2}$, since $H$ must be orthonormal}
|
||||||
Thus, quantum circuits are drawn with a fixed set of bits, whose states change with time: \par
|
|
||||||
\note[Note]{
|
|
||||||
In this diagram, CNOT and SWAP are drawn as $\oplus$ and \rotatebox[origin=c]{90}{$\leftrightarrows$} to save space.
|
|
||||||
}
|
|
||||||
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[scale=1]
|
|
||||||
\node[qubit] (a) at (0, 0) {$\ket{a}$};
|
|
||||||
\node[qubit] (b) at (0, -1) {$\ket{1}$};
|
|
||||||
\node[qubit] (c) at (0, -2) {$\ket{c}$};
|
|
||||||
\node[qubit] (d) at (0, -3) {$\ket{d}$};
|
|
||||||
\node[qubit] (e) at (0, -4) {$\ket{1}$};
|
|
||||||
|
|
||||||
\draw[wire] (a) -- ([shift={(7, 0)}] a.center) node[qubit] {$\ket{0}$};
|
|
||||||
\draw[wire] (b) -- ([shift={(7, 0)}] b.center) node[qubit] {$\ket{b}$};
|
|
||||||
\draw[wire] (c) -- ([shift={(7, 0)}] c.center) node[qubit] {$\ket{1}$};
|
|
||||||
\draw[wire] (d) -- ([shift={(7, 0)}] d.center) node[qubit] {$\ket{0}$};
|
|
||||||
\draw[wire] (e) -- ([shift={(7, 0)}] e.center) node[qubit] {$\ket{e}$};
|
|
||||||
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(1,0)}] a)!0.5!([shift={(2,0)}] a)$) --
|
|
||||||
($([shift={(1,0)}] c)!0.5!([shift={(2,0)}] c)$)
|
|
||||||
;
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(1,0)}] b)!0.5!([shift={(2,0)}] b)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\draw[wireijoin]
|
|
||||||
($([shift={(1,0)}] c)!0.5!([shift={(2,0)}] c)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\qubox{a}{1}{a}{2}{T}
|
|
||||||
|
|
||||||
\qubox{a}{4}{a}{5}{X}
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(2,0)}] e)!0.5!([shift={(3,0)}] e)$) --
|
|
||||||
($([shift={(2,0)}] d)!0.5!([shift={(3,0)}] d)$)
|
|
||||||
;
|
|
||||||
\draw[wireijoin]
|
|
||||||
($([shift={(2,0)}] d)!0.5!([shift={(3,0)}] d)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\qubox{e}{2}{e}{3}{$\oplus$}
|
|
||||||
|
|
||||||
\qubox{b}{3}{c}{4}{\rotatebox[origin=c]{90}{$\leftrightarrows$}}
|
|
||||||
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(5,0)}] a)!0.5!([shift={(6,0)}] a)$) --
|
|
||||||
($([shift={(5,0)}] c)!0.5!([shift={(6,0)}] c)$)
|
|
||||||
;
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(5,0)}] a)!0.5!([shift={(6,0)}] a)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(5,0)}] c)!0.5!([shift={(6,0)}] c)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\qubox{b}{5}{b}{6}{T}
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
|
|
||||||
In a quantum circuit, the ONLY way two bits can interact is through a gate. \par
|
|
||||||
We cannot add \say{branches} in quantum circuits like we do in classical circuits:
|
|
||||||
|
|
||||||
\begin{center}
|
|
||||||
\begin{tikzpicture}[circuit logic US, scale=1.2]
|
|
||||||
\node[xor gate] (xor) at (0, 0) {\tiny\texttt{xor}};
|
|
||||||
\draw (xor.input 1) ++(-0.5, 0) coordinate (start);
|
|
||||||
\draw (xor.input 1) ++(-0.25, 0) coordinate (startjoin);
|
|
||||||
\draw (xor.input 1) -- (xor.input 1 -| start) node[left] {$x$};
|
|
||||||
\draw (xor.input 2) -| (0,-0.25 -| startjoin) |- (0,-0.25, -| start) node[left] {$y$};
|
|
||||||
\filldraw (0,-0.25, -| startjoin) circle[radius=0.3mm] coordinate(dot);
|
|
||||||
\draw (dot) -- (dot -| 1,0) node[right] {$y_\text{out}$};
|
|
||||||
\draw (xor.output) -- (xor.output -| 1,0) node[right] {$x_\text{out}$};
|
|
||||||
|
|
||||||
\draw[->, line width = 1, ogrape]
|
|
||||||
([shift={(0.3,-0.5)}] dot) node[right] {This is a branch}
|
|
||||||
-| ([shift={(0,-0.2)}] dot)
|
|
||||||
;
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\problem{}
|
\problem{}
|
||||||
Find the values of $\ket{a}$ through $\ket{e}$ in the above circuit.
|
What is $HH$? \par
|
||||||
|
Using this result, find $H^{-1}$.
|
||||||
|
|
||||||
\begin{solution}
|
\begin{solution}
|
||||||
\begin{center}
|
$HH = I$, so $H^{-1} = H$
|
||||||
\begin{tikzpicture}[scale=1]
|
|
||||||
\node[qubit] (a) at (0, 0) {$\ket{1}$};
|
|
||||||
\node[qubit] (b) at (0, -1) {$\ket{1}$};
|
|
||||||
\node[qubit] (c) at (0, -2) {$\ket{1}$};
|
|
||||||
\node[qubit] (d) at (0, -3) {$\ket{0}$};
|
|
||||||
\node[qubit] (e) at (0, -4) {$\ket{1}$};
|
|
||||||
|
|
||||||
\draw[wire] (a) -- ([shift={(7, 0)}] a.center) node[
|
|
||||||
qubit] {$\ket{0}$};
|
|
||||||
\draw[wire] (b) -- ([shift={(7, 0)}] b.center) node[
|
|
||||||
qubit] {$\ket{1}$};
|
|
||||||
\draw[wire] (c) -- ([shift={(7, 0)}] c.center) node[
|
|
||||||
qubit] {$\ket{1}$};
|
|
||||||
\draw[wire] (d) -- ([shift={(7, 0)}] d.center) node[
|
|
||||||
qubit] {$\ket{0}$};
|
|
||||||
\draw[wire] (e) -- ([shift={(7, 0)}] e.center) node[
|
|
||||||
qubit] {$\ket{0}$};
|
|
||||||
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(1,0)}] a)!0.5!([shift={(2,0)}] a)$) --
|
|
||||||
($([shift={(1,0)}] c)!0.5!([shift={(2,0)}] c)$)
|
|
||||||
;
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(1,0)}] b)!0.5!([shift={(2,0)}] b)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\draw[wireijoin]
|
|
||||||
($([shift={(1,0)}] c)!0.5!([shift={(2,0)}] c)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\qubox{a}{1}{a}{2}{T}
|
|
||||||
|
|
||||||
\qubox{a}{4}{a}{5}{X}
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(2,0)}] e)!0.5!([shift={(3,0)}] e)$) --
|
|
||||||
($([shift={(2,0)}] d)!0.5!([shift={(3,0)}] d)$)
|
|
||||||
;
|
|
||||||
\draw[wireijoin]
|
|
||||||
($([shift={(2,0)}] d)!0.5!([shift={(3,0)}] d)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\qubox{e}{2}{e}{3}{$\oplus$}
|
|
||||||
|
|
||||||
\qubox{b}{3}{c}{4}{\rotatebox[origin=c]{90}{$\leftrightarrows$}}
|
|
||||||
|
|
||||||
|
|
||||||
\draw[wire]
|
|
||||||
($([shift={(5,0)}] a)!0.5!([shift={(6,0)}] a)$) --
|
|
||||||
($([shift={(5,0)}] c)!0.5!([shift={(6,0)}] c)$)
|
|
||||||
;
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(5,0)}] a)!0.5!([shift={(6,0)}] a)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\draw[wirejoin]
|
|
||||||
($([shift={(5,0)}] c)!0.5!([shift={(6,0)}] c)$)
|
|
||||||
circle[radius=0.1] coordinate(dot)
|
|
||||||
;
|
|
||||||
\qubox{b}{5}{b}{6}{T}
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{center}
|
|
||||||
\end{solution}
|
\end{solution}
|
||||||
|
|
||||||
|
|
||||||
\vfill
|
\vfill
|
||||||
\pagebreak
|
|
||||||
|
\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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user