• No results found

Simulating a Quantum Computer

N/A
N/A
Protected

Academic year: 2021

Share "Simulating a Quantum Computer"

Copied!
33
0
0

Loading.... (view fulltext now)

Full text

(1)

IN

DEGREE PROJECT TECHNOLOGY, FIRST CYCLE, 15 CREDITS

,

Simulating a Quantum Computer

Grover's Search Algorithm with Error Correction MARTIN SJÖBORG

HANNA LINN

KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF ENGINEERING SCIENCES

(2)

IN

DEGREE PROJECT TEKNIK, FIRST CYCLE, 15 CREDITS

,

Att simulera en kvantdator

Grovers sökalgoritm med felhantering MARTIN SJÖBORG

HANNA LINN

KTH ROYAL INSTITUTE OF TECHNOLOGY SKOLAN FÖR TEKNIKVETENSKAP

(3)

Abstract

Classical simulations of quantum computers give us an insight into various things such as what quantum algorithms can achieve, whether it is possible to verify that they function as postulated, the difficulties that have to be overcome before quantum computers can be realized, as well as how we can handle these difficulties. We build a Python library to simulate a quantum computer that can perform all quantum algorithms by defining an universal gate set, from which all quantum gates – and thereby all circuits – can be constructed. We implement two algorithms that both highlight two important aspects of quantum computing: Grover’s quantum search algorithm, which demonstrates the efficiency of quantum algorithms and their superiority over their classical counterparts by searching an unsorted list quadratically faster; and an error correcting code, the Shor code, which highlights the cost of correcting the possible errors in a quantum computer.

We test the rigidity of Grover’s algorithm by introducing errors without correction, and find that the algorithm shows resilience to smaller 1-qubit Pauli errors, but looses its efficiency under larger errors and thus the need for Pauli error correction arise.

(4)

Abstract

Klassiska simuleringar av kvantdatorer ger oss en inblick i vad kvantalgoritmer kan åstadkomma, hur vi kan verifiera att algoritmerna fungerar, vilka problem vi måste lösa innan kvantdator- erna blir en verklighet, samt hur vi kanske kan hantera problemen. Vi bygger ett bibliotek i Python för att simulera en kvantdator som kan utföra alla kvantalgoritmer genom att definiera en grinduniversalmängd, ur vilken alla kvantgrindar – och därmed alla kretsar – kan konstrueras. Vi implementar två algoritmer som båda belyser två viktiga aspekter hos kvantberäkning: Grover’s kvantsökning, som demonstrerar effektiviteten hos kvantalgoritmer över deras klassiska analoger, samt en felhanteringsalgoritm, Shorkoden, som kan jämka Paulifel och är betydelsefull för att förstå vikten hos felkorrigering.

Vi prövar motståndskraften hos Grovers algoritm genom att utsätta den för slumpmässiga ro- tationer hos en qubit, och finner att algoritmen är resistent mot mindre Paulifel, men snabbt slutar producera meningsfulla resultat vid större Paulifel.

(5)

Contents

1 Introduction 2

1.1 Qubits: Superposition & Entanglement . . . 3

1.2 Quantum Supremacy . . . 4

1.3 Grover’s Algorithm . . . 4

1.4 Error: Decoherence & Operational Inaccuracy . . . 5

1.5 Error Correction . . . 5

1.6 Simulation of Quantum Computers . . . 5

2 Architecture of Our Quantum Computer 7 2.1 Quantum Gates . . . 7

2.2 Grover’s Algorithm . . . 10

2.2.1 The Algorithm . . . 11

2.2.2 Result Periodicity . . . 13

2.3 Error & Error Correction . . . 14

2.3.1 Defining the Error . . . 14

2.3.2 Error Correction . . . 14

3 Simulation & Results 18 3.1 Simulation in Python . . . 18

3.2 Grover’s Algorithm . . . 19

3.3 Grover’s Algorithm with Error . . . 20

3.4 Error Correction Code . . . 20

3.5 Grover’s Algorithm with Error correction . . . 21

4 Discussion 23 4.1 Simulation of a Quantum Computer . . . 23

4.2 Weakness in Grover’s Algorithm . . . 23

4.3 Error & Correction Price . . . 24

4.4 Coherence Time . . . 24

5 Conclusion 26

(6)

Chapter 1 Introduction

In the early 1980’s, Yuri Manin and Richard Feynman suggested that we might be able to exploit the quantum effects in order to go be- yond what the conventional computers can do [Feynman, 1982]. Feynman mainly argued that the complexity in the interaction between particles could not be simulated without ap- proximations and simplifications by a classi- cal computer, and the computer that would be able to do the information processing required to make the simulation accurate would have to operate in the world of quantum mechanics itself. Manin broadened this statement by re- versing Feynman’s argument, suggesting that computers using quantum effects to do calcu- lations would be considerably more powerful than classical ones, surpassing todays comput- ers and thereby achieving quantum supremacy, explained in Sec. (1.2) [Manin, 1999]. The quantum computers could be able to process larger amounts of data with the use of quan- tum parallelism, and with a lower complex- ity due to quantum mechanical properties, ex- plained in Sec. (1.1).

However, a bundle of technical hurdles may be in the way of quantum computers as we have yet not been able to construct the hardware required for the quantum computers to be practical. The quantum state is highly sensitive to its surroundings, experiencing decoherence, explained in Sec. (1.4). Further- more, we have not yet found a way to control and manipulate the quantum information effi- ciently without errors, outlined in Sec. (1.4).

There have been a number of theories and published results on how the problem with

decoherence and error might be controlled.

One method being the use of error correction codes, especially one developed by Peter Shor [Mermin, 2016, Shor, 1995].

How the quantum computer is realized is yet to be discovered, but we can anticipate which elements that will be crucial by classi- cally simulating the operations the quantum computer would perform and even introduce decoherence and errors. This can also foretell what would be possible to do with a quantum computer. More about this in Sec. (1.6).

Practical applications for quantum comput- ing, if feasible, is a debated subject, but it is clear that it will not be everyday tasks. The two main applications are to:

1) simulate systems with complex Schrödinger equations like chemical reac- tions or quantum interactions, and

2) speed up classical algorithms by inventing a quantum analog.

The first topic is interesting because infor- mation processing of molecular systems with modeling of chemical reactions and materi- als scales exponentially with the number of atoms involved, rendering it impossible due in part to multi-body couplings. The quan- tum simulation field promises a revolution in areas such as drug design, material engineer- ing, and elucidation of biochemical processes [Wang et al., 2015].

The second topic concerns the quantum applications of classical algorithms. Perhaps the most interesting examples are Peter Shor’s

(7)

prime factorization algorithm [Shor, 1995], Alexei Kitaev’s stabilizers of Abelian group actions [Kitaev, 1997], and Lov Grover’s search algorithm [Grover, 1996]. According to Manin, these three algorithms demonstrated a useful toolkit that has then been used while searching for even greater algorithms.

