Added quantum handout
This commit is contained in:
parent
c7afd20437
commit
afadc8bf6c
43
Advanced/Introduction to Quantum/main.tex
Executable file
43
Advanced/Introduction to Quantum/main.tex
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
% Copyright (C) 2023 <Mark (mark@betalupi.com)>
|
||||||
|
%
|
||||||
|
% This program is free software: you can redistribute it and/or modify
|
||||||
|
% it under the terms of the GNU General Public License as published by
|
||||||
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
|
% (at your option) any later version.
|
||||||
|
%
|
||||||
|
% You may have received a copy of the GNU General Public License
|
||||||
|
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
%
|
||||||
|
%
|
||||||
|
%
|
||||||
|
% If you edit this, please give credit!
|
||||||
|
% Quality handouts take time to make.
|
||||||
|
|
||||||
|
% use the [nosolutions] flag to hide solutions,
|
||||||
|
% use the [solutions] flag to show solutions.
|
||||||
|
\documentclass[
|
||||||
|
solutions,
|
||||||
|
singlenumbering
|
||||||
|
]{../../resources/ormc_handout}
|
||||||
|
\usepackage{../../resources/macros}
|
||||||
|
|
||||||
|
\def\ket#1{\left|#1\right\rangle}
|
||||||
|
\def\bra#1{\left\langle#1\right|}
|
||||||
|
|
||||||
|
\usepackage{units}
|
||||||
|
\input{tikzset}
|
||||||
|
|
||||||
|
|
||||||
|
\uptitlel{Advanced 2}
|
||||||
|
\uptitler{Winter 2022}
|
||||||
|
\title{Intro to Quantum Computing I}
|
||||||
|
\subtitle{Prepared by \githref{Mark} on \today{}}
|
||||||
|
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
\maketitle
|
||||||
|
|
||||||
|
\input{parts/0 bits}
|
||||||
|
\input{parts/1 gates}
|
||||||
|
\end{document}
|
620
Advanced/Introduction to Quantum/parts/0 bits.tex
Normal file
620
Advanced/Introduction to Quantum/parts/0 bits.tex
Normal file
@ -0,0 +1,620 @@
|
|||||||
|
\section{One Bit}
|
||||||
|
Before we discuss quantum computation, we first need to construct a few tools. \par
|
||||||
|
To keep things simple, we'll use regular (usually called \textit{classical}) bits for now.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\definition{}
|
||||||
|
$\mathbb{B}$ is the set of binary digits. In other words, $\mathbb{B} = \{\texttt{0}, \texttt{1}\}$. \par
|
||||||
|
\note[Note]{We've seen $\mathbb{B}$ before: It's $(\mathbb{Z}_2, +)$, the addition group mod 2.}
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
Multiplication in $\mathbb{B}$ works just as you'd expect: \par
|
||||||
|
$
|
||||||
|
\texttt{0} \times \texttt{0} =
|
||||||
|
\texttt{0} \times \texttt{1} =
|
||||||
|
\texttt{1} \times \texttt{0} = \texttt{0}
|
||||||
|
$; and $\texttt{1} \times \texttt{1} = \texttt{1}$.
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
We'll treat addition a bit differently: \par
|
||||||
|
$0 + 0 = 0$ and $0 + 1 = 1$, but $1 + 1$, for our purposes, is undefined.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\definition{}
|
||||||
|
Let $A$ and $B$ be sets. \par
|
||||||
|
The \textit{cartesian product} $A \times B$ is the set of all pairs $(a, b)$ where $a \in A$ and $b \in B$. \par
|
||||||
|
As usual, we can write $A \times A \times A$ as $A^3$. \par
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
In this handout, we'll often see the following sets:
|
||||||
|
\begin{itemize}
|
||||||
|
\item $\mathbb{R}^2$, a two-dimensional plane
|
||||||
|
\item $\mathbb{R}^n$, an n-dimensional space
|
||||||
|
\item $\mathbb{B}^2$, the set $\{\texttt{00}, \texttt{01}, \texttt{10}, \texttt{11}\}$
|
||||||
|
\item $\mathbb{B}^n$, the set of all possible states of $n$ bits.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
What is the size of $\mathbb{B}^n$?
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\generic{Remark:}
|
||||||
|
Consider a single classical bit. It takes states in $\{\texttt{0}, \texttt{1}\}$, picking one at a time. \par
|
||||||
|
The states \texttt{0} and \texttt{1} are fully independent. They are completely disjoint; they share no parts. \par
|
||||||
|
We'll therefore say that \texttt{0} and \texttt{1} \textit{orthogonal} (or equivalently, \textit{perpendicular}). \par
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
We can draw $\vec{0}$ and $\vec{1}$ as perpendicular axis on a plane to represent this:
|
||||||
|
|
||||||
|
\begin{center}
|
||||||
|
\begin{tikzpicture}[scale=1.5]
|
||||||
|
\fill[color = black] (0, 0) circle[radius=0.05];
|
||||||
|
|
||||||
|
\draw[->] (0, 0) -- (1.5, 0);
|
||||||
|
\node[right] at (1.5, 0) {$\vec{0}$ axis};
|
||||||
|
\fill[color = oblue] (1, 0) circle[radius=0.05];
|
||||||
|
\node[below] at (1, 0) {\texttt{0}};
|
||||||
|
|
||||||
|
\draw[->] (0, 0) -- (0, 1.5);
|
||||||
|
\node[above] at (0, 1.5) {$\vec{1}$ axis};
|
||||||
|
\fill[color = oblue] (0, 1) circle[radius=0.05];
|
||||||
|
\node[left] at (0, 1) {\texttt{1}};
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{center}
|
||||||
|
|
||||||
|
|
||||||
|
The point marked $1$ is at $[0, 1]$. It is no parts $\vec{0}$, and all parts $\vec{1}$. \par
|
||||||
|
Of course, we can say something similar about the point marked $0$: \par
|
||||||
|
It is at $[1, 0] = (1 \times \vec{0}) + (2 \times \vec{1})$. In other words, all $\vec{0}$ and no $\vec{1}$. \par
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
Naturally, the coordinates $[0, 1]$ and $[1, 0]$ denote how much of each axis a point \say{contains.} \par
|
||||||
|
We could, of course, mark the point \texttt{x} at $[1, 1]$, which is equal parts $\vec{0}$ and $\vec{1}$: \par
|
||||||
|
\note[Note]{
|
||||||
|
We could also write $\texttt{x} = \vec{0} + \vec{1}$ explicitly. \\
|
||||||
|
I've drawn \texttt{x} as a point on the left, and as a sum on the right.
|
||||||
|
}
|
||||||
|
|
||||||
|
\null\hfill
|
||||||
|
\begin{minipage}{0.48\textwidth}
|
||||||
|
\begin{center}
|
||||||
|
\begin{tikzpicture}[scale=1.5]
|
||||||
|
\fill[color = black] (0, 0) circle[radius=0.05];
|
||||||
|
|
||||||
|
\draw[->] (0, 0) -- (1.5, 0);
|
||||||
|
\node[right] at (1.5, 0) {$\vec{0}$ axis};
|
||||||
|
|
||||||
|
\draw[->] (0, 0) -- (0, 1.5);
|
||||||
|
\node[above] at (0, 1.5) {$\vec{1}$ axis};
|
||||||
|
|
||||||
|
\fill[color = oblue] (1, 0) circle[radius=0.05];
|
||||||
|
\node[below] at (1, 0) {\texttt{0}};
|
||||||
|
|
||||||
|
\fill[color = oblue] (0, 1) circle[radius=0.05];
|
||||||
|
\node[left] at (0, 1) {\texttt{1}};
|
||||||
|
|
||||||
|
\draw[dashed, color = gray, ->] (0, 0) -- (0.9, 0.9);
|
||||||
|
\fill[color = oblue] (1, 1) circle[radius=0.05];
|
||||||
|
\node[above right] at (1, 1) {\texttt{x}};
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{center}
|
||||||
|
\end{minipage}
|
||||||
|
\hfill
|
||||||
|
\begin{minipage}{0.48\textwidth}
|
||||||
|
\begin{center}
|
||||||
|
\begin{tikzpicture}[scale=1.5]
|
||||||
|
\fill[color = black] (0, 0) circle[radius=0.05];
|
||||||
|
|
||||||
|
\fill[color = oblue] (1, 0) circle[radius=0.05];
|
||||||
|
\node[below] at (1, 0) {\texttt{0}};
|
||||||
|
|
||||||
|
\fill[color = oblue] (0, 1) circle[radius=0.05];
|
||||||
|
\node[left] at (0, 1) {\texttt{1}};
|
||||||
|
|
||||||
|
\draw[dashed, color = gray, ->] (0, 0) -- (0.9, 0.0);
|
||||||
|
\draw[dashed, color = gray, ->] (1, 0.1) -- (1, 0.9);
|
||||||
|
\fill[color = oblue] (1, 1) circle[radius=0.05];
|
||||||
|
\node[above right] at (1, 1) {\texttt{x}};
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{center}
|
||||||
|
\end{minipage}
|
||||||
|
\hfill\null
|
||||||
|
|
||||||
|
\vspace{4mm}
|
||||||
|
|
||||||
|
But \texttt{x} isn't a member of $\mathbb{B}$, it's not a valid state. \par
|
||||||
|
Our bit is fully $\vec{0}$ or fully $\vec{1}$. There's nothing in between.
|
||||||
|
|
||||||
|
|
||||||
|
\vspace{8mm}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\definition{}
|
||||||
|
The unit vectors $\vec{0}$ and $\vec{1}$ form an \textit{orthonormal basis} of the plane $\mathbb{R}^2$. \par
|
||||||
|
\note{
|
||||||
|
\say{ortho-} means \say{orthogonal}; normal means \say{normal,} which means length $= 1$. \\
|
||||||
|
}{
|
||||||
|
Note that $\vec{0}$ and $\vec{1}$ are orthonormal by \textit{definition}. \\
|
||||||
|
We don't have to prove anything, we simply defined them as such.
|
||||||
|
} \par
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
There's much more to say about basis vectors, but we don't need all the tools of linear algebra here. \par
|
||||||
|
We just need to understand that a set of $n$ orthogonal unit vectors defines an $n$-dimensional space. \par
|
||||||
|
This is fairly easy to think about: each vector corresponds to an axis of the space, and every point
|
||||||
|
in that space can be written as a \textit{linear combination} (i.e, a weighted sum) of these basis vectors.
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
For example, the set $\{[1,0,0], [0,1,0], [0,0,1]\}$ (which we usually call $\{x, y, z\})$
|
||||||
|
forms an orthonormal basis of $\mathbb{R}^3$. Every element of $\mathbb{R}^3$ can be written as a linear combination of these vectors:
|
||||||
|
|
||||||
|
\begin{equation*}
|
||||||
|
\left[\begin{smallmatrix} a \\ b \\ c \end{smallmatrix}\right]
|
||||||
|
=
|
||||||
|
a \left[\begin{smallmatrix} 1 \\ 0 \\ 0 \end{smallmatrix}\right] +
|
||||||
|
b \left[\begin{smallmatrix} 0 \\ 1 \\ 0 \end{smallmatrix}\right] +
|
||||||
|
c \left[\begin{smallmatrix} 0 \\ 0 \\ 1 \end{smallmatrix}\right]
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
The tuple $[a,b,c]$ is called the \textit{coordinate} of a point with respect to this basis.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\definition{}
|
||||||
|
This brings us to what we'll call the \textit{vectored representation} of a bit. \par
|
||||||
|
Instead of writing our bits as just \texttt{0} and \texttt{1}, we'll break them into their components: \par
|
||||||
|
|
||||||
|
\null\hfill
|
||||||
|
\begin{minipage}{0.48\textwidth}
|
||||||
|
\[ \ket{0} = \begin{bmatrix} 1 \\ 0 \end{bmatrix} = (1 \times \vec{0}) + (0 \times \vec{1}) \]
|
||||||
|
\end{minipage}
|
||||||
|
\hfill
|
||||||
|
\begin{minipage}{0.48\textwidth}
|
||||||
|
\[ \ket{1} = \begin{bmatrix} 0 \\ 1 \end{bmatrix} = (0 \times \vec{0}) + (1 \times \vec{1}) \]
|
||||||
|
\end{minipage}
|
||||||
|
\hfill\null
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
This may seem needlessly complex---and it is, for classical bits. \par
|
||||||
|
We'll see why this is useful soon enough.
|
||||||
|
|
||||||
|
\generic{One more thing:}
|
||||||
|
The $\ket{~}$ you see in the two expressions above is called a \say{ket,} and denotes a column vector. \par
|
||||||
|
$\ket{0}$ is pronounced \say{ket zero,} and $\ket{1}$ is pronounced \say{ket one.} \par
|
||||||
|
This is called bra-ket notation. $\bra{0}$ is called a \say{bra,} but we won't worry about that for now.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
Write \texttt{x} and \texttt{y} in the diagram below in terms of $\ket{0}$ and $\ket{1}$. \par
|
||||||
|
|
||||||
|
\begin{center}
|
||||||
|
\begin{tikzpicture}[scale=1.5]
|
||||||
|
\fill[color = black] (0, 0) circle[radius=0.05];
|
||||||
|
|
||||||
|
\draw[->] (0, 0) -- (1.5, 0);
|
||||||
|
\node[right] at (1.5, 0) {$\vec{0}$ axis};
|
||||||
|
|
||||||
|
\draw[->] (0, 0) -- (0, 1.5);
|
||||||
|
\node[above] at (0, 1.5) {$\vec{1}$ axis};
|
||||||
|
|
||||||
|
\fill[color = oblue] (1, 0) circle[radius=0.05];
|
||||||
|
\node[below] at (1, 0) {$\ket{0}$};
|
||||||
|
|
||||||
|
\fill[color = oblue] (0, 1) circle[radius=0.05];
|
||||||
|
\node[left] at (0, 1) {$\ket{1}$};
|
||||||
|
|
||||||
|
\draw[dashed, color = gray, ->] (0, 0) -- (0.9, 0.9);
|
||||||
|
\fill[color = ored] (1, 1) circle[radius=0.05];
|
||||||
|
\node[above right] at (1, 1) {\texttt{x}};
|
||||||
|
|
||||||
|
\draw[dashed, color = gray, ->] (0, 0) -- (-0.9, 0.9);
|
||||||
|
\fill[color = ored] (-1, 1) circle[radius=0.05];
|
||||||
|
\node[above right] at (-1, 1) {\texttt{y}};
|
||||||
|
\end{tikzpicture}
|
||||||
|
\end{center}
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section{Two Bits}
|
||||||
|
How do we represent multi-bit states using vectors? \par
|
||||||
|
Unfortunately, this is hard to visualize---but the idea is simple.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
What is the set of possible states of two bits (i.e, $\mathbb{B}^2$)?
|
||||||
|
|
||||||
|
|
||||||
|
\vspace{2cm}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\generic{Remark:}
|
||||||
|
When we have two bits, we have four orthogonal states:
|
||||||
|
$\overrightarrow{00}$, $\overrightarrow{01}$, $\overrightarrow{10}$, and $\overrightarrow{11}$. \par
|
||||||
|
We need four dimensions to draw all of these vectors, so I can't provide a picture... \par
|
||||||
|
but the idea here is the same as before.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
Write $\ket{00}$, $\ket{01}$, $\ket{10}$, and $\ket{11}$ as column vectors \par
|
||||||
|
with respect to the orthonormal basis $\{\overrightarrow{00}, \overrightarrow{01}, \overrightarrow{10}, \overrightarrow{11}\}$.
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\generic{Remark:}
|
||||||
|
So, we represent each possible state as an axis in an $n$-dimensional space. \par
|
||||||
|
A set of $n$ bits gives us $2^n$ possible states, which forms a basis in $2^n$ dimensions.
|
||||||
|
|
||||||
|
\vspace{1mm}
|
||||||
|
|
||||||
|
Say we now have two seperate bits: $\ket{a}$ and $\ket{b}$. \par
|
||||||
|
How do we represent their compound state? \par
|
||||||
|
|
||||||
|
\vspace{4mm}
|
||||||
|
|
||||||
|
If we return to our usual notation, this is very easy:
|
||||||
|
$a$ is in $\{\texttt{0}, \texttt{1}\}$ and $b$ is in $\{\texttt{0}, \texttt{1}\}$, \par
|
||||||
|
so the possible compound states of $ab$ are
|
||||||
|
$\{\texttt{0}, \texttt{1}\} \times \{\texttt{0}, \texttt{1}\} = \{\texttt{00}, \texttt{01}, \texttt{10}, \texttt{11}\}$
|
||||||
|
|
||||||
|
\vspace{1mm}
|
||||||
|
|
||||||
|
The same is true of any other state set: if $a$ takes values in $A$ and $b$ takes values in $B$, \par
|
||||||
|
the compound state $(a,b)$ takes values in $A \times B$. This is trivial.
|
||||||
|
|
||||||
|
|
||||||
|
\vspace{4mm}
|
||||||
|
|
||||||
|
We would like to do the same in vector notation. Given $\ket{a}$ and $\ket{b}$, \par
|
||||||
|
how should we represent the state of $\ket{ab}$?
|
||||||
|
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\definition{}
|
||||||
|
The \textit{tensor product} between two vectors
|
||||||
|
is defined as follows:
|
||||||
|
\begin{equation*}
|
||||||
|
\begin{bmatrix}
|
||||||
|
x_1 \\ x_2
|
||||||
|
\end{bmatrix}
|
||||||
|
\otimes
|
||||||
|
\begin{bmatrix}
|
||||||
|
y_1 \\ y_2
|
||||||
|
\end{bmatrix}
|
||||||
|
=
|
||||||
|
\begin{bmatrix}
|
||||||
|
x_1
|
||||||
|
\begin{bmatrix}
|
||||||
|
y_1 \\ y_2
|
||||||
|
\end{bmatrix}
|
||||||
|
|
||||||
|
\\[4mm]
|
||||||
|
|
||||||
|
x_2
|
||||||
|
\begin{bmatrix}
|
||||||
|
y_1 \\ y_2
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{bmatrix}
|
||||||
|
=
|
||||||
|
\begin{bmatrix}
|
||||||
|
x_1y_1 \\[1mm]
|
||||||
|
x_1y_2 \\[1mm]
|
||||||
|
x_2y_1 \\[1mm]
|
||||||
|
x_2y_2 \\[0.5mm]
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
|
||||||
|
That is, we take our first vector, multiply the second
|
||||||
|
vector by each of its components, and stack the result.
|
||||||
|
You could think of this as a generalization of scalar
|
||||||
|
mulitiplication, where scalar mulitiplication is a
|
||||||
|
tensor product with a vector in $\mathbb{R}^1$:
|
||||||
|
\begin{equation*}
|
||||||
|
a
|
||||||
|
\begin{bmatrix}
|
||||||
|
x_1 \\ x_2
|
||||||
|
\end{bmatrix}
|
||||||
|
=
|
||||||
|
\begin{bmatrix}
|
||||||
|
a_1
|
||||||
|
\end{bmatrix}
|
||||||
|
\otimes
|
||||||
|
\begin{bmatrix}
|
||||||
|
y_1 \\ y_2
|
||||||
|
\end{bmatrix}
|
||||||
|
=
|
||||||
|
\begin{bmatrix}
|
||||||
|
a_1
|
||||||
|
\begin{bmatrix}
|
||||||
|
y_1 \\ y_2
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{bmatrix}
|
||||||
|
=
|
||||||
|
\begin{bmatrix}
|
||||||
|
a_1y_1 \\[1mm]
|
||||||
|
a_1y_2
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
Also, note that the tensor product is very similar to the
|
||||||
|
Cartesian product: if we take $x$ and $y$ as sets, with
|
||||||
|
$x = \{x_1, x_2\}$ and $y = \{y_1, y_2\}$, the Cartesian product
|
||||||
|
contains the same elements as the tensor product---every possible
|
||||||
|
pairing of an element in $x$ with an element in $y$:
|
||||||
|
\begin{equation*}
|
||||||
|
x \times y = \{~(x_1,y_1), (x_1,y_2), (x_2,y_1), (x_2y_2)~\}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
|
||||||
|
In fact, these two operations are (in a sense) essentially identical. \par
|
||||||
|
Let's quickly demonstrate this.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
Say $x \in \mathbb{R}^n$ and $y \in \mathbb{R}^m$. \par
|
||||||
|
What is the dimension of $x \otimes y$?
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
\problem{}<basistp>
|
||||||
|
What is the pairwise tensor product
|
||||||
|
$
|
||||||
|
\Bigl\{
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
|
1 \\ 0 \\ 0
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right],
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
|
0 \\ 1 \\ 0
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right],
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
|
0 \\ 0 \\ 1
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right]
|
||||||
|
\Bigr\}
|
||||||
|
\otimes
|
||||||
|
\Bigl\{
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
|
1 \\ 0
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right],
|
||||||
|
\left[
|
||||||
|
\begin{smallmatrix}
|
||||||
|
0 \\ 1
|
||||||
|
\end{smallmatrix}
|
||||||
|
\right]
|
||||||
|
\Bigr\}
|
||||||
|
$?
|
||||||
|
|
||||||
|
\note{in other words, distribute the tensor product between every pair of vectors.}
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
The vectors we found in \ref{basistp} are a basis of what space? \par
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
The compound state of two vector-form bits is their tensor product. \par
|
||||||
|
Compute the following. Is the result what we'd expect?
|
||||||
|
\begin{itemize}
|
||||||
|
\item $\ket{0} \otimes \ket{0}$
|
||||||
|
\item $\ket{0} \otimes \ket{1}$
|
||||||
|
\item $\ket{1} \otimes \ket{0}$
|
||||||
|
\item $\ket{1} \otimes \ket{1}$
|
||||||
|
\end{itemize}
|
||||||
|
\hint{
|
||||||
|
Remember that the coordinates of
|
||||||
|
$\ket{0}$ are $\left[\begin{smallmatrix} 1 \\ 0 \end{smallmatrix}\right]$,
|
||||||
|
and the coordinates of
|
||||||
|
$\ket{1}$ are $\left[\begin{smallmatrix} 0 \\ 1 \end{smallmatrix}\right]$.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}<fivequant>
|
||||||
|
Of course, writing $\ket{0} \otimes \ket{1}$ is a bit excessive. \par
|
||||||
|
We'll shorten this notation to $\ket{01}$. \par
|
||||||
|
Thus, the two-bit kets we saw on the previous page are, by definition, tensor products.
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
In fact, we could go further: if we wanted to write the set of bits $\ket{1} \otimes \ket{1} \otimes \ket{0} \otimes \ket{1}$, \par
|
||||||
|
we could write $\ket{1101}$---but a shorter alternative is $\ket{13}$, since $13$ is \texttt{1101} in binary.
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
Write $\ket{5}$ as three-bit state vector. \par
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
$\ket{5} = \ket{101} = \ket{1} \otimes \ket{0} \otimes \ket{1} = [0,0,0,0,0,1,0,0]^T$ \par
|
||||||
|
Notice how we're counting from the top, with $\ket{000} = [1,0,...,0]$ and $\ket{111} = [0, ..., 0, 1]$.
|
||||||
|
\end{solution}
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
Write the three-bit states $\ket{0}$ through $\ket{7}$ as column vectors. \par
|
||||||
|
What do you see?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
635
Advanced/Introduction to Quantum/parts/1 gates.tex
Normal file
635
Advanced/Introduction to Quantum/parts/1 gates.tex
Normal file
@ -0,0 +1,635 @@
|
|||||||
|
\section{Logic Gates}
|
||||||
|
Now that we know how to write vectored bits, let's look at the ways we can change them.
|
||||||
|
|
||||||
|
\generic{Remark:}
|
||||||
|
A few weeks ago, we talked about matrices. Recall that every linear map may be written as a matrix,
|
||||||
|
and that every matrix represents a linear map. For example, if $f: \mathbb{R}^2 \to \mathbb{R}^2$ is a linear
|
||||||
|
map, we can write it as follows:
|
||||||
|
\begin{equation*}
|
||||||
|
f\left(
|
||||||
|
\ket{x}
|
||||||
|
\right)
|
||||||
|
=
|
||||||
|
\begin{bmatrix}
|
||||||
|
m_1 & m_2 \\
|
||||||
|
m_3 & m_4
|
||||||
|
\end{bmatrix}
|
||||||
|
\begin{bmatrix} x_1 \\ x_2 \end{bmatrix}
|
||||||
|
=
|
||||||
|
\left[
|
||||||
|
\begin{matrix}
|
||||||
|
m_1x_1 + m_2x_2 \\
|
||||||
|
m_3x_1 + m_4x_2
|
||||||
|
\end{matrix}
|
||||||
|
\right]
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
The \say{not} gate is a map from $\mathbb{B}$ to $\mathbb{B}$ defined by the following table:
|
||||||
|
\begin{itemize}
|
||||||
|
\item $\text{not}(\texttt{1}) = \texttt{0}$
|
||||||
|
\item $\text{not}(\texttt{0}) = \texttt{1}$
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
Write the not gate as a matrix that operates on single-bit vector states. \par
|
||||||
|
That is, find a matrix $N$ so that $N\ket{0} = \ket{1}$ and $N\ket{1} = \ket{0}$.
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
\begin{equation*}
|
||||||
|
N = \begin{bmatrix}
|
||||||
|
0 & 1 \\ 1 & 0
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{equation*}
|
||||||
|
\end{solution}
|
||||||
|
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
The \say{and} gate is a map $\mathbb{B}^2 \to \mathbb{B}$ defined by the following table:
|
||||||
|
\begin{center}
|
||||||
|
\begin{tabular}{ c | c | c }
|
||||||
|
\hline
|
||||||
|
\texttt{a} & \texttt{b} & \texttt{a} and \texttt{b} \\
|
||||||
|
\hline
|
||||||
|
0 & 0 & 0 \\
|
||||||
|
0 & 1 & 0 \\
|
||||||
|
1 & 0 & 0 \\
|
||||||
|
1 & 1 & 1
|
||||||
|
\end{tabular}
|
||||||
|
\end{center}
|
||||||
|
|
||||||
|
Find a matrix $A$ so that $A\ket{\texttt{ab}}$ works as expected. \par
|
||||||
|
\hint{
|
||||||
|
What is the dimension of the input? What is the dimension of the desired output? \\
|
||||||
|
What do these two values tell us about the dimension of the matrix $A$?
|
||||||
|
}
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
\begin{equation*}
|
||||||
|
A = \begin{bmatrix}
|
||||||
|
1 & 1 & 1 & 0 \\
|
||||||
|
0 & 0 & 0 & 1 \\
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{equation*}
|
||||||
|
\end{solution}
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\generic{Remark:}
|
||||||
|
The way a quantum computer handles information is a bit different than the way a classical computer does.
|
||||||
|
For spooky physics reasons, all quantum gates must be invertible. Naturally, this implies that the usual
|
||||||
|
logic gates we use (and, or, xor) aren't valid quantum gates: each of these takes two inputs (four states)
|
||||||
|
and produces one output (two states), losing information by mapping many inputs to the same output. \par
|
||||||
|
\note[Note]{The \say{not} gate is fine. It is its own inverse, after all!}
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
Although we are still using classical bits, we'll design our gates to be reversible. \par
|
||||||
|
One consequence of the \say{reversibility} rule is that all quantum gate matrices must be square. \par
|
||||||
|
(i.e, they must take the same number of inputs and outputs.) \par
|
||||||
|
\note[Note]{All invertible matrices are square, but not all square matrices are invertible.}
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
This is fairly intuitive: if we have more inputs than we have outputs, we inevitably lose information.
|
||||||
|
|
||||||
|
\vspace{2mm}
|
||||||
|
|
||||||
|
There's also a better way to think about this: rather than seeing quantum gates as \textit{functions}
|
||||||
|
that consume one set of bits and produce another, it's better to think of them as \textit{transformations}
|
||||||
|
we apply to an existing set of bits.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\problem{}
|
||||||
|
For example, take the CNOT (controlled not) gate. \par
|
||||||
|
When applied to a two-bit state $\ket{ab}$, CNOT inverts $b$ iff $a$ is $\ket{1}$. \par
|
||||||
|
Find the matrix that represents the CNOT gate. \par
|
||||||
|
\hint{what are the dimensions of this matrix?}
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
\begin{equation*}
|
||||||
|
\text{CNOT} = \begin{bmatrix}
|
||||||
|
1 & 0 & 0 & 0 \\
|
||||||
|
0 & 1 & 0 & 0 \\
|
||||||
|
0 & 0 & 0 & 1 \\
|
||||||
|
0 & 0 & 1 & 0 \\
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{equation*}
|
||||||
|
|
||||||
|
\vspace{4mm}
|
||||||
|
|
||||||
|
If $\ket{a}$ is $\ket{0}$, $\ket{a} \otimes \ket{b}$ is
|
||||||
|
$
|
||||||
|
\begin{bmatrix}
|
||||||
|
\begin{bmatrix}
|
||||||
|
b_1 \\ b_2
|
||||||
|
\end{bmatrix} \\ 0 \\ 0
|
||||||
|
\end{bmatrix}
|
||||||
|
$, and the \say{not} portion of the matrix is ignored.
|
||||||
|
|
||||||
|
|
||||||
|
\vspace{4mm}
|
||||||
|
|
||||||
|
If $\ket{a}$ is $\ket{1}$, $\ket{a} \otimes \ket{b}$ is
|
||||||
|
$
|
||||||
|
\begin{bmatrix}
|
||||||
|
0 \\ 0 \\
|
||||||
|
\begin{bmatrix}
|
||||||
|
b_1 \\ b_2
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{bmatrix}
|
||||||
|
$, 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\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
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
\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 X'd 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
|
||||||
|
|
||||||
|
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{}
|
||||||
|
What are $\ket{a}$ and $\ket{b}$ in the diagrams above?
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
\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]
|
||||||
|
($([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{solution}
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
As we noted before, quantum gates are \textit{transformations,} modifying a set of bits. \par
|
||||||
|
Thus, quantum circuits are drawn with a fixed set of bits, whose states transform 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{}
|
||||||
|
Find the values of $\ket{a}$ through $\ket{e}$ in the above circuit.
|
||||||
|
|
||||||
|
\begin{solution}
|
||||||
|
\begin{center}
|
||||||
|
\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}
|
||||||
|
|
||||||
|
|
||||||
|
\vfill
|
||||||
|
\pagebreak
|
53
Advanced/Introduction to Quantum/tikzset.tex
Normal file
53
Advanced/Introduction to Quantum/tikzset.tex
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
\usetikzlibrary{arrows.meta}
|
||||||
|
\usetikzlibrary{shapes.geometric}
|
||||||
|
\usetikzlibrary{calc}
|
||||||
|
\usetikzlibrary{circuits.logic.US}
|
||||||
|
\usetikzlibrary{plotmarks}
|
||||||
|
|
||||||
|
|
||||||
|
\tikzset{
|
||||||
|
gate/.style = {
|
||||||
|
draw,
|
||||||
|
rectangle,
|
||||||
|
fill = white,
|
||||||
|
line width = 0.35mm
|
||||||
|
},
|
||||||
|
qubit/.style = {
|
||||||
|
fill = \ORMCbgcolor,
|
||||||
|
line width = 0.35mm
|
||||||
|
},
|
||||||
|
wire/.style = {
|
||||||
|
line width = 1
|
||||||
|
},
|
||||||
|
wirejoin/.style = {
|
||||||
|
fill = oblue,
|
||||||
|
draw = oblue,
|
||||||
|
line width = 1.5
|
||||||
|
},
|
||||||
|
wireijoin/.style = {
|
||||||
|
fill = white,
|
||||||
|
draw = oblue,
|
||||||
|
line width = 1.5
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
% Macros
|
||||||
|
\def\qubox#1#2#3#4#5{
|
||||||
|
% 1: point ne
|
||||||
|
% 2: point ne x offset
|
||||||
|
% 3: point sw
|
||||||
|
% 4: point sw x offset
|
||||||
|
% 5: label text
|
||||||
|
\draw[
|
||||||
|
line width = 1,
|
||||||
|
fill = white,
|
||||||
|
draw = black
|
||||||
|
]
|
||||||
|
([shift={(#2 + 0.1, 0.4)}] #1.center)
|
||||||
|
-- ([shift={(#2 + 0.1, -0.4)}] #1.center |- #3.center)
|
||||||
|
-- ([shift={(#4 - 0.1, -0.4)}] #3.center)
|
||||||
|
-- ([shift={(#4 - 0.1, 0.4)}] #1.center -| #3.center)
|
||||||
|
-- cycle
|
||||||
|
;
|
||||||
|
\node at ($([shift={(#2,0)}] #1)!0.5!([shift={(#4,0)}] #3)$) {#5};
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user