post2644 grovers quantum sear

15
8/17/2019 Post2644 Grovers Quantum Sear http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 1/15 Home Portfolio Contact Blog Grover’s Quantum Search Algorithm posted by Craig Gidney on March 5, 2013 Grover’s algorithm is a quantum search algorithm that runs quadratically faster than any equivalent classical algorithm. With a budget of a million operations, a classical algorithm is limited to searching through about a million unsorted, unstructured! possibilities. Grover’s algorithm, on the other hand, can use those million operations to search through hundreds of billions of possibilities. "escribing ho# Grover’s algorithm pulls this tric$ is difficult, because it uses concepts fundamental to quantum mechanics. %nstead of chec$ing possibilities one by one, it #arning& incoming 'argon! creates a uniform superposition over all possibilities and repeatedly destructively interferes states that are not solutions. Hopefully, by the end of this post, you’ll understand qubits, quantum circuits, maybe a little bit of quantum mechanics, and of course! Grover’s algorithm. Search a Function umping ahead a bit, % need to ma$e one important concept clear right a#ay& Grover’s algorithm doesn’t search through lists, it searches through function inputs . Grover’s algorithm ta$es a function, searches through the implicit  list of possible inputs to that function, and #ith high probability! returns the single input that causes the function to return true. )o deal #ith cases #ith more than one satisfying input, #e need a variant of Grover’s algorithm.! )he follo#ing C* code solves a problem equivalent, in spirit, to #hat Grover’s algorithm solves. %t uses an entirely different approach, but solves the same basic problem& int FindSingleSatisfyingInput(Func<int, bool> predicate, int inputRange) { int solution = 0; int resultount = 0; for (int i = 0; i < inputRange; i!!) { if (predicate(i)) { solution = i; resultount != "; # # if (resultount $= ") { %% &iolated t'e eactly one solution constraint %% *arbage in, probable garbage out return Rando+Result(0, inputRange); # return solution; # Page 1 of 15 Grover’s Quantum Search Algorithm | Twisted Oak Studios log !"#$"#%1& htt'(""twistedoakstudios)com"*log"Post#&!!+grovers,-uantum,search,algorithm

Upload: bhar

Post on 06-Jul-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 1/15

Home Portfolio Contact

Blog

Grover’s Quantum Search Algorithmposted by Craig Gidney on March 5, 2013

Grover’s algorithm is a quantum search algorithm that runs quadratically faster than any equivalent

classical algorithm. With a budget of a million operations, a classical algorithm is limited to searching

through about a million unsorted, unstructured! possibilities. Grover’s algorithm, on the other hand, can

use those million operations to search through hundreds of billions of possibilities.

"escribing ho# Grover’s algorithm pulls this tric$ is difficult, because it uses concepts fundamental to

quantum mechanics. %nstead of chec$ing possibilities one by one, it #arning& incoming 'argon! creates auniform superposition over all possibilities and repeatedly destructively interferes states that are not

solutions.

Hopefully, by the end of this post, you’ll understand qubits, quantum circuits, maybe a little bit of

quantum mechanics, and of course! Grover’s algorithm.

Search a Function

umping ahead a bit, % need to ma$e one important concept clear right a#ay& Grover’s algorithm doesn’t

search through lists, it searches through function inputs . Grover’s algorithm ta$es a function, searches

through the implicit  list of possible inputs to that function, and #ith high probability! returns the single input that causes the function to return true. )o deal #ith cases #ith more than one satisfying input, #e

need a variant of Grover’s algorithm.!

)he follo#ing C* code solves a problem equivalent, in spirit, to #hat Grover’s algorithm solves. %t uses an

entirely different approach, but solves the same basic problem&

