Skip to content

Commit 5fd3b72

Browse files
committed
Continue Writing
1 parent a627ab6 commit 5fd3b72

File tree

5 files changed

+195
-9
lines changed

5 files changed

+195
-9
lines changed

Report/appedix/controlledGates.tex

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
\documentclass[../main.tex]{subfiles}
2+
3+
\begin{document}
4+
5+
One method of creating 'Controlled Unitary-2x2 Gates',
6+
that involves a new number \(c\), or the control value.
7+
When working with this value, it has all of the properties of a real number (\(\mathbb{R}\)), except that the kronecker product of any matrix \(M\), and \(c\) is:
8+
\begin{equation}
9+
c \otimes M = c \cdot Id
10+
\end{equation}
11+
With \(Id\) Being a 2x2 Identity matrix. \\
12+
Now with a control matrix, \(C = \begin{bmatrix} c & 0 \\ 0 & 1\end{bmatrix}\), You can create any controlled matrix \(CG_{control, target, n}\) (With \(G\) being the 2x2 matrix you want to apply, \(control\) being the number of the qubit controlling the opperation, \(target\) being the number of the qubit you want to apply \(G\) to conditionally, and \(n\) being the total number of qubits in the register) with this equation:
13+
\begin{equation}
14+
CG_{control, target, n} = \underset{i=1}{\overset{n}{\otimes}}
15+
\begin{cases}
16+
G & \text{if} \quad i = target\text{;} \\
17+
C & \text{if} \quad i = control\text{;} \\
18+
Id & \text{otherwise.}
19+
\end{cases}
20+
\end{equation}
21+
22+
(Again: \(\underset{i=1}{\overset{n}{\otimes}}\) is like \(\underset{i=1}{\overset{n}{\sum}}\), but using the kronecker product, instead of the sum.)
23+
24+
Credit to Craig Gidney \cite{controlslikevalues}
25+
26+
27+
\end{document}

Report/main.tex

+55-5
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,53 @@
88
\usepackage{amssymb}
99
\usepackage{graphicx}
1010
\usepackage{csquotes}
11+
\usepackage{courier}
12+
\usepackage{pgf,tikz}
13+
\usepackage{mathrsfs}
14+
\usetikzlibrary{arrows}
15+
\usepackage{listings}
16+
\usepackage{fontbook}
17+
\usepackage{color}
18+
19+
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
20+
\definecolor{zzttqq}{rgb}{0.6,0.2,0.}
21+
\definecolor{qqqqff}{rgb}{0.,0.,1.}
22+
\definecolor{codegreen}{rgb}{0,0.6,0}
23+
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
24+
\definecolor{codepurple}{rgb}{0.58,0,0.82}
25+
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
26+
27+
\lstdefinestyle{mystyle}{
28+
backgroundcolor=\color{backcolour},
29+
commentstyle=\color{codegreen},
30+
keywordstyle=\color{magenta},
31+
numberstyle=\tiny\color{codegray},
32+
stringstyle=\color{codepurple},
33+
basicstyle=\footnotesize,
34+
breakatwhitespace=false,
35+
breaklines=true,
36+
captionpos=b,
37+
keepspaces=true,
38+
numbers=left,
39+
numbersep=5pt,
40+
showspaces=false,
41+
showstringspaces=false,
42+
showtabs=false,
43+
tabsize=2
44+
}
45+
46+
\lstset{style=mystyle}
1147
\usepackage[
1248
backend=biber,
1349
style=numeric
1450
]{biblatex}
1551
\addbibresource{sections/ref.bib}
16-
52+
1753
\title{Designing a High Level Programming Language for Quantum Computing}
1854
\subtitle{For the implementation and simulation of Classical and Quantum Algorithms}
1955
\author{Adam Kelly}
2056
\date{January 2017}
21-
57+
2258
\begin{document}
2359