These, at the time, new concepts have boosted the field of quantum algorithms and researchers have since then generalized them [Manin, 1999].

In this thesis, we focus on the implemen- tation of Grover’s search algorithm, and the benefits of the algorithm’s speedup in database searching. This is outlined in Sec. (1.3). We then discuss the problems with errors, deco- herence and operation inaccuracy, and how parts of the problems could be handled by Shor’s error correcting code.

1.1 Qubits: Superposition

& Entanglement

A classical computer works by manipulating binary numbers composed of bits represented by the charge stored in a capacitor, where the state of the bit is either 0 or 1, whether charge is stored or not. The quantum bit (qubit) can be implemented as a two-state quantum sys- tem - e.g. the spin of an electron, polarization of a photon or a trapped ion, or a nuclear mag- netic moment [Mermin, 2016] - such that the state of the system can be expressed as a su- perposition of each distinct state.

Superposition

To express the superposition formally, we in- troduce the bra-ket notation, outlined below.

The quantum state of a system in superpo- sition is defined as the normalized vector

|Ψi =X

i

αiii (1.1) such that|ψii forms a complete orthogonal set in Hilbert space, and the square of the complex

0

1

(a) The two bit states.

|0i

|1i

|0i+|1i 2

(b) A qubit superpo- sition on the Bloch sphere.

Figure 1.1: Bit representation in a) classical systems, and b) quantum systems.

amplitude, |αi|2, denotes the probability that the system, when measured, is found in the state with corresponding basis vector|ψii. We can in principle choose a non-binary quantum system such as the energy levels of an atom with n basis vectors and expand the theory be- yond binary states, but this is unconventional and complicated. Instead, consider the spin of an electron with basis vectors |↑i and |↓i with corresponding eigenvalues Sz = ±~/2 respec- tively. We can now translate the classical bit state of 0 or 1 as the eigenvectors of Sz such that

|↑i = |0i , |↓i = |1i . (1.2) We get a state

|Ψi = α |0i + β |1i if we have one qubit.

In a way, we have now replaced the classical existence of capacitor charge with the quan- tum direction of electron spin along the z-axis.

We can picture this on the Bloch sphere, seen in Fig. (1.1b). On the Bloch sphere, we can represent the state as a two-component vec- tor, with the complex coefficients αi from Eq.

(1.1).

Register

Just as in a classical computer, we are in- terested in forming a register, which in our case translates to collecting the state of each

(8)

qubit into a quantum system with an associ- ated wave function. This means that a register with n qubits is described by a quantum state in 2n Hilbert space. For simplicity, we define the state of the system where all qubits are in the state |0i as the n-fold Kronecker product of the n states in Eq. (1.3). The superscripts denote the qubit, but can be omitted if we keep track of the order which the states appear in the ket vector

00

01 ⊗ . . . ⊗

0n−1 =

0001. . . 0n−1

=|0i⊗n. (1.3) For example: We describe the state of the qubit register of qubits 0, in state |ψ0i = α0|0i + β0|1i, and 1, in state |ψ1i = α1|0i + β1|1i, with |Ψi to describe the whole register, using bra-ket notation we get

|Ψi =

ψ0 ⊗ ψ1

= (α0|0i + β0|1i) ⊗ (α1|0i + β1|1i)

= α0β0|00i + α0β1|01i

+ α1β0|10i + α1β1|11i . (1.4) Gates

Similar to classical computers we need op- erations, called gates, to alter the state of the qubit, more about these and how they have to differ from ordinary gate in Sec.

(2.1). We will use them to put the qubits in superposition and entangling them.

Entanglement

Unlike classical bits the qubits will have the property of entanglement. Quantum entangle- ment is a physical phenomenon that describes when two or more particles interact with each other leading to each of the particle’s state not being possible to be described independently of the other’s states. Thereby making it im- possible to describe the single qubits in the register with a single Kronecker product as de- picted in Eq. (1.4), but a superposition of the different product states: |0001. . . 0n−1i.

A measurement of one of the particles would lead to the other one choosing a state, and thereby being measured too, causing the su- perposition to collapse. This holds even if the particles are parted by a great distance, Al- bert Einstein called this "Spooky action at a distance".

1.2 Quantum Supremacy

Not surprisingly, the goal of the field of quan- tum computing is to perform tasks quicker than, or even tasks that are outright unfeasible to simulate on, classical supercomputers. A quantum search algorithm is a good and sim- ple example of the former, whereas a factoring algorithm is more complicated and an exam- ple of the latter. The set of all problems that can be solved classically in polynomial time Nk for some k and where N is the size of the problem, lies in the complexity class P, which in turn is a subset of the class NP, in which a solution can be readily verified in P. Search- ing an unordered list classically requires N/2 steps, and has a solution that is easily checked (does the entry found match the search cri- terion?). The optimal quantum search algo- rithm completes in a time that is polynomial in √

N [Bennett et al., 1996], and one of pos- sible applications of this is to offer enormous aid in recognizing solutions to NP-complete problems, due to the quadratic speed-up from classical searching [Bennett et al., 1996, Nielsen and Chuang, 2016].

1.3 Grover’s Algorithm

RequiringO(√

N ) steps, Grover’s search algo- rithm is the fastest possible quantum search algorithm, and yet still relatively easy to im- plement. The ramifications of the quadratic speed-up compared to classical search is not only palpable in fields related to ordinary database handling; the Grover algorithm has also been modified neuronally to select optimal responses in vital cell functions [Clark, 2014].

(9)

1.4 Error: Decoherence &

Operational Inaccuracy

The quantum computers will be highly sen- sitive to small changes, caused either by dis- turbances from the outside or by defects in the components of the hardware. More pre- cisely the error could take place anywhere in a quantum computer but especially in a vul- nerable part, called a noisy part, which can be in a long transportation channel, in a storage, or in a certain gate. [Chiaverini et al., 2004, Shor, 1995].

When performing the quantum algorithm in real quantum computers we need the qubit to be in a pure quantum state, thereby to not be perturbed by the world around it, ei- ther by nearby qubits or by the outside of the quantum computer. An interaction with its surroundings, caused by thermal fluctuations, quantum fluctuations, mechanical vibrations, or other extraneous interactions, will entan- gle the qubit with some state in the environ- ment. The entanglement will lead to an er- ror by either just altering the superposition a bit, changing the output of the quantum com- puter, or lead to a measurement of the qubit, thereby destroying the superposition and re- duce the qubit to a classical boolean bit mak- ing it impossible to perform operations on the superposition. This change in the superposi- tion is called decoherence. Decoherence may be the one reason why quantum computers will be difficult, if not impossible to build because the totally isolated qubit may be unattain- able. [Shor, 1995, Mermin, 2016] Another er- ror could occur in the components: the qubits or the gates, if they don’t do the desired oper- ation exact.

1.5 Error Correction

We will not be able to use classical error correction codes, because if we did we would have to measure the qubit to correct the right error, and in doing so cause the collapse of

