Quantum Programming and Simulation of the Hubbard Model Using Q
Total Page:16
File Type:pdf, Size:1020Kb
DEGREE PROJECT IN TECHNOLOGY, FIRST CYCLE, 15 CREDITS STOCKHOLM, SWEDEN 2020 Quantum programming and simulation of the Hubbard model using Q# HENRIC HINTZE KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF ENGINEERING SCIENCES Theoretical Physics Quantum programming and simulation of the Hubbard model using Q# Henric Hintze SA114X Degree Project in Engineering Physics, First Level Department of Theoretical Physics Royal Institute of Technology (KTH) 1st June 2020 Abstract This paper gives a brief introduction to the basic concepts of quantum computing and simulation as well as quantum programming using Q#. These concepts are then applied by implementing the 2D Hubbard model for fermions interacting on a lattice. Eigenstate energies of the model are obtained for small lattices by running the program on a simulated quantum computer and the resulting values are, when verifiable, accurate. Besides this, the implementation process demonstrates the utility of a framework such as Microsoft’s Quantum Development Kit (QDK) when writing quantum algorithms. Denna uppsats ger en kort introduktion till kvantdatorer, kvantsimulering och kvant- programmering med Q#. Dessa koncept appliceras sedan genom att implementera Hub- bard modellen för fermioner som interagerar i ett gitter i 2D. Modellens egentillståndsen- ergier beräknas genom att köra programmet på en simulerad kvantdator och resultaten stämmer i de fall de går att verifiera. Utöver detta demonstrerar implementationspro- cessen hur användbart ett ramverk såsom Microsoft’s Quantum Development Kit (QDK) är vid skrivandet av kvantalgoritmer. Contents 1 Introduction 2 2 Background 3 2.1 Qubits . .3 2.2 Quantum gates . .4 2.3 Quantum simulation . .7 2.4 The Hubbard model . .8 3 Investigation 9 3.1 A brief introduction to Q# . .9 3.2 Implementation of the Hubbard model using Q# . 11 3.3 Results and discussion . 12 4 Summary and conclusions 15 Bibliography 16 A Hubbard simulation code 18 1 Chapter 1 Introduction As with many fields of study, it is difficult to define exactly what started the field of quantum computing, but one significant event in the early stages of its development was the First Conference on the Physics of Computation, held at MIT in May 1981, at which Paul Benioff [1] and Richard Feynman [2] gave talks on quantum computing. Benioff’s talk focused on his earlier work in 1980 which showed that a computer can operate under the laws of quantum mechanics, while Feynman argued that it is impossible to efficiently simulate a quantum system on a classical computer, which led him to formulate a basic model for a quantum computer that could, in theory, be used for this purpose. In the following decades the field slowly started taking off with some significant milestones being the proof of the no-cloning theorem, stating that it is impossible to construct a copy of an unknown quantum state, in 1982 by William Wootters and Wojciech Zurek [3] and independently by Dennis Dieks [4], the first description of a universal quantum computer by David Deutsch in 1985 [5], the formulations of Shor [6] and Grover’s [7] algorithms in 1994 and 1996 respectively and more recently the realisations of quantum computers with upwards of 50 qubits by companies like Google and IBM [8]. With the advent of increasingly more effective implementations of quantum com- puters, a need for the tools necessary to efficiently program them as well as people capable of using these tools arises. One effort to make quantum programming accessible and to engage people in the field is Microsoft’s Quantum Development Kit (QDK) [9], which comprises tools to build quantum programs with the programming language Q#, designed specifically to program quantum computers. This paper aims to explore the basics of quantum programming using the QDK, first exploring some of the theoretical background of quantum computing and simulation, then implementing a simple example quantum algorithm and finally simulating the 2D Hubbard model for fermions interacting on a lattice. 2 Chapter 2 Background To begin, let us briefly summarise what quantum computers are, how they work and why they are worth developing in the first place. The fundamental concept of a quantum computer is the so-called qubit. Whereas a classical computer uses classical bits which take on binary values of either 0 or 1 to store information, a quantum computer instead uses qubits which draw on the quantum mechanical principles of superposition and en- tanglement to create states which are in superposition of 0 and 1, meaning that instead of strictly having the value 0 or 1 they instead have a certain probability to yield either 0 or 1 when measured. These qubits can be physically implemented in a variety of differ- ent ways using for example electron spin, trapped ions, superconductivity or topological qubits; however, the details of this are beyond the scope of this paper. The reason quantum computers are deemed worth the effort of overcoming the dif- ficulties of physically realizing them, is that there are certain types of problems which would take millennia to solve using our most powerful classical computers, but which a reasonably powerful quantum computer could solve in mere minutes. Broadly speaking, there are three classes of problems which a quantum computer is better equipped to solve than a classical one. The first of these is the class of problems which can be solved using the quantum version of the Fourier transform. Most famous in this class is the problem of factoring large numbers, which can be done efficiently using Shor’s algorithm, yielding an exponential speed-up over classical computers. Secondly, there are search problems, most famously approached by Grover’s algorithm, which gives a quadratic speed-up over classical computers. Finally there are simulation problems dealing with the simulation of quantum mechanical systems. Throughout this paper, the main sources used were the Microsoft Quantum Docu- mentation [9], the book ’Quantum Computation and Quantum Information’ by Nielsen and Chuang [14] and the paper ’Strategies for solving the Fermi-Hubbard model on near- term quantum computer’ by Chris Cade, Lana Mineh, Ashley Montanaro and Stasja Stanisic [15]. 2.1 Qubits Linear algebra is often considered to be the language of quantum mechanics, and since quantum computers function using quantum mechanical systems, that same language can be used to describe operations in quantum computing. The fundamental unit of quantum computing, the qubit, can be represented by a complex vector of size 2 and 3 magnitude 1: α : β Here α and β are the amplitudes of states 0 and 1, meaning jαj2 and jβj2 are the prob- abilities of getting 0 and 1 respectively when measuring the qubit. This can also be written as a linear combination of orthonormal basis states, where a qubit in state 0 is represented by 1 0 and a qubit in state 1 by 0 1 yielding α 1 0 = α + β : β 0 1 Instead of having to write out all of the vectors, it is common to use Dirac notation where the basis states are represented by the following kets: 1 0 j0i = j1i = : 0 1 A qubit in a general state can now be written as j i = α j0i + β j1i : The below ket symbols have the following generally accepted uses: 1 1 j+i = p (j0i + j1i) |−i = p (j0i − j1i) 2 2 1 1 jii = p (j0i + i j1i) |−ii = p (j0i − i j1i): 2 2 2.2 Quantum gates Now that the basics of a qubit have been introduced, the next step is to examine how its state can be altered. This is done using so-called quantum gates, which are the quantum equivalents of classical logic gates. Mathematically, applying a quantum gate to a qubit is done by multiplying the qubit state vector with a 2 × 2 unitary matrix. The simplest example of a quantum gate is the Pauli-X gate which simply switches the basis state coefficients of the qubit with each other. The matrix representation of the gate is 0 1 X = : 1 0 Applying this to a qubit in a general state would therefore look as follows: 0 1 α β X j i = = = β j0i + α j1i : 1 0 β α 4 Quantum gates can also be written using Dirac notation. In the case of the Pauli-X gate one gets 0 1 0 0 1 0 X = + = 0 1 + 1 0 = j0i h1j + j1i h0j : 0 0 1 0 0 1 Application to a qubit now looks as follows: X j i = (j0i h1j + j1i h0j)(α j0i + β j1i) = α(j0i h1j0i + j1i h0j0i) + β(j0i h1j1i + j1i h0j1i) = α(j0i · 0 + j1i · 1) + β(j0i · 1 + j1i · 0) = α j1i + β j0i : The other two Pauli gates, the Y and Z gates are given by 0 −i 1 0 Y = Z = : i 0 0 −1 Another important gate is the Hadamard gate, which can be used to put a qubit in the j0i state into an even superposition of j0i and j1i: 1 1 1 1 H = p H j0i = p (j0i + j1i) = j+i : 2 1 −1 2 The generalisation from single-qubit systems to multiple-qubit systems is fairly straight- forward. A system of N qubits is represented by a complex vector of size 2N . In the case of a two-qubit system one gets 2 3 x0 6x17 6 7 : 4x25 x3 As in the case of the single-qubit system, this can also be written in terms of basis states: 2 3 2 3 2 3 2 3 2 3 x0 1 0 0 0 6x17 607 617 607 607 6 7 = x0 6 7 + x1 6 7 + x2 6 7 + x3 6 7 : 4x25 405 405 415 405 x3 0 0 0 1 These basis states can be generated by taking the tensor product of pairs of the single- qubit basis states: 213 203 203 203 607 1 1 617 1 0 607 0 1 607 0 0 6 7 = ⊗ 6 7 = ⊗ 6 7 = ⊗ 6 7 = ⊗ : 405 0 0 405 0 1 415 1 0 405 1 1 0 0 0 1 Using this fact, it is once again possible to write everything in Dirac notation: 2 3 x0 6x17 6 7 = x0 j0i ⊗ j0i + x1 j0i ⊗ j1i + x2 j1i ⊗ j0i + x3 j1i ⊗ j1i : 4x25 x3 5 To simplify further, tensor products of basis states are by convention written as ji0i ⊗ ji1i ⊗ · · · ⊗ jini = ji0i1:::ini : This yields 2 3 x0 6x17 6 7 = x0 j00i + x1 j01i + x2 j10i + x3 j11i : 4x25 x3 In a similar fashion, quantum gates are generalised to multiple-qubit systems as 2N × 2N matrices.