2460
\begin{titlepage}
@@ -28,10 +64,24 @@
2864
\newpage
2965
\tableofcontents
3066
\newpage
31-
67+
3268
\section{An Introduction to Quantum Computing}
3369
\subfile{sections/introduction}
34-
70+
71+
\section{Simulating a Quantum Computer}
72+
\subfile{sections/simulation}
73+
74+
\newpage
75+
\section{Appendix}
76+
\subsection{Creating Controlled Unitary Gates}
77+
\subfile{appedix/controlledGates}
78+
79+
\subsection{Source Code}
80+
81+
\emph{QuSim.py | Main Simulator}
82+
%\lstinputlisting[language=Python]{../Code/Simulator/QuSim.py}
83+
3584
\newpage
3685
\printbibliography
37-
\end{document}
86+
\newpage
87+
\end{document}

Report/sections/introduction.tex

+2-4
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,7 @@ \subsubsection{T or Pi/8 Gate}
279279
\end{equation}
280280

281281
The \(T\) Gate makes it possible to access all points on a Bloch
282-
Sphere.\\
283-
This is all of the gates that will be implemented into the simulator.
284-
285-
282+
Sphere.\\ \\ \\
283+
These all of the gates that will be implemented into the simulator.
286284

287285
\end{document}

Report/sections/ref.bib