int FindSingleSatisfyingInput(Func<int, bool> predicate, int inputRange) {

int solution = 0;

int resultount = 0;

for (int i = 0; i < inputRange; i!!) {

if (predicate(i)) {

solution = i;resultount != ";

#

#

if (resultount $= ") {

%% &iolated t'e eactly one solution constraint

%% *arbage in, probable garbage out

return Rando+Result(0, inputRange);

#

return solution;

#

Page 1 of 15Grover’s Quantum Search Algorithm | Twisted Oak Studios log

!"#$"#%1&htt'(""twistedoakstudios)com"*log"Post#&!!+grovers,-uantum,search,algorithm

Page 2: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 2/15

% really can+t stress this point enough& Grover+s algorithm searches a function for a single satisfying input.

%f you #ant to search through an eplicit list of items, then you need a function bac$ed by said list.

-nderstanding ho# to do that is outside the scope of this post, so %+m going to stic$ to searching

functions.

o, if Grover+s algorithm searches a function, ho# is that function represented/ Good question. %+ll get

bac$ to that.

Like probability theory, but over the complex numbers

0y favorite summary of quantum computing, from a tal$ called 1uantum information and the Brain by

cott 2aronson, goes as follo#s& 34i$e probability theory, but over the comple numbers3. %t is my

favorite summary because, unli$e misleading oversimplifications li$e 3it tries every possibility3, you can

actually use 34i$e probability theory, but over the comple numbers3 to ma$e a reasonable guess at ho#

quantum algorithms #ill #or$.

5or eample, ho# do #e describe the state of a probabilistic system/ Well, each possible state is

associated #ith a real number bet#een 6 and 7 the probability!, #ith the constraint that if #e add up allof the probabilities #e #ill get 7. 5lip a coin and, before the coin lands, the result of the flip is in the state

. %f the coin lands on heads then the result of the flip is in the state .

Ho# do #e describe the state of a quantum system/ 4i$e probabilities, but comple. 8ach possible state

is associated #ith a comple number #ith magnitude absolute value! bet#een 6 and 7 the amplitude!.

)he squared magnitude of a state+s amplitude is the probability of that state, so #e have the constraint

that the squared magnitudes of the amplitudes must add up to 7. Because many different amplitudes

can result in the same probabilities, our coin flip eample no longer has a unique representation. Before

the coin is flipped, the result of the flip could be represented as the state , the state

, or many other possibilities.

5or another eample of summary goodness, consider ho# transitions bet#een states can be

represented. Probabilistic systems allo# operations li$e 3%f in state 9 then go to state : #ith ;6<

chance3. %t turns out that these operations can al#ays be represented as linear transformations&

multiplying the vector of states=#eighted=by=probabilities against a matri. )here+s actually a name for

the type of matri that corresponds to a probabilistic operation& stochastic.

Ho# are quantum transitions represented/ 4i$e stochastic matrices, but comple. 2ll quantum

operations are equivalent to a unitary matri. >no#ing that, #e can derive further properties li$e

3operations must be reversible3.!

o a quantum algorithm #ill necessarily loo$ li$e... a bunch of carefully chosen matri multiplications

involving imaginary numbers! to ma$e +solution+ states have large amplitudes. Hurray. )he larger the

amplitudes of the solution states, the more li$ely it #ill be that the problem is solved #hen the quantum

computer+s state is un=isolated and reported.

Working with omplex !umbers

Page # of 15Grover’s Quantum Search Algorithm | Twisted Oak Studios log

!"#$"#%1&htt'(""twistedoakstudios)com"*log"Post#&!!+grovers,-uantum,search,algorithm

Page 3: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 3/15

%f you+re completely unfamiliar #ith comple numbers, they+re introduced very #ell during Ho# to 5old a

ulia 5ractal, by teve Wittens creator of 0athBo!. He starts #ith rotations  of normal numbers #ith a

7?6@ turn being equivalent to multiplying by =7! and then notes that a A6@ turn is suspiciously similar to

the result of a negative square root...

)he overall state of a quantum computation is made up of comple numbers referred to as amplitudes.

%+ll often be representing amplitudes using #hat % call a 3square diagram3, #hich visually represents thevarious components of a comple number&

)he arro# rooted in the center of the diagram points to the comple value of the amplitude. )he real

part is the offset of the arro#, the imaginary part is the offset, the magnitude is the length of the

arro#, and the phase is related to the direction of the arro#. Because the squared magnitude of an

amplitude is also an important value, since it determines the probability of a state, it is represented by

the proportion of filled=in area of the unit radius square #idthDheightD9! surrounding the arro#.

)reating comple numbers as arro#s is a useful intuition. When Eichard 5eynman gave a lecture on

quantum mechanics intended for non=physicists, he too$ advantage of this and only mentioned in

passing that these +spinning arro#s+ #ere equivalent to comple numbers. 2fter all, adding is as easy as