the wave function from the superposition into one certain state, rendering it to a Boolean bit. We also have another kind of error that the classic computer does not have: the phase shift. In quantum systems we need to keep the qubit in superposition and correcting for the error without knowing the error. There are many different ways to correct errors in quantum memories, two common ones are: back up reservoirs [Almlöf, 2016] and correction algorithms [Mermin, 2016].

We have chosen to focus on one algorithm called the 9-qubit Error Correction Code, of- ten referred to as the Shor Code (not to be con- fused with Shor’s Factorization Algorithm).

Shor suggested to make the system more ro- bust by the use of ancillary qubits to "back- up" the state of one qubit, called encoding, before the possible error, so that the inverse of the encoding, called decoding, could recon- struct the "no-error" state of the qubit by ma- jority voting [Shor, 1995].

1.6 Simulation of Quantum Computers

A large number of studies in simulating quan- tum computers has paved the way for more accurate hardware research in the quantum computer field. By determining what kind of operations a quantum computer will have to be able to perform and how many qubits are required to achieve quantum supremacy, together with anticipation of what obstacles would be in the way, the simulations paint a clearer picture of what the hardware will be.

Using a distributed high-performance sim- ulator to model circuits with 42 qubits, [Boixo et al., 2017] came to the conclusion that quantum supremacy can be achieved with only 50 super conducting qubits. Even by their cutting edge technology, incorpo- rating optimizations such as multi-threading, they were still 8 qubits away to their pro- posed quantum supremacy of 50 qubits.

(10)

Using their in-house quantum computer, [Bishop et al., 2017] at IBM have proposed a formula showing the useful amount of work a given quantum computer can perform. They have quantified the implementation challenges such as number of qubits and gate quality, and their findings show that the hardware is bot- tlenecking performance.

The findings from both these research groups indicates that, for the time being, quantum simulations are heavily hampered by hard- ware. This shows that the simulations provide useful direction to the field, even if the simu- lations per se can’t achieve a speed-up.

(11)

Chapter 2

Architecture of Our Quantum Computer

2.1 Quantum Gates

In order to manipulate the state of the qubit and thereby to build algorithms, regular quan- tum operators are used in the form of gates.

Similar to the classical Boolean gates, the quantum gates alters the state of the qubit, but unlike classical Boolean logic, it is possi- ble to rotate the state over three different spin axes and change the phase. Another impor- tant distinction between Boolean and quan- tum gates is reversibility of the latter, which only the NOT-gate possesses in the Boolean set. The necessary condition of reversibility is inherited from the time symmetry in quantum mechanics. Thus, in order to represent a pos- sible operation, all quantum gates need to be unitary. As rotation and phase shift are trans- formations to other Hilbert spaces it is possible to represent a quantum gate U as a matrix in the basis corresponding to the Hilbert space.

The transformation have to be linear in or- der to take unit vectors into unit vectors and also to ensure that the probability amplitude is conserved,

UU = I. (2.1)

We want to find a set of operators so that we can preform all the necessary transformations to do our calculations. If we have a set of a finite number of gates, that can be combined to perform all transformations, then building a real quantum computer will be easier. This set of gates is called a universal set S because we are able to solely use gates inS to construct possible circuits [Williams, 2011]. The set of the three rotational gates R, and phase shift

P h gates together with the controlled-U gate cU , form a basis for

S = {Rx(α), Ry(β), Rz(γ), P h(δ), cU}. (2.2) We can create any 1-bit unitary gate by com- bining the first four as

U = Rx(α)· Ry(β)· Rz(γ)· P h(δ), (2.3) and we can build any n-qubit circuit by includ- ing the cU -gate. The implementation of these gates are discussed below. However, by adding additional gates that can be built with the gates in S, can we construct an over-complete set S0, which is more common and simpler to work with theoretically. In S0, we include the Hadamard gate H, the Pauli gates X, Y, Z, and the Toffoli gate.

We are now ready to visualize the qubit reg- ister, as shown in Fig. (2.1) This is read as the

|q0i U U|q0i = |˜q0i

|q1i |q1i Figure 2.1

state of each qubit evolving from left to right.

In this case, we see qubits|q0i and |q1i starting out in their own (independent) states|q0i and

|q1i respectively. An arbitrary gate U is then applied to|q0i, while |q1i is left unaltered. The resulting state of|q0i is U |q0i = | ˜q0i. U acting in this way on the register can be expressed as its action on the over the whole Hilbert space with the Kronecker product from Eq. (1.3) as

U :

q0q1 7→ U0⊗ I1

q0q1 =

0q1 . (2.4)

(12)

Where the subscript denotes which qubit the gate acts on. The identity matrix I repre- sents a "do-nothing" gate, since I|q1i = |q1i.

Combining gates acting on individual qubits using the Kronecker product like this, we can pick qubits to manipulate, and leave others un- changed. These 1-qubit gates act individually on each qubit, so that an initial product state will remain a product state after the opera- tion. As an extension of this, we can also cre- ate gates operating over multiple qubits. Us- ing Eq. (2.4), we express the action of U on the circuit shown in Fig. (2.2) as

U :

q0q1 7→ U0⊗ U1

q0q1 =

˜q01 . (2.5) If U is a 2× 2 matrix, the resulting product U0⊗ U1 will be a 4× 4 matrix. When applied, the new big matrix operates on the whole reg- ister at once.

|q0i U0

= U |˜q0i

|q0i U1 |˜q1i

Figure 2.2: U acting on both qubits, producing a compound gate acting on the whole register.

We are now ready to present the matrices representing the gates of interest.

Rotation Gates

The Pauli matrices X, Y , Z, and the iden- tity matrix I are Hermitian and constitute a unitary operator basis in our 1-qubit Hilbert space.

X =0 1 1 0



Y =0 −i i 0



Z =1 0 0 −1



I =1 0 0 1



(2.6) We can use the Pauli matrices to rotate the state of a single qubit, |q0i, around the state axes of the Bloch sphere by π radians. Note that we will have to rotate 4π radians to be back in the original state.

More generally, the rotation matrices de- fined below are more versatile then the Pauli matrices, since the Pauli matrices are special cases of the rotation matrices with the param- eters α, β, γ = π

Rx(α) = e−iαX2 =

 cos α2

−i sin α2

−i sin α2

cos α2



Ry(β) = e−iβY2 =cos β2

− sin β2 sin β2

cos β2



Rz(γ) = e−iγZ2 =e−iγ2 0 0 eiγ2



. (2.7)

We can also describe Rx in terms of the oth- ers as

Rx(α) = Rz(π/2)· Ry(α)· Rz(π/2). (2.8)

Phase Gate

If a global phase δ is applied to a state, the re- sult will be e|Ψi. A phase shift gate will not alter the result of the circuit, because upon measuring a state |Ψi, the probabilities are only related to the magnitudes, not their phases. This fact is a key component in the Grover algorithm, discussed below. e|Ψi and

|Ψi are then indistinguishable, because they will give the same result when measured. We get the matrix

P h(δ) = e1 0 0 1



. (2.9)