+7
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@ @Article{gottesmanknill
1313
pages = {19},
1414
eprinttype = {arxiv},
1515
eprint = {quant-ph/9807006}
16+
}
17+
@online{controlslikevalues,
18+
author = {Craig Gidney},
19+
title = {Treating Control like Values},
20+
year = 2015,
21+
url = {http://algorithmicassertions.com/impractical-experiments/2015/05/17/Treating-Controls-like-Values.html},
22+
urldate = {2016-10-09}
1623
}

Report/sections/simulation.tex

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
\documentclass[../main.tex]{subfiles}
2+
3+
\begin{document}
4+
When thinking of simulating a Quantum Computer, there are a number of possible ways to implement it, depending on what you want from your simulator.
5+
Regardless of what method, it will always get exponentially slower as you add more qubits to simulate, as the number of amplitudes you need to store is \(2^n\).
6+
To get the most accurate simulation, you need to also simulate 'Decoherence', which is where the system will loose information by the outside environment, although the simulator detailed here is called an 'Ideal' Simulator, as it doesn't also simulate Decoherence.
7+
In this project, the simulator will be built upon vector-matrix opperations.
8+
9+
\subsection{Quantum Register}
10+
To first start the simulator, you have to have a new quantum register object. When a new Quantum Register is created, it creates a new \(2^n\) dimensional vector of zero, and then it sets the first 0 to 1. This is the same as representing an n qubit state, and setting all n qubits to the state \(\lvert0\rangle\). Remember:
11+
12+
$$
13+
\lvert q_1 q_2...q_n \rangle = \lvert q1 \rangle \otimes \lvert q2 \rangle \otimes ... \otimes \lvert q_n \rangle
14+
$$
15+
16+
So therefore, the vector that must be stored for 4 qubits in the state of 0000 is:
17+
18+
$$
19+
\lvert0000\rangle = \lvert0\rangle \otimes \lvert0\rangle \otimes \lvert0\rangle \otimes \lvert0\rangle = \left( \begin{matrix} 1 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{matrix} \right)
20+
$$
21+
22+
When a new Quantum Register Is Defined, it stores the vector, so that gates can be applied to it.
23+
24+
For Source Code see the \emph{QuantumRegister} Class, in the \emph{\_\_init\_\_} function.
25+
26+
\subsection{Matrix Generation}
27+
If you look at the gates defined in the Previous Section, 'Quantum Logic Gates' (For Example, Equation (3)), they are all either \(2\times2\) or \(4\times4\) Matrices, which means that they can only be applied to either a 2 or 4 dimensional vector. This is a problem for our computational model, as we create a large \(2^n\) Dimensional Vector.
28+
29+
\subsubsection{Expanding Single Qubit Gates}
30+
Essentially, what we are trying to do it take a 2x2 matrix, and scale it up, so that it a \(2^n\) x \(2^n\) matrix. Whats important, is that the new matrix must only affect the qubit its targeting. For example, if I had a 4 Qubit Register, and I wanted to apply an \(X\) Gate to the 3rd Qubit, The equation for that new matrix is \(X_{3,4} = Id \otimes Id \otimes X \otimes Id \), with \(Id\) Being a 2x2 Identity Matrix. \\
31+
To generalise this further, to create the gate \(G_{m,n}\) (With \(n\) being the number of qubits in the register, \(m\) being the number of the qubit the gate will act on, and \(G\) Being the 2x2 gate that will be applied to that qubit),
32+
you can use the equation:
33+
34+
\begin{equation}
35+
G_{m,n} = \underset{i=1}{\overset{n}{\otimes}}
36+
\begin{cases}
37+
G & \text{if} \quad i = m \\
38+
Id & \text{if} \quad i \neq m
39+
\end{cases}
40+
\end{equation}
41+
42+
(Note: \(\underset{i=1}{\overset{n}{\otimes}}\) is like \(\underset{i=1}{\overset{n}{\sum}}\), but using the kronecker product, instead of the sum.)
43+
44+
\subsubsection{Expanding Multi-Qubit Gates}
45+
Focusing on Controlled Gates, there are a number of ways to expand / scale up multi-qubit gates, but most of them are quite long winded (See the appendix for a general expansion method),
46+
but the way that the CNOT / Controlled X Gate is implemented in the simulator, is using a Input-Output like structure to generate a new matrix. \\
47+
There is no equation for this gate (Again, see the appendices for a full, generalised mathematical solution), but the generation method for this simulator can be shown using the source code. \\ \\
48+
See the \emph{Gate} class, and the \emph{generateGate} method.
49+
50+
\subsection{Applying Gates}
51+
Once there is a state vector and a full, unitary matrix to apply to it,
52+
you can then apply the gate by using the dot product of the state or amplitude vector (\(\psi\)), and the matrix of the gate \(G\) \\
53+
\begin{equation}
54+
\lvert\psi\rangle \cdot G
55+
\end{equation}
56+
57+
For example, to apply a Pauli-X Gate (Not Gate) to the second qubit of a 2-Qubit Register, it would look as shown (Keep in mind the previous Gate Matrix Generation Equations):
58+
59+
$$
60+
Id = \left [\begin{matrix}
61+
1 && 0 \\
62+
0 && 1
63+
\end{matrix}\right]
64+
$$
65+
\\
66+
$$
67+
X = \left [\begin{matrix}
68+
0 && 1 \\
69+
1 && 0
70+
\end{matrix}\right]
71+
$$
72+
\\
73+
$$
74+
X_{2,2} = Id \otimes X = \left [\begin{matrix}
75+
0 && 1 && 0 && 0 \\
76+
1 && 0 && 0 && 0 \\
77+
0 && 0 && 0 && 1 \\
78+
0 && 0 && 1 && 0
79+
\end{matrix}\right]
80+
$$
81+
82+
$$
83+
\lvert00\rangle \cdot X_{2,2} = \left[\begin{matrix}
84+
0 && 1 && 0 && 0 \\
85+
1 && 0 && 0 && 0 \\
86+
0 && 0 && 0 && 1 \\
87+
0 && 0 && 1 && 0
88+
\end{matrix}\right] \cdot \left[\begin{matrix}
89+
1 \\
90+
0 \\
91+
0 \\
92+
0 \\
93+
\end{matrix}\right] = \left[\begin{matrix}
94+
0 \\
95+
1 \\
96+
0 \\
97+
0 \\
98+
\end{matrix}\right] = \lvert01\rangle
99+
$$
100+
101+
102+
\end{document}
103+
104+

0 commit comments

Comments
 (0)