placing arro#s end to end&

)he fact that arro#s clearly sho# magnitude and phase also ma$es multiplication easier to visualiFe,

because the effect on the phases is independent of the effect on the magnitudes. )o multiply t#o

comple numbers, you add their phases and multiply their magnitudes&

Page 3 of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 4: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 4/15

)o represent #hat happens during a linear transformation matri multiplication, % combine the above

multiplication and addition animations. %n the follo#ing animation, a vector of t#o state amplitudes

each amplitude corresponds to a possible state! is transformed by a unitary matri, using a combination

of the multiplying and summing animations&

otice ho# the matri multiplication mies both input state amplitudes the blue values initially on the

left! into the t#o output state amplitudes the eventual blue values on the right! through the operation of

the matri the yello# values in the middle!. 8ach input may reinforce or counteract the effect of otherinputs due to differences in phase. )his ability to create interference may seem li$e a bad thing, but it+s

actually #hat gives quantum computers their po#er compared to a probabilistic or classical computer

#ith no phase information.

Quantum ircuits

Ho# do #e represent a quantum computation/ Ine #ay is quantum circuits, #hich are made up of a

fied number of #ires going through a sequence of gates.

)he #ires of a quantum circuit correspond to qubits, and store the state of the system. % say qubits,

instead of bits, because the system can be placed into superpositions of the various possible classicalstates. 2 system #ith bits has possible classical states, but a system #ith qubits has a continuum

of quantum states corresponding to various amplitude=#eightings superpositions! of the classical

states.

)he state space of bits can be visualiFed as the corners of an dimensional cube maybe 3visualiFed3 is

the #rong #ord!, #hereas the state space of qubits can be imagined abstractly as the points in the

volume of a dimensional sphere e.g. the Bloch sphere!.

Page " of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 5: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 5/15

5or eample, if there are t#o #ires then the quantum system can be in a pure classical state li$e

, corresponding to both #ires definitely being on, or in a mied

state li$e , corresponding to $no#ing eactly one #ire is on but

not #hich one it is. )hese states can be represented more compactly in bra=$et notation as and

, respectively.! )he phases of the states matter #hen interference occurs.

)he gates of a quantum circuit correspond to operations to perform on the #ires+ state. 8ach one is

equivalent to a multiplication of the state by a unitary matri.

4ets start #ith a nice simple eample of a quantum circuit. )he simplest gate % can thin$ of is the I)

gate, #hich flips the InIff state of a single #ire&

%n the above diagram, you can see that applying a I) gate corresponds to multiplying the state of the

system by the unitary matri . )he input is in the In state, #hich effectively selects the first

column of the matri as the output, resulting in an Iff output state. %f the input had been in the Iff

state, then the second column #ould have been selected and the output #ould have been in the Instate.

)he I) gate is pretty boring. %t can be performed in non=quantum computers, after all. Ho# about a

simple quantum gate #ith no classical equivalent/ 8nter the Hadamard Gate, corresponding to the

matri and used for creating uniform mies. ho#n belo#& an initially=In state blue!

and an initially=Iff state red! are mied and unmied by Hadamard gates.

Page 5 of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 6: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 6/15

The Hadamard Gate is interesting because it transforms both On and Off states into a mixed 50% On/Off

state but, when applied again, undoes its own effects and restores the original state. This would be

impossible with a classical or probabilistic computer, because the 50%/50% input would hae to gie the

same result in both cases. !f "ou pa" close attention to the aboe animation, "ou can see how the magic

wor#s$ the original alue is encoded into the phases of the 50%/50% state the phases agree if the

original state was On and disagree if it was Off&.

More Wires

Things get a bit more complicated when there are more wires present. 'uppose we want to appl" a

Hadamard gate to a single wire in an wire circuit. (e hae a )b") matrix, but an" operation on an

wire circuit must be represented b" )b") matrices. How do we conert it, to simulate what nature

does automaticall"*

+eep in mind that the state of the wire we want to affect isnt confined to out of the possible states)

of)all)wires the possible global states&. -er" possible global state includes the state of the wire we want

to affect. !f we want to touch one wire, we must touch eer" global state.

The basic idea of what needs to be done, which is a bit tric#" to write down mathematicall", is to repeat

our )b") matrix for eer" combination of states of the other wires. !f there are two wires then we need