The purpose of this gate then is to make sure the state is in the right phase after the rotation around the Bloch sphere [Williams, 2011].

The Pauli Gates

The X-gate represents the bit-flip and is equivalent to the classical NOT-gate as it maps |0i to |1i and |1i to |0i by rotating the state π radians around the x-axis. How- ever, we also need to compensate for the phase

(13)

change with the phase shift matrix.

X = Rx(π)· P h(π

2) =  0 −i

−i 0



· i1 0 0 1



=0 1 1 0



. (2.10)

The Z-gate represents the phase-flip and will leave the |0i unaffected and negate the magnitude of the |1i state with a rotation around the z-axis with π radians so that it becomes − |1i, but just as in Eq. (2.10) we also need to compensate for the phase change.

Z = Rz(π)· P h(π 2) =

1

i 0 0 i



· i1 0 0 1



=1 0 0 −1



. (2.11) The Y -gate is identical to the combined op- eration iXZ and will map|0i to i |1i and |1i to

−i |0i with a rotation around the y-axis with π radians and a phase shift [Williams, 2011].

Y = Ry(π)· P h(π) =0 −1

1 0



· −11 0 0 1



= 0 −i

−i 0



. (2.12)

Hadamard Gate

The Hadamard transform is a discrete Fourier transform in 2n dimensions. The Hadamard matrix Hn can be calculated recursively by:

H0 = 1, H1 = 1

√2

1 1 1 −1



Hn = 1

√2

Hn−1 Hn−1 Hn−1 −Hn−1



= H1⊗ Hn−1 (2.13)

The 2n-dimensional Hn maps n qubits to a superposition of all 2northogonal states of the Hilbert space with equal probability. The op- erator representation for one qubit is

H = |0i + |1i

√2 h0| + |0i − |1i

√2 h1| (2.14)

where it will pick up the first term if the qubit is in state |0i and the second if the qubit is in state |1i corresponding to the signs in Eq.

(2.14). The Hadamard gate will transform the state of the qubit onto the Hadamard basis {|+i , |−i} by performing the transformation

|0i → 1

√2(|0i + |1i) = |+i

|1i → 1

√2(|0i − |1i) = |−i .

In the Hadamard basis we will be able to alter the phase, an operation which is impossible to do on the classical bit. This property is one source of the power of several quantum algo- rithms.

It is possible to construct the Hadamard ma- trix using the gates in the universal set S by the combination of two rotations; π radi- ans around the X-axis followed by π/2 radians around the Y-axis, and lastly a phase shift.

H = Rx(π)· Ry

2)· P h(π 2)

= 0 −i

−i 0



·

"

2

2

2 2

2 2

2 2

#

· i1 0 0 1



= (−i)i

√2 2

0 1 1 0



·1 −1 1 1



= 1

√2

1 1 1 −1



. (2.15)

This is not necessarily the best way to con- struct the Hadamard gate in the hardware of a quantum computer or even when construct- ing the matrix in a simulation of a quantum computer. It just shows that it is possible to build it with these gates, that the setS is uni- versal, and that we don’t need any other gates, even if it may not be the best way to build the larger gates.

Controlled-Universal Gate

In Grover’s algorithm we need a controlled op- eration to do “if-then-else” tasks. For exam- ple: "negate the second qubit (the target) if and only if the first qubit (the control) is in

(14)

the state |1i". This example describes the controlled-NOT gate cNOT, which is analo- gous to the classical XOR gate. However, since the control qubit can be in a superposition, the target qubit may become entangled.

cN OT = P0⊗ I + P1⊗ X =

1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0

 (2.16) In the cNOT-gate we use the projection op- erators Pi|ji = δij|ji for the control part as they tell us if a qubit is in state 0 or 1.

P0 =|0i h0| =1 0 0 0



P1 =|1i h1| =0 0 0 1



(2.17) In the circuit it has the symbols visualized in Fig. (2.3).

|1i • |1i

|1i |0i

Figure 2.3: cNOT with the first qubit as the control and second qubit as target

We can generalize the cN OT -gate by con- sidering the target to be rotated a certain amount around an arbitrary axis by using the rotation matrices. If applied to the system on two qubits with the first qubit as control and the second qubit as target we get

cU = P0⊗ I + P1⊗ U =

1 0 0 0

0 1 0 0

0 0 U11 U12

0 0 U21 U22

 .

(2.18) Toffoli Gate

An extension of cN OT is the Toffoli gate, also called the controlled-controlled-NOT gate ccN OT . By adding a second control, we can flip the third bit (the target) only if both controls are in state |1i and |1i. Often, the

first two qubits will not purely be in the state

|1i and the operation will be proportional to how close the actual state is to the|1i state.

ccU = P0⊗ P0⊗ I + P1⊗ P1 ⊗ U+

+ P0⊗ P1⊗ I + P1⊗ P0 ⊗ I =

=

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 U11 U12

0 0 0 0 0 0 U21 U22

(2.19)

The Toffoli gate can also be constructed by the gates in the universal set S [Shende V. and Markov L., 2008].

2.2 Grover’s Algorithm

In 1996 Lov Grover presented a quan- tum search algorithm with O(√

N ) steps [Grover, 1996], which is the fastest possible quantum algorithm today. Classically, search- ing an unsorted database of N entries is typ- ically finished with N/2 steps. Grover’s algo- rithm provides a quadratic speed-up, and the allure of such an algorithm is clear.

Start by labeling each item of the database that is to be searched with a corresponding quantum state. Using our n-qubit Hilbert space, the number of qubits n required to com- pletely map the database, follows the relation N = 2n, and our computational basis is de- scribed as {|q0i , |q1i , ..., |qn−1i}. Using our formalism from Eq. (1.3) and choosing n = 3 for simplicity, we can define the ground state of the register as all qubits being in the |0i state, namely

q0

q1

q2 = |000i . (2.20) When we are searching a list, it helps to think of the computational basis as |000i being the state chosen to describe the first entry, |001i

(15)

|q0i : |0i H |0i+|1i2

|q1i : |0i H |0i+|1i2 ...

|qn−1i : |0i H |0i+|1i2

Figure 2.4: Initialization of the register with the Hadamard gate

the second, and so forth. In this way, we have mapped 3 qubits to 23 entries. For example, this means that the second entry in our list is described by the state where qubits 1 and 2 have eigenvalue Sz = ~/2 and qubit 3 has Sz = −~/2. However, this mapping is not exclusive to qubits since classical bits also have 2 states and can be mapped in the same way.

The real supremacy of the qubit comes when it is put in a superposition, which is done by the Hadamard gate during the initialization.

2.2.1 The Algorithm

Initializing

We initialize the n qubit register|0i⊗nwith the Hadamard gate as shown in Fig. (2.4). This puts the qubits in an equal superposition of all N = 2n basis states, shown in Eq. (2.21).

Note that as in Fig. (2.2), the application of n H1 gates is equivalent of applying one Hn gate over the whole register. This linear prop- erty is convenient when we examine the effect of this operation algebraically, because we can use the 2n-dimensional Hadamard operator Hn

