From aa463002290a09edaf6581c7c39f7c87d852f149 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Thu, 1 Sep 2016 22:24:46 +0100 Subject: [PATCH] Revise Some Text --- Report/main.tex | 2 +- Report/sections/introduction.tex | 77 ++++++++++++-------------------- Report/sections/simulation.tex | 16 +++---- 3 files changed, 38 insertions(+), 57 deletions(-) diff --git a/Report/main.tex b/Report/main.tex index 8432c17..0947b68 100644 --- a/Report/main.tex +++ b/Report/main.tex @@ -79,7 +79,7 @@ \subsection{Creating Controlled Unitary Gates} \subsection{Source Code} \emph{QuSim.py | Main Simulator} -%\lstinputlisting[language=Python]{../Code/Simulator/QuSim.py} +\lstinputlisting[language=Python]{../Code/Simulator/QuSim.py} \newpage \printbibliography diff --git a/Report/sections/introduction.tex b/Report/sections/introduction.tex index d4b96f4..e3d8afe 100644 --- a/Report/sections/introduction.tex +++ b/Report/sections/introduction.tex @@ -3,18 +3,12 @@ \begin{document} -Here I will give a brief overview of the mathematics necessary to follow -the workings / implementation of the Simulator, and also to refresh -slightly on the notation and concepts of what will be used throughout -this paper.\\ -A working knowledge of linear algebra, matrix operations (\emph{i.e. -multiplication, transpose, trace and tensor products}) among others, -along with a basic idea of some Quantum Mechanics / Quantum -Informational Theory and the workings of Classical Computers, is helpful -but not 100\% necessary. I will try and keep away from the extreme -specifics, and the reasons behind everything, to the best of my -abilities, although some detail is needed in order to portray the ideas -behind this. If you are interested in learning more, the book +Here I will give a brief overview of the whats necessary to follow +the workings / implementation of the Simulator and then the programming language, and also to look over the notation and concepts that will be used throughout this paper.\\ +A familiarity with some linear algebra +along with a basic idea of some Quantum Mechanics and the workings of Classical Computers, is helpful +but not 100\% necessary. \\ +If you are interested in learning more about Quantum Computing, the book ``\emph{Quantum Computing for Computer Scientists}'' \cite{quantumcomputerscience} is very good. \subsection{The Qubit} @@ -22,9 +16,9 @@ \subsection{The Qubit} In classical computing, the bit (short for binary unit) is the smallest data unit. It has a \emph{Single binary value, that can be either \texttt{0} or \texttt{1}}.\\ -The \emph{qubit} would be the Quantum version of the classical bit. +The \emph{qubit} is the Quantum analog of the classical bit. However, unlike a classical bit, it can take a superposition, meaning -that it is possible for a qubit to be in a linear combination of +that it is possible for a qubit to be in a combination of states.\\ In this paper, the choice of basis states (\(Z\)) are as follows: \begin{equation} @@ -43,15 +37,15 @@ \subsection{The Qubit} superposition. A single qubit superposition would look like this:\\ \[ \left\lvert \Psi \rangle =\alpha\lvert0\rangle +\beta\right\lvert 1\rangle\]\\ -The coefficients - \(\alpha\) and \(\beta\) are complex numbers. +The coefficients, \(\alpha\) and \(\beta\) can be complex numbers. Because this state is a superposition, fundamentally you cannot get -access to the amplitudes of the base vectors \(\alpha\) and \(\beta\). +access to the amplitudes of \(\alpha\) and \(\beta\). Instead, you will either get \(\lvert0\rangle\) or \(\lvert1\rangle\), with the probability of getting \(\lvert0\rangle\) being \(\lvert\alpha\lvert^2\), and the probability of getting \(\lvert1\rangle\) being \(\lvert\beta\lvert^2\).\\ Also, if you add the probabilities, you will always get \(1\), which is -the normalization.\\ +the normalization principle.\\ \begin{equation} \lvert\alpha\lvert^2 + \lvert\beta\lvert^2 = 1 \end{equation} @@ -59,20 +53,13 @@ \subsection{The Qubit} If an operation is being performed on a qubit with multiple states, the operation is performed on all of the states at the same time. However, when observed, the qubit will collapse into either \(0\) or \(1\), -stochastically, based on the probability of each of the basic states.\\ -This property can be realised by using partical spin, among others, but -I will not get into that as this project is on a practical +based on the probability of each of the basic states.\\ +A Qubit can be created by using partical spin, among other methods, but +I will not get into that as this project is not about the practical implementation of a quantum computer.\\ -Richard Feynman (a theoretical physicist known for his contribution to -quantum mechanics) suggested that a qubit, -\(\alpha\lvert0\rangle + \beta\lvert1\rangle\), occupies all possible states -between \(0\) and \(1\), thereby making it possible to encode an -infinite amount of data. Although, when observed, collapses into a state -of 0 or 1, thus making the data held in the superpositions useless. This -is why \emph{Quantum Algorithms} are used to exploit this trait. Just like a classical computer, while it is possible to have a single -qubit quantum computer, it's not going to be much use. To use the power +qubit quantum computer, it's not going to be of much use. To use the power of quantum computing you need to have more then 1 qubit.\\ To define more then 1 qubit, you use a \emph{register}. For example, if you wanted to put the value \texttt{11010} Onto 5 qubits, you set the @@ -82,10 +69,8 @@ \subsection{The Qubit} which is equal to:\\ \[ \lvert11010\rangle = \lvert1\rangle \otimes \lvert1\rangle \otimes \lvert0\rangle \otimes \lvert1\rangle \otimes \lvert0\rangle\]\\ -where \(\otimes\) is the tensor product.\\ -A Quantum Register is just a number of qubits, tensored together.\\ -An \emph{n-bit} Quantum Register can hold any number of \emph{n-qubit} -states / superpositions. +where \(\otimes\) is the kronecker product.\\ +An n-Qubit Quantum Register can be described as just the kronecker product of n-Qubits\\ \subsection{Quantum Logic Gates} @@ -102,7 +87,7 @@ \subsection{Quantum Logic Gates} A unitary matrix is defined so that: \begin{quote} -A Complex, Square Matrix, \textbf{U} is unitary if its complex conjugate +A Complex, Square Matrix, \textbf{U}, is unitary if its complex conjugate (U*) is also its inverse \end{quote} @@ -136,7 +121,7 @@ \subsubsection{The NOT Gate / Pauli-X Gate} \subsubsection{Pauli-Y Gate} -This gate acts on a single qubit, and works out to a rotation around a +This gate acts on a single qubit, and works as a rotation around a Bloch Sphere on the \(y\) axis by \(\pi\) radians.\\ It maps the basic states as follows:\\ \[ @@ -224,7 +209,7 @@ \subsubsection{Multi Qubit Gates} quantum computer.\\ In short, the complex vector space for a 5 qubit system has a dimension equal to \(2^5\) or \(32\). Now if you look at, for example, a 64 qubit -system, you get \(2^64 = 18446744073709551616\), or just under eighteen +system, you get \(2^{64} = 18446744073709551616\), or just under eighteen and a half quintillion. As you can probably see, in an \(n\)th qubit system, you need \(2^n\) numbers to represent its state. This growth is exponential, and if you had a \(300\) qubit system, you would need more @@ -236,12 +221,11 @@ \subsubsection{Multi Qubit Gates} or for 3 qubits:\\ \[ \{\lvert000\rangle, \lvert001\rangle, \lvert010\rangle, \lvert011\rangle, \lvert100\rangle, \lvert101\rangle, \lvert110\rangle, \lvert111\rangle,\}\]\\ -A Classical computer also needs \(2^n\) Numbers to define what position -the bits are in, but this is much simpler then in Quantum Computing, +A Classical computer needs \(2\) Numbers to define what position +the bits are in, which is much simpler then in Quantum Computing, where you don't just have a single set state, but rather, due to -Superpositions and Entanglement, the set at any point is very different. -To describe the quantum state, you need \(2^n\) Complex Numbers. Now, -onto some gates. +Superpositions and Entanglement, the state at any point is very different. +To describe the quantum state, you need \(2^n\) Complex Numbers. \subsubsection{CNOT / Controlled Not Gate} @@ -258,24 +242,21 @@ \subsubsection{CNOT / Controlled Not Gate} \begin{equation} CNOT = \left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0\end{matrix} \right] \end{equation} +(Note: The equation above (12), shows a CNOT gate, acting on 2 qubits, with the 1st Qubit being the control, and the target being the 2nd Qubit.) \subsubsection{T or Pi/8 Gate} The reason that I have this gate included is because of a few things. So far, all of the gates we have gone through \(\{ X,Y,Z,H,S,S^\dagger, CNOT \}\), are all part of whats called a -Clifford Group. Every gate in the Clifford group can be simulated pretty -well on a classical computer (See the Gottesman-Knill Theorem \cite{gottesmanknill}), -and therefore the Clifford group is not \emph{universal} (Basically that +Clifford Group. The Clifford group is not \emph{universal} (Basically the the set of gate to which any possible operation on a quantum computer can be reduced to and -preformed on, see -\href{https://en.wikipedia.org/wiki/Quantum_gate\#Universal_quantum_gates}{Here}). -To use the `Quantum Computer' (The simulator) properly, we will need to -include another gate, thats not part of the Clifford Group. For this, we +preformed on) +To use the `Quantum Computer' (The simulator) properly, another gate will need to be implemented, thats not part of the Clifford Group. For this, I will use \(T\) and \(T^\dagger\).\\ They can be represented with the matrices:\\ \begin{equation} - T = \left[ \begin{matrix} 1 & 0\\0 & e^\frac{i\pi}{4}\end{matrix} \right], T^\dagger = \left[ \begin{matrix} 1 & 0\\0 & e^-\frac{i\pi}{4}\end{matrix} \right] + T = \left[ \begin{matrix} 1 & 0\\0 & e^\frac{i\pi}{4}\end{matrix} \right], T^\dagger = \left[ \begin{matrix} 1 & 0\\0 & e^{\frac{-i\pi}{4}}\end{matrix} \right] \end{equation} The \(T\) Gate makes it possible to access all points on a Bloch diff --git a/Report/sections/simulation.tex b/Report/sections/simulation.tex index 92ac1fc..2efc161 100644 --- a/Report/sections/simulation.tex +++ b/Report/sections/simulation.tex @@ -2,18 +2,18 @@ \begin{document} 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. -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\). -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. +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\). +To get the most accurate simulation, you need to also simulate 'Decoherence', which is where the system will loose information due to measurements by the outside environment, although the simulator detailed here is called an 'Ideal' Simulator, as it doesn't also simulate Decoherence. In this project, the simulator will be built upon vector-matrix opperations. \subsection{Quantum Register} -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: +When you start the simulator, you have to have a new Quantum Register. 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: $$ \lvert q_1 q_2...q_n \rangle = \lvert q1 \rangle \otimes \lvert q2 \rangle \otimes ... \otimes \lvert q_n \rangle $$ -So therefore, the vector that must be stored for 4 qubits in the state of 0000 is: +So therefore, the vector that must be stored for 4 Qubits in the state of 0000 is: $$ \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) @@ -27,8 +27,8 @@ \subsection{Matrix Generation} 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. \subsubsection{Expanding Single Qubit Gates} -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. \\ -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), +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. \\ +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), you can use the equation: \begin{equation} @@ -42,7 +42,7 @@ \subsubsection{Expanding Single Qubit Gates} (Note: \(\underset{i=1}{\overset{n}{\otimes}}\) is like \(\underset{i=1}{\overset{n}{\sum}}\), but using the kronecker product, instead of the sum.) \subsubsection{Expanding Multi-Qubit Gates} -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), +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), 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. \\ 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. \\ \\ See the \emph{Gate} class, and the \emph{generateGate} method. @@ -54,7 +54,7 @@ \subsection{Applying Gates} \lvert\psi\rangle \cdot G \end{equation} -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): +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): $$ Id = \left [\begin{matrix}