one cop" for when the other wire is On and one cop" for when the other wire is Off.

The following diagram shows a )wire circuit that applies a Hadamard gate on one wire and then on the

other. otice how the repeated entries of the )b") Hadamard matrix are placed differentl" based on

the wire being affected$

n interesting propert" of Hadamard gates, which "ou might hae noticed in the aboe diagram, is that

appl"ing them to multiple wires has the same mixing effect as the single)wire case. -er" pure input

state will become a uniforml" mixed output state, with the original state encoded into the phases, and

appl"ing the gates again will unmix the mixed state bac# into the original pure state.

'ince appl"ing a Hadamard gate to each of wires acts so much li#e appl"ing a Hadamard gate to wire,

it ma#es a lot of sense to pretend we hae Hadamard gates that operate on an" number of wires. The

following diagram shows an example of a )wire Hadamard gate in action, which is actuall" under the

hood& a Hadamard gate on each wire$

Page 6 of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&16htt'(##twistedoastudios)com#*log#Post$6""+grovers,-uantum,search,algorithm

Page 7: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 7/15

'hown aboe$ an initiall")OnOn state blue& and an initiall")OffOff state red& are mixed and unmixed b"

a combined )wire Hadamard gate. The matrix representing the operation of a combined gate is

obtained b" multipl"ing the matrices of the underl"ing gates together.

There are man" other common 1uantum gates. Howeer, since Groers algorithm is almost entirel"

made up of Hadamard gates, ! wont be coering them here.

Detour: Simulating a Physical System

(e can simulate real ph"sical s"stems with 1uantum circuits, and doing so can be useful for grounding

our understanding in concrete examples. 2or example, consider the 3ach)4ehnder interferometer$

The 3ach)4ehnder interferometer is an interesting optical s"stem. !t uses a beam splitter to split an

incoming photon along two paths, and then uses a second beam splitter to recombine the two paths into

a single output path. 'end a photon in from the left on path & and it will alwa"s exit towards the right

on path H&, neer towards the bottom on path G&. The reason this occurs is that contributions to G from

- and from 2 destructiel" interfere.

(e can represent the 3ach)4ehnder interferometer as a 1uantum circuit using onl" a single wire. The

state of the wire represents whether the photon is on the upper path ,,-,G& or the lower path

6,7,2,H&. (e will use gates to simulate the beam splitters and mirrors. mirror rotates a photons phase

b" 809, and since both paths hae a mirror at the same position we can use the matrix to

represent their effects. -ach beam splitter reflects the photon onto the opposite path also rotating its

phase b" 809& or lets it through unaffected, and can be represented b" the matrix $

Page % of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&16htt'(##twistedoastudios)com#*log#Post$6""+grovers,-uantum,search,algorithm

Page 8: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 8/15

otice how the aboe animation shows an input of giing a definite output of H. Our circuit predicts

the result of the ph"sical s"stem. The destructie interference from - and 2s contributions can be clearl"

seen in the summation of the top row of the matrix of the last splitter.

ow to ma#e things a bit more interesting.

One of the counter)intuitie things about 3ach)4ehnder interferometers is what happens when "ou use

a detector to determine whether the photon :reall": too# the upper or lower path. The interference goesawa" ;&$

!n the aboe diagram a detector has been placed on path -. otice the appearance of opposing waes

traeling along G, instead of no wae. (h" arent the opposing waes interfering destructiel" an"more*

an we use a 1uantum circuit to shed light on this* <up.

To represent the state of the detector on path -&, we need to add a second wire to our circuit. The

operation of the detector will be performed b" a controlled)OT gate$ when a photon passes through -

i.e. the first wire is On&, the state of the detector second wire& is flipped$

Page 8 of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 9: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 9/15

Good$ the aboe diagram shows the output of our circuit also isnt showing an" interference, matching

the ph"sical s"stem. -ach possibilit" G, G=detect, H, H=detect& has an e1ual 5% chance of being

obsered.

The reason we dont get interference an"more comes down to the necessar" addition of the second wire,

increasing the number of possible states from to . (e no longer need to >am four possible paths into

ust two output states, creating interference effects. !nstead, were effectiel" using the detector to sendeach possible path to its own output state. ?hotons from different states dont interfere, een if the"

happen to be at the same position, because onl" entire states interfere.

! hope this detour has been helpful. (e now return to Groers algorithm.

The Unknown Gate

! mentioned earlier that ! would get to how the function)to)be)searched)b")Groer was represented.