from Eq. (2.13)

|ψi = H⊗n|0i⊗n= Hn|0i⊗n= 1

√N

N −1

X

x=0

|xi . (2.21) The ket |xi is the decimal representation of the state of the register, so in the summation

|0i = |000i , |1i = |001i, and so on. The regis- ter can now be graphed.

Figure 2.5: The equal amplitudes of the regis- ter |ψi = H⊗n|0i⊗n after initialization.

Marking

Define the solved problem (e.g. which state in the computational basis that maps to the sought-after database entry) as the unique state |ti that satisfies the following property for a Boolean function F

F (x) = 1 for x = t

0 for x6= t 0≤ x ≤ N − 1.

(2.22) Using this criterion, we can construct an ora- cle, whose purpose is to returns −1 upon be- ing "asked" the correct question t and 1 other- wise. This selection process is called marking because the oracle recognizes the solution by marking the sought-after state in the compu- tational basis with a negative sign and leaves the rest unaltered. The oracle is then defined as

O|xi = (−1)F (x)|xi . (2.23) Herein lies the Achilles heel of the algorithm, because it is not clear how the oracle is con- structed. Being a black box, the oracle is as- sumed to be provided to the quantum com- puter a priori, or at least be computed exter- nally and will most certainly have a different time complexity than theO(√

N ) we promised earlier. Additionally, the oracle must still be implemented as a quantum gate, obeying re- versibility. In practice, a 3-qubit oracle has

(16)

Figure 2.6: The amplitudes of the register O|ψi = OHn|0i⊗n after querying the oracle once. Mean amplitude µ included.

been implemented by [Figgatt et al., 2017] us- ing a number of X and ccN OT -gates to pro- duce the correct mark.

Returning to our demonstrative case of n = 3 qubits, the matrix representation of an oracle O could be

O =

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 1 0 0 0 0 0 0 0 0 1

. (2.24)

This oracle will mark the state |101i, which, by using the decimal representation from Eq.

(2.21) is the state |x = ti = |5i. Using Eq.

(2.21) and Eq. (2.23), we arrive at the state

O|ψi = 1

√N

N −1

X

x=0

(−1)F (x)|xi . (2.25)

The effect of the marking is shown in Fig.

(2.6).

While this looks promising since the marked state |ti is clearly distinguishable from the unmarked ones, a measurement of this state will unfortunately yield no useful result since

the magnitudes, and by extension, probabili- ties are still equal. The oracle has merely ro- tated the phase of the correct question |ti by θ = π Thus, we need to invoke amping to fur- ther modify the amplitudes by converting the phase difference to a magnitude difference.

Amping

The goal of the amping stage is to amplify the marked state at the cost of the unmarked ones.

To do this, we calculate the mean, µ (shown in Fig. (2.6)) of the amplitudes, and then in- vert around it. The result will be a drop-off of the states above the mean (i.e. the un- marked ones), and a large boost to the marked state, as shown in Fig. (2.7). However, we will never explicitly calculate any averages.

Instead, we use the inversion-about-the-mean operator U = 2|ψi hψ| − I, which does all of this for us. We can prove that U really gets the job done by the following theorem.

Theorem 1. The operator U = 2|ψi hψ| − I, where |ψi is the equal superposition

1 N

PN −1

x=0 |xi = 1N |ii, applied on a register inverts each state about the mean.

Proof. Consider the effect of U on the gen- eral state PN −1

k=0 αk|ki. Then U αk|ki = P

ijk 2

Nαk|ii hj|ki − αkI|ki = P

ijk 2

Nαj|ii − αk|ki = {k → i} = P

ij2N1αj|ii − αi|ii . Since αk|ii hj|ki = αj|ii, and the definition for the mean, µ = P

j 1

Nαj, We now have:

P

ij2N1αj|ii − αi|ii = P

i[2µ− αi]|ii, which inverts each amplitude αi around µ.

The effect of U is shown in Fig. (2.7).

This figure shows that the unmarked states

|x 6= ti are reduced by 4/N√

N , while the marked state |ti has grown from 1/√

N to

3−4/N

N . At measurement,|ti is now distinguish- able from |x 6= ti, but we can do even better with more iterations, which will further am- plify |ti, and reduce |x 6= ti.

How do we implement the amping U ? We have provided its operator representation, and proved that it is an inversion about the mean,

(17)

Figure 2.7: The amplitudes of the register (2|ψi hψ|−I)O |ψi after one iteration through the Grover algorithm.

k

|0i H

Oracle H

2P0− I H

|0i H H H

|0i H H H

Figure 2.8: The complete Grover algorithm with k ∼ O(√

N ) iterations.

but we need a set of gates to actually per- form it. As mentioned in the subsection about marking, the qualitative goal of the amping U is to utilize the phase difference between the states and convert it to a magnitude difference.

For such an operation, the Hadamard Trans- form springs to mind, and it turns out that we can use the interpretation of the Hadamard gate as a Discrete Fourier Transform to per- form just that. From Theorem (1) and Eq.

(2.21), we can rewrite U = 2|ψi hψ| − I to Hn(2|0i⊗nh0|⊗n − I)Hn. Recall the projec- tion matrix P0 = |0i h0|, and we can thus write U as Hn(2(P0)⊗n− I)Hn. The complete Grover algorithm in operator representation is then written [Hn(2(P0)⊗n− I)HnO]kHn|0i⊗n, where k ∼ O(√

N ). This is shown in Fig. (2.8) .

|

O|

/2 /2

G|

|t

Figure 2.9: How the register state evolves in the Grover algorithm

2.2.2 Result Periodicity

How many times do we have to iterate? For simplicity, let k Grover iterations be denoted as

Gk|ψi = [Hn(2(P0)⊗n− I)HnO]kHn|0i⊗n. (2.26) Rewrite the superposition from Fig. (2.5) |ψi in terms of the marked state |ti and the un- marked states |αi = N −11 P

x6=t|xi

|ψi =

rN − 1 N

X

x6=t

|αi + 1

√N |ti . (2.27)

From this, the angle between the state of the register and the unmarked states is hα|ψi = cos θ/2 =

qN −1

N . The register may now be expressed as

|ψi = cosθ 2

X

x6=t

|αi + sinθ

2|ti . (2.28) We are now interested in how much each itera- tion decreases angle between the register state and the marked state, ht|ψi. Approximating a trigonometric identity, we now have θ ≈ sin θ = 2 cosθ2 sinθ2 = 2

qN −1 N

1

N = 2

N −1 N , which is approximately 2/√

N for N  1. The

(18)

number of iterations needed, i.e. the number of θ rotations needed to reach|ti at π/2 is now

k = π/2

θ ≈ π/2 2/√

N = π 4

√N . (2.29)

2.3 Error & Error Correc- tion

2.3.1 Defining the Error