ow that !e coered the basics of a 1uantum circuit, ! can finall" explain it.

The input to Groers algorithm is actuall" a gate, or combination of gates, whose function is un#nown.2or example, if we wanted to sole a large instance of the boolean satisfiabilit" problem, then the

un#nown gates& gien to Groers search algorithm would compute whether an input satisfies a boolean

e1uation. Gien a pure state that is not a solution, the gates must pass it along unchanged. Gien a pure

state that is  a solution, the gates must rotate the states amplitudes phase b" @A09.

2or wires, there are allowed possibilities for the effect of the un#nown gates&$

Groers algorithm will distinguish between these four possibilities. This might sound pointless, but

remember that as the number of wires goes up the matrices become exponentiall" huge. (ith wires,

theres about a trillion places for that to hide. lso, remember that in practice we wouldnt be

explicitl" pic#ing the position of the . !nstead, wed be implicitl" constraining its position b" proiding

gates that sole a problem when gien the right input.

Page 9 of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 10: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 10/15

The technical term for the un#nown/unspecified gate is :1uantum oracle:. !m >ust going to #eep calling it

the un#nown gate/gates/operation/whateer.

Grover's Gates

The soul of Groers algorithm is an operation that computes the aerage of all the amplitudes, and then

inerts all of the amplitudes through that aerage and additionall" negates all the amplitudes&. This

operation is referred to as the :Groer 7iffusion Operator:, and it is built out of Hadamard gates

surrounding an operation that inerts the phase of the first state.

'hown below$ an OnOn state, the onl" one with opposite phase in the initial uniforml" mixed input state,

is found b" the diffusion operator.

The input state in the aboe diagram has three states with an amplitude of and one state with an

amplitude of . The aerage of these four amplitudes is . The states with amplitude go from

to . The state with amplitude goes from to .

2or an explanation of wh" the diffusion operator is an inersion)about)the)mean, see these lecturenotes.

s the aboe diagram demonstrated, the diffusion operator can enhance the amplitude of a single

discordant phase. ombine this #nowledge with the fact that the un#nown gate rotates the phase of the

solution state b" @A09, ma#ing it different from the other states, and suddenl" the mechanism of

Groers algorithm becomes clear. Bse the un#nown gate to ma#e the solution states amplitude

different from the other states amplitudes, then use the diffusion operator to amplif" the difference,

and repeat until the difference is non)negligible.

! call the repeated part of Groers algorithm the Groer 'tep$

Page 1& of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 11: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 11/15

Above: the unknown gate flips the phase of the "On,Off" state of a uniformly mixed input, and then the

diffusion operation 'finds' this flipped phase. Only a single iteration is needed to find the solution when

there are two wires.

Now we have all the elements needed to put the full algorithm together. he input to the !ir!uit is all

wireson. he first thing the !ir!uit does is apply a #adamard gate that, be!ause of the input state we

!hoose, will !reate a uniform mix where every state has an amplitude of . hen the !ir!uit applies the

$rover %tep &that !ontains the unknown gate that determines what we're looking for an appropriate

number of times, amplifying the soughtafter solution state until the probability of observing it when the

wire states are measured is maximi(ed.

)elow: finding the solution "Off,On,On,On,On", out of a spa!e of si(e , in $rover %teps. he matrix

multipli!ations and underlying states are not shown in the diagram be!ause they're too large & by

to fit !omfortably.

Noti!e that the !orre!t solution is the most likely answer after *ust one step, but it takes three more steps

before the solution is near!ertain to be observed. &+arning: the probabilities shown for ea!h individual

wire being in the !orre!t state are partially dependent. he probability of a!tually observing the solution,

i.e. every wire being in the right state, progresses as follows: , , , , .

Counting Steps

#ow did - know to apply four iterations when there were five wires #ow many iterations of the $rover

step do we need to apply, in general /ets do a bit of math.

%uppose we're sear!hing through a state spa!e of si(e , re0uiring wires &assume is a

power of 1. )efore the first $rover step, all the amplitudes will be e0ual to . /et be the amplitude