There are different types of possible changes in a qubits state: the Pauli errors include bit flips where the state is flipped: |0i → |1i, and phase shifts |+i → |−i. Another type of er- ror is amplitude dampening, which is outside the scope of this thesis. We have chosen to simplify the effect of decoherence and opera- tion inaccuracy. In reality, a combination of changes might occur. We define the error by a single qubit state change, assuming that the decoherence process only affects the different qubits independently and also assuming only one gate is faulty.

Decoherence is entanglement with a state in the environment and can be written as

E : α|0i + β |1i →

α(|e0i |0i + |e1i |1i)+

β(|e3i |0i + |e4i |1i) (2.30) where |eii are states of the environment that the qubit entangled with and thereby produce an error [Nyman, 2009, Mermin, 2016].

Ideally, no decoherence occurs and the gates will work perfectly. To model the error, we introduce a 1-qubit error gate, either at a noisy channel in the circuit or directly after a gate.

The error gate, E, will perform Pauli errors by rotating through normally distributed angles, with standard deviation σ

E = Rx(α)· Ry(β)· Rz(γ)· P h(δ). (2.31) We have to turn 4π radians to be back in the original state, so it is not interesting to do sim- ulations with rotations above 4π. Below 0.1%

of the values are after the fourth standard de- viation in a normal distribution, and we cut the tail here. 4π divided by eight gives us the maximum interesting value of σ = π2 and we will not use larger values.

2.3.2 Error Correction

Different methods to mitigate errors are avail- able, and we have chosen to implement an error correcting algorithm. Such algorithms are not that common in ordinary computers because one Boolean bit needs a relatively large perturbation, for example a large heat fluctuation or physical impact, to change and the change can only be a bit flip (0 → 1 or 1 → 0). Error detection and correction are more common in communication channels, which can be subjects to noise, and is easily done by simply measuring the bits and re-flip the faulty ones. We could do this if we can check the state in some way, either by knowing the original state or have a check- sum. Additionally is also possible to copy classical bits, and thereby be able to measure differences between different snapshots of the register.

If one were to try to apply this to a quantum system, quantum mechanics would throw multiple gears in the wheel. Even a small perturbation could completely destroy the state. We have more types of errors (e.g phase shifts) that can occur due to the wave particle duality of the wave function; we cannot measure the state to check if it is correct due to the collapse of the superposition; and we cannot copy the state of a qubit due to the no- cloning theorem [Wootters and Zurek, 1982].

The quantum algorithm that we use have to be able to correct for an error without detecting and measuring it. We do so by making sure that we return to the same state independently if an arbitrary change has occurred.

We have implemented Shor’s error cor- recting code. During the first step in the

(19)

algorithm called the encryption, n incoming qubits in the state |φi, are distributed to nine qubits, 9n, highly entangling them.

The algorithm cleverly avoids the no-cloning theorem by a basis transform. The resulting encrypted system is now in a highly entangled Bell state, in 29n Hilbert space. The system is more robust in the encrypted state, and will thereby be more resistant to changes. The algorithm then uses the amplitudes of the larger state to recover the original information in the final part, called the decryption process.

A few things need to be defined before we can get into the details of the algorithm.

We break the Pauli errors down to its two components and build a robust state that is able to withstand for both changes in one qubit.

The Bit Flip Robust State

First thing to be defined is the 3-qubit logic qubit, |ψLi, that will be able to withstand bit flips.

|0Li = |000i , |1Li = |111i . (2.32) This state is achieved by entangling the qubit, in state|ψi, with two ancillary qubits, both in state |0i, with the use of two cNOT -gates as shown in Fig. (2.11).

α|0i + β |1i • •

|0i

)

α|000i + β |111i

|0i

Figure 2.11: Circuit to construct a logic qubit From the logic qubit will we be able to re- cover to the original information of the qubit

|ψi even if a bit is flipped, (|000i → |010i). We can do this decryption to the original state of

|0i or |1i, by a majority vote with the use of the inverse of the operations in Fig. (2.11) and a ccN OT -gate. The state will be the same be- cause the coefficients α and β do not change after the bit flip [Mermin, 2016].

The Phase Shift Robust State

Secondly, we specify the phase shift robust state, and we do this by expanding the Hadamard basis. The Hadamard gate will convert the logic qubit to the phase basis as

H|0Li = |000i + |111i√

2 (2.33)

H|1Li = |000i − |111i

√2 (2.34)

and a phase shift will lead to a change in the sign (|+i → |−i). We want to build a robust state for the signs too and we do this by build- ing logic qubits of the signs as well. We can use the circuit in Fig. (2.11) to do this too,

α|0i + β|1i • • H • •

E

• • H • • α|0i + β |1i

|0i •

|0i •

|0i H • • • • H •

|0i •

|0i •

|0i H • • • • H •

|0i •

|0i •

Figure 2.10: The Shor Code.

(20)

but we need to add the Hadamard gate at the end to end up in the right basis.

The Shor Code

In the Shor error code we start with the encod- ing to the phase shift robust state and then do the bit flip robust state encoding, as shown in the left side of the error gate E in Fig. (2.10), and end up in the state of the highly entangled logic qubit

|0Si =

|000i + |111i

√2

⊗3

(2.35)

|1Si =

|000i − |111i

√2

⊗3

. (2.36) We now examine why this final state |ψSi = α|0Si + β |1Si is so robust.

First we look at what an error in one qubit,

|qii, with initial state |0i does when said bit

|qii is encoded to the phase shift robust state of H|0Li, i.e. the first triplet

EiH|0Li = Ei(|0i00i + |1√ i11i

2 )

= 1

√2((|e0i |0i + |e1i |1i) |00i + (|e3i |0i + |e4i |1i) |11i). (2.37) Similarly if|qii’s original state was |1i:

EiH|1Li = Ei(|0i00i − |1√ i11i

2 )

= 1

√2((|e0i |0i + |e1i |1i) |00i

− (|e3i |0i + |e4i |1i) |11i). (2.38) This is very specifically a change in the first qubit of the first three coupling (in the phase robust state). To generalize this we need to describe the state Eq. (2.37), but with the error in an arbitrary qubit, and the need of a larger basis rises. We expand the phase robust state basis to the Bell basis

{|000i ± |111i ,

|001i ± |110i ,

|010i ± |101i ,

|100i ± |011i}. (2.39)

We use the Bell basis to describe highly entangled states of qubits, and this one will make it possible to describe the distinguished states.

For example can we differentiate between:

• if in state |0i when entangled with a change

in the third qubit: |001i + |110i,

or a change in the second qubit: |010i+|101i

• if in state 1 when entangled with a change in the third qubit: |001i − |110i,

or a change in the second qubit: |010i −

|101i.

If we write Eq. (2.37) in the Bell basis we get Ei|0i =

= 1

2√