Page 11 of 15Grover’s Quantum Search Algorithm | Twisted Oak Studios log

!"#$"#%1&htt'(""twistedoakstudios)com"*log"Post#&!!+grovers,-uantum,search,algorithm

Page 12: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 12/15

of the state we want to find, after step , and be the amplitude of the other states. +ithin the

$rover %tep, the unknown operation will negate the target amplitude and then the diffusion operator will

invert about the mean amplitude . he next amplitudes are

and .

he probability that the measured result will be the target state, after a given step, is . %hove the

above e0uations into 2x!el, graph the !han!e of su!!ess against various numbers of steps and problemsi(es, and you get:

One interesting thing to note here is the periodi! behavior. -f we apply too many steps, the !han!e of

su!!ess starts going ba!k down &and then ba!k up, and ba!k down, and...3 Also, the a!hievable

probability of su!!ess is not always 455. he best number of steps is, presumably, *ust shy of things

going downhill for the first time.

6isually, - !an tell from the graph that the best number of steps is going up slower than . 7ore analysis

of the math will show it takes approximately steps to rea!h the first maximal !han!e of su!!ess.

hus !lassi!al algorithms are !omparatively slower and slower, as the problem gets larger and larger,

be!ause they must take a linear number of steps with respe!t to .

Summary

$rover's algorithm sear!hes for satisfying inputs to a fun!tion by !reating a uniform 0uantum

superposition of states, and then !an!elling out nonsolutions. -t repeatedly applies an operation

&representing the problem to solve that only inverts the phase of the solution, and then an operationthat amplifies amplitudes that are different, until the most likely resulttomeasure is the solution.

Discuss on Hacker News, Reddit

2 Responses to “Grover’s Quantum Searc !"goritm#

Page 1# of 15Grover’s Quantum Search Algorithm | Twisted Oak Studios log

!"#$"#%1&htt'(""twistedoakstudios)com"*log"Post#&!!+grovers,-uantum,search,algorithm

Page 13: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 13/15

4. te!hroa!h  says:

%eptember 48, 1549 at 8:1 am

Awesome post3 - always wanted to know more about ;uantum algorithms. he

visuali(ations made everything so mu!h simpler. )ut - guess -<ll have to read it on!e or

twi!e more to get a !omplete understanding.

1. =evin li  says:

 >anuary ?, 154? at @:?1 pm

2x!ellent post3 -t explained in 15 minutes what hours on +ikipedia and ouube !ouldnt

Twisted Oak Studios offers consulting and development on high-tech interactive projects. Check out our

 portfolio, or Give us a shout if you have anything you think some really rad engineers should help you with.

!rcive

B strilan!B +hat ;uantum Computers Do Easter, with CaveatsB Naming hings: EailFsefulB Dete!ting %imple Cy!les Eorming, EasterB hird Garty )it CommitmentB Angular 6elo!ity is %impleB Colle!tion 20uality is #ardB Deadlo!ks in Gra!ti!e: Don<t #old /o!ks +hile NotifyingB )rute Eor!e Garalleli(ationB A ear<s +orth of Opinions about Ob*e!tiveCB Heferen!ing %ubstrings Easter, without /eaking 7emoryB Not Crying Over Old Code

B 2xploring Fniversal ernary $atesB -mpra!ti!al 2xperiments I1: %e!uring Geer to Geer Eog of +ar against 7ap #a!ksB A!hieving 2xponential %lowdown by 2numerating wi!eB Fsing -mmortality to =ill A!!idental Callba!k Cy!lesB Can!ellation okens &and Collapsing Eutures for Ob*e!tiveCB 6isuali(ing the 2igenve!tors of a HotationB Collapsing Eutures in Ob*e!tiveCB )ug #unting I4: $arbled Audio from 2nd to 2ndB -mpra!ti!al 2xperiments I4: Hepresenting Numbers as GolynomialsB -mplementing ;uantum GseudoelepathyB urn On our Damn +arningsB )igO 7ade rivialB Fnfathomable )ugs IJ: he )roken OvenB %olomonoff<s 7ad %!ientistB early )logging Houndup I4B +hat isn<t a 7onadB %ear!hing a %orted 7atrix EasterB #ow to Head Nested ernary OperatorsB 7aking %ublime ext 1 >ump to the Corre!t /ine with Fnity on O% KB 7y )ug, 7y )ad I?: Heading Con!urrentlyB +hole AG- esting with Hefle!tionB Optimi(ing a Garser Combinator into a mem!pyB Don<t reat Gaths /ike %trings