2((|e0i + |e3i)(|000i + |111i) + (|e0i − |e3i)(|000i − |111i) + (|e1i + |e2i)(|100i + |011i)

+ (|e1i − |e2i)(|100i − |011i). (2.40) Then do the same for Eq. (2.38).

Ei|1i =

= 1

2√

2((|e0i + |e3i)(|000i − |111i) + (|e0i − |e3i)(|000i + |111i) + (|e1i + |e2i)(|100i − |011i)

+ (|e1i − |e2i)(|100i + |011i). (2.41) This change, either to Eq. (2.40) or to Eq.

(2.41), will only be in one triplet and we can re- store the original state of the encoded qubit by checking the other two triplets ancillary qubits to see if the sign in the Bell superposition has changed. The superposition of the Bell basis is still maintained because the coefficients are the same whether the original qubit decohered from the state |000i + |111i or |000i − |111i.

We do this check and then correction accord- ing to the sign changed with the ccN OT -gate as seen in the right part of Fig. (2.10).

We now describe more closely why the decoding works to get the original state back.

(21)

The state in the Bell basis shows what went wrong and a check of the ancilla is the same as the encoded qubit.

For example:

• if the check of the ancilla shows to be the second line of the right side of Eq. (2.40) we know that the error was a sign flip (phase shift) but no bit flip;

• if the output was the third line we know that the error was bit flip in qubit one, but the sign is right so no phase shift;

and if the output is the fourth line then both the Pauli errors has occurred.

Note that we do not actually measure the original encoded qubit, but rather measure the error so that the original state is left untouched. The state is rebuilt without giving the information about it.

Figure 2.12: Theoretical construction of the circuits producing the cU - and ccU -gate.

= P1

+ P0

I I

U U I

(a) cU -gate.

= P1

+ P0

+ P1

+ P0

• P1 P1 P0 P0

U U I I I

(b) ccU -gate.

(22)

Chapter 3

Simulation & Results

3.1 Simulation in Python

Here we describe how we simulated the quan- tum computer in Python using NumPy with the register as a state vector and the gates as transformation matrices. The one qubit gates are implemented as their 2x2-matrices as they’re written in Sec. (2.1). A gate ap- plied on qubit i in the register with n qubits is written with the identity matrix on the un- affected qubits as

Ui :

q0,...,n 7→

I0,...,(i−1)

⊗ Ui ⊗ I(i+1),...,n q0,...,n

=

q0,...,(i−1)iq(i+1),...,n , (3.1) so the identity matrix ensures the correct di- mension.

The cU -gate Matrix

With the control qubit |qci in position c and the target qubit |qti in position t, we per- mute through the different possibilities, i.e.

the state of the target. This is done by cUc,t = I0,...,(t−1)

⊗ Ut⊗ I(t+1),...,(t+c−1)

⊗ P1c⊗ I(c+1),...,n

+ + I0,...,(c−1)

⊗ P0c⊗ I(c+1),...,n, (3.2) where the first term corresponds to the action of the gate if qubit c is found in state|1i, and the second term corresponds to the action of the gate (i.e. apply U on |qti) if the qubit is found in state|0i. This is achieved by applying P1c, and P0c respectively. This is visualized in Fig (2.12a).

The Toffoli Gate Matrix

The Toffoli gate uses qubits |qc1i and |qc2i as controls and|qti as target. The matrix is con- structed as

ccUc1,c2,t =

I0,...⊗ Ut⊗ I...⊗ P1c1 ⊗ I...⊗ P1c2 ⊗ I...,n + I0,...⊗ P0c1 ⊗ I...⊗ P0c2 ⊗ I...,n

+ I0,...⊗ P0c1 ⊗ I...⊗ P1c2 ⊗ I...,n

+ I0,...⊗ P1c1 ⊗ I ⊗ P0c2 ⊗ I...,n, (3.3) where we need to permute through the four states that the two controls can be in. This is visualized in Fig (2.12b). This is a theoreti- cal application of how to combine the 1-qubit matrices of the cU -gate and might not neces- sarily be convenient to implement outside of simulations.

The Measurement

We implement the measurement of a qubit as a generated random number of 0 or 1, governed by the probability p. If the register is in state

|Ψi we can then express the probability that qubit i is in state 0 by expressing the state vector as a density matrix|Ψi hΨ|, and taking the trace of the state when acted on by the projector P0i

p(

qi = |0i) = T r(|Ψi hΨ| P0i). (3.4) If the random number is 0 then the rest of the register will fall to the state

measuredi = P0i

kP0i|Ψik2. (3.5)

(23)

Iteration Probability of measuring |ti

1 0.6172

2 0.7948

3 0.9468

4 0.9996

5 0.9276

6 0.7656

Table 3.1: How the probabilities in Grover’s algorithm with 5 qubits evolve with the num- ber of iterations. The optimal number of iter- ations is marked in bold.

Figure 3.1: The oscillations of continuous it- erations of Grover’s algorithm

3.2 Grover’s Algorithm

Evolution of Probabilities

As seen in Fig. (2.9), the algorithm has a periodicity, which makes it possible to over- count, and for the qubit state to retract from the target state. Thus, the probabilities os- cillate around the target |ti, as see in Table (3.1), and in Fig (3.1). With n = 5 qubits (i.e.

the graph with 25 = 16 items), the optimal number of iterations is expected to be, as per Eq. (2.29): π4

25 = 4.44. To illustrate the al- gorithm overcounting, 12 iterations were done for each of the three simulations.

n Time [ms]

1 4.01 2 5.01 3 6.02 4 7.02 5 10.0 6 13.1 7 29.7 8 116 9 675 10 4.25· 103 11 2.99· 104 12 2.21· 105 (a) Time taken for π4

2n iterations

(b) Logarithmic time plot for the simulated Grover algorithm to execute π4

2n iterations

Efficiency

Using sparse matrices, the algorithm becomes quite efficient at low qubits. First at n = 10, the calculations become non-instantaneous, finishing at 4.26 s on a machine with eight 2.6 GHz cores. The logarithmic time taken in milliseconds for the algorithm to iterate the optimal number of iterations for each qubit is shown in Fig. (3.2b). This behav- ior is expected, due to the O(n2.8) complex- ity in NumPy matrix multiplications using the Strassen algorithm.

(24)

σ Probability of measuring |0i

π

32 0.5

π

16 0.5

π

8 0.5

π

4 0.5

π

2 0.5

Table 3.2: How the probabilities of measuring 0 changes with σ.

3.3 Grover’s Algorithm with Error

We can place the same error gate from Eq.

(2.31), without any error correction whatso- ever, directly after the oracle in Grover’s algo- rithm to see how resilient it is. In this way, we can simulate an error due to the oracle, or a noisy transportation between the oracle and the amping gate. The error gate is placed on

|q0i to simulate a noisy oracle. This can be ex- tended by applying the 1-qubit gate over more qubits.

3.4 Error Correction Code

Error in One Qubit

We initialized the original qubit to be guarded in a state with probability of measuring either

|0i or |1i to p = 0.5 as:

|ψi = 1

√2(|0i + |1i) (3.6) and the eight rest in state 0. Then we apply the encoding as shown in the left side of Fig.

2.10 followed by the application of the error gate on the first qubit E0|ψ00000000i. We apply the error gate with different standard deviations σ in the distribution of the random angles of Eq. (2.31). We then decode the reg- ister and measure the first qubit to see if it has returned to its original state by checking the probability of measuring |0i. The mea- surements are written in Table 3.2.

We then investigate if the measurement is the same for a 100 runs with the same stan-

σ Probability of measuring |ti

0 0.9996

π

32 0.9912

π

16 0.9669

π

8 0.8908

π

4 0.7298

π

2 0.5710

(a) Table showing the probability of finding the marked state after it applying an error gate directly after the oracle. 4 iterations (optimal) ran for each σ.

/32 /8 /2 No error

(b) Plot of the results with three different stan- dard deviations, along with an unperturbed plot.

Figure 3.3: How the probability of measuring

|ti varies after placing an error gate on |q0i after the oracle with a normally distributed error with standard deviation σ. n = 5, so we expect the first peak to show at π4

25 = 4.44 iterations. Each Grover iteration ran 1000 times to reduce fluctuations.

(25)

dard deviation σ = π/2 and same initial state as in Eq. 3.6. All the measurements gave p(|qi = |0i) = 0.5 and the whole run took around 140 seconds. This means that the in- coming superposition was conserved, and that the error was successfully removed by the al- gorithm.

Error in Two or More Qubits

We initialized the original qubit to be guarded in a state with probability of measuring either

|0i or |1i to p(|q0i = |0i) = 0.5 as in Eq. 3.6 and the eight rest in state 0. Then we apply the encoding, followed by the application of the error gate on an increasing amount (2 to 9) of qubits. We apply the error gate with the same standard deviations σ = π/2 in the distribution of the random angles of Eq.

(2.31) with a new generated angle for each time we apply it to a qubit. We then decode the register and measure the first qubit to see if it has returned to its original state by checking the probability of measuring |0i.

We repeat this for each number of qubits a 100 times and take the mean value of the measurements and the mean value of how much the measurements the differ from 0.5, we write the in Table 3.3 together with the largest and smallest value. Each run took about 140 seconds.

We can conclude that the Shor code works really good for up to six perturbed qubits.

Noticing we get a difference in the algorithms capacity to correct the error between six and seven perturbed qubits called for more runs with error in different qubits around seven per- turbed qubits, with the same initializing and standard deviation. This can be seen in Ta- ble 3.4. There is really a line to be drawn at six qubits with an exception at the combina- tion of 235678 being perturbed. We do not know why this is. We don’t treat any of the qubits from the other, other simulations with six qubits works fine.

3.5 Grover’s Algorithm with Error correction

We were not able to simulate the two algo- rithms together because Grover’s algorithm needs at least two qubits to work and the Shor code adds nine to each. At 18 qubits the memory of the simulating computer runs out because using Grover’s algorithm with n = 2 qubits, we get (non-sparse) matrices with (22·9)2 = 68719476736 elements. If each ele- ment stored as a 8-bit complex float, a single matrix then requires 550 gigabytes of memory.

(26)

perturbed qubits # Mean Max. Min. Mean diff.

0,1 2 0.5000 0.5000 0.5000 0

0,1,2 3 0.5000 0.5000 0.5000 0

0,1,2,3 4 0.5000 0.5000 0.5000 0 0,1,2,3,4 5 0.5000 0.5000 0.5000 0 0,1,2,3,4,5 6 0.5000 0.5000 0.5000 0 0,1,2,3,4,5,6 7 0.4998 0.5370 0.4355 2.0· 10−2 0,1,2,3,4,5,6,7 8 0.5009 0.5416 0.4459 −9.2 · 10−2 0,1,2,3,4,5,6,7,8 9 0.4998 0.5578 0.4052 1.5· 10−2

Table 3.3: How the probabilities of measuring |0i on qubit |q0i, p(|q0i = |0i), changes with different perturbed qubits. # is the number of perturbed qubits. Mean is the mean of the 100 values; Max. is the maximum of the 100 values; Min. is the minimum of the 100 values; and Mean diff. is the mean value of how much the 100 measurements the differ from 0.5.

perturbed qubits # Mean Max. Min. Mean diff.

0,3,6 3 0.5000 0.5000 0.5000 0

0,1,3,4,6,7 6 0.5000 0.5000 0.5000 0 0,1,3,4,6,7,8 7 0.5007 0.5292 0.4778 −7.3 · 10−2 0,1,2,3,4,5,7 7 0.5002 0.5760 0.3922 2.0· 10−2 0,1,2,3,4,5,6 7 0.5008 0.5409 0.4795 −8.0 · 10−2 0,1,2,3,4,5,6,7 8 0.4991 0.5296 0.4149 9.5· 10−2 0,1,2,3,4,5,6,7,8 9 0.4969 0.5255 0.4052 3.0· 10−3 0,1,2,3,4,5,6,7,8 9 0.5021 0.5468 0.4653 −2.0 · 10−3

2,3,5,6,7,8 6 0.5013 0.5495 0.4590 −1.3 · 10−3 2,3,5,6,7,8 6 0.5009 0.5552 0.4588 −1.0 · 10−3 2,3,5,6,7,8 6 0.4990 0.5456 0.4249 1.0· 10−3

0,1,2,6,7,8 6 0.5000 0.5000 0.5000 0 3,5,6,7,8 5 0.5000 0.5000 0.5000 0 3,4,5,6,7,8 6 0.5000 0.5000 0.5000 0 1,2,3,5,6,7 6 0.5000 0.5000 0.5000 0

Table 3.4: How the probabilities of measuring |0i on qubit |q0i, p(|q0i = |0i), changes with different perturbed qubits. # is the number of perturbed qubits. Mean is the mean of the 100 values; Max. is the maximum of the 100 values; Min. is the minimum of the 100 values; and Mean diff. is the mean value of how much the 100 measurements the differ from 0.5. The special combination of six perturbed qubits are in bold.

References

Related documents

By analysing the movement of electrons in a magnetic field classically and quantum mechanically information about the integer quantum Hall effect and the fractional quantum Hall

Nonrelativistic quantum gravity, e.g., shows promise for prohibiting black holes altogether (which would eliminate singularities and also solve the black hole information

This, the actual observation, has long been suspected in many interpretations of quantum mechanics to be what makes the transition quantum → classical, but so far it has not

The quantum measurement problem is the most fundamental ques- tion of all: How the ghostly quantum mechanical coexistence of many mutually incompatible possibilities result in

Definition 2.2.1. Classical circuits, which are sequences of logic gates and can thus be represented as functions, are clearly not all reversible. Consider the OR gate for example.

Figure 27: Measurement of quantum walk search algorithm for a complete bipartite graph with 8 nodes after 2 iterations on noise-free simulator with node 011 marked.. The

The purpose of this note is to take the conjecture seriously and consider the remain- ing corner (from a type II point of view), where string loop corrections, i.e., quantum

•  Any operation on a set of qubits can be reduced to a finite sequence of gates from a universal set