Page 13 of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 14: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 14/15

B )reaking a oy #ash Eun!tionB Counting -terators /a(ilyB Fnfathomable )ugs I: Gretend Gre!isionB 7y )ug, 7y )ad I9: A!!identally Atta!king +arCraft 9B Collapsing ypes vs 7onads &followupB Collapsing Eutures: 2asy to Fse, #ard to HepresentB 2ventual 2x!eptions vs Grogramming in a 7inimal Eun!tional %tyleB he 7ystery of Elunf B 2xplain it like -<m Eive: he %o!ialist 7illionaire Groblem and %e!ure 7ultiGarty ComputationB Computer %!ien!e )lows 7y 7indB A visit to 2xe!ution /abs in 7ontrLalB ransmuting Di!e, Conserving 2ntropyB Hule of humb: Ask for the Clo!kB Hule of humb: Fse Gurposefully +eakened 7ethodsB Hule of thumb: Gre!onditions %hould be Che!ked 2xpli!itlyB -nterse!ting /inked /ists EasterB 7ouse Gath %moothing for >a!k /umberB 7y )ug, 7y )ad I1: %unk by EloatB Hepeat ourself DifferentlyB $rover<s ;uantum %ear!h Algorithm

B Eollowup to NonNullable ypes vs CIB Optimi(ing >ust in ime with 2xpression reesB +hen One+ay /aten!y Doesn<t 7atterB Determining exa!tly ifMwhenMwhere a moving line interse!ted a moving pointB 2mulating A!tors in CI with Asyn!MAwaitB 7aking an immutable 0ueue with guaranteed !onstant time operationsB -mproving Che!ked 2x!eptionsB Gerishable Colle!tions: he )enefits of Hemovalby/ifetimeB De!oupling shared !ontrolB De!oupling inlined F- !odeB /in0 to Colle!tions: )eyond -2numerableB Gublish your .Net library as a Nu$et pa!kageB +hen null is not enough: an option type for CI

B Fnfathomable )ugs IP: Headonly or notB 7inkowski sums: examplesB 7y )ug, 7y )ad I4: Era!tal %pheresB +orking around the brittle F- 6irtuali(ation in +indows 8B 2n!apsulating AnglesB Fnfathomable )ugs I?: =eys that aren<tB #ow would - even use a monad &in CIB FsefulM-nteresting 7ethods I4: Observable.+hen2a!hB Fnfathomable )ugs I9: %tringing you alongB Anonymous -mplementation Classes Q A Design Gattern for CIB asks for A!tion%!ript 9 Q -mproving on 2ventDriven GrogrammingB 7inkowski sums and differen!esB NonNullable ypes vs CI: Eixing the )illion Dollar 7istakeB Fnfathomable )ugs I1: %lashing OutB %!ript templates and base !lassesB Fnity font extra!tionB Abusing RGhantom ypesS to 2n!ode /ist /engths -nto heir ypeB Constru!tive Criti!ism of the Hea!tive 2xtensions AG-B ;uaternions part 9B ;uaternions part 1B ;uaternions part 4B Fnfathomable )ugs I4: ou !an have things3 ou !an have things -N things3 ou !an have…B Coroutines Q 7ore than you want to know

Page 1" of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log

"#$%#$&1'htt()##twistedoastudios*com#+log#Post$'"",grovers-.uantum-search-algorithm

Page 15: Post2644 Grovers Quantum Sear

8/17/2019 Post2644 Grovers Quantum Sear

http://slidepdf.com/reader/full/post2644-grovers-quantum-sear 15/15

$wisted %ak Studios2&'& Gottingen Street

Ha"i(a) NS *+ +!-

contact.twistedoakstudios/com

wistedOakStudios

T1541 154P wisted Oak %tudios /td. All Hights Heserved

All images and logos are property of their respe!tive owners.

B Asset )undle #elperB he 6isual %tudio goes awayB .Net<s time traveling %top+at!hB -ntrodu!ing Catalyst

Page 15 of 15Grover’s Quantum Search Algorithm | Twisted Oa Studios !log