r/askscience • • Mar 28 '21

Computing How exactly do quantum computers simulate molecular/particle interactions better than classical computers?

I’m struggling to understand why quantum computers can simulate nature better than classical computers.

2.5k Upvotes

134 comments sorted by

View all comments

886

u/GroundStateGecko Mar 28 '21 edited Mar 29 '21

First, I'd like to demystify something. It's common that people say an N-bit quantum computer can simultaneously exist in a superposition of 2N states, such that it will be able to access 2N answers, thus much faster than classical computers.

This is FALSE. You can only get ONE answer from the superposition of 2N states. ONE measurement will disrupt the whole system so that the superposition (of that property you were measuring) is broken. So an N-bit quantum computer has nothing to do with running 2N calculations at the same time.

Now the real answer to this question:

A tl;dr answer would be: because we can construct certain quantum systems, so that some physical properties of that system happens to be the same as some formula we need. (And that formula is hard to calculate using other stuff, like a classical computer or in our head.)

You can use this exact same explanation to answer "how do classical computers calculate addition faster than human". An adder, built with classical electronic circuits (like this one), are just some physical objects that do "experiments" so that if you flip the switches as your input, the output light bulbs will almost instantaneously illuminate in a way that happens to be the same as how addition works. We then measure the on/off of the light bulbs, and say that this "computer" (consisted of two switches, two logical gates, and two light bulbs) can do addition as fast as the electricity can flow through the wire, like billions of times a second (assuming you have bulbs that can flicker really fast).

We can now put our switch-gate-light bulb thing in a case, and call that thing "a classical computer that can quickly calculate the sum of two one-bit numbers". The switches are input, and (the brightness of) the light bulbs are output.

So what's a fast computer?

It's a physical apparatus, which we have configurations to change as input; and the measurement of some physical property happens to correlate to some formula we need.

Now, the same thing for quantum computers.

I'll use the calculation of a permanent of matrix as an example. A permanent (Wikipedia) of an n*n matrix is a sum of products, each product is consisted by n element, the horizontal indices are 1...n, and the vertical indices are each of the possible permutations for the n indices. So the total number of products in the summation is the factorial of n. Like for 2*2 matrix, for 3*3 matrix, and I generated the permanent for 4*4 and 5*5 matrices. You can see as the matrix grow bigger, it will be exponentially more complicated if we calculate the multiplications one by one (and the optimal complexity on a classical computer is ~O(n×2n)). For a 100*100 matrix, You would need to do ~1032 times calculation to get the result, and that will need ~1000 years on our best classical supercomputers.

However, there happens to be a quantum process, called Boson sampling (Wikipedia), whose physical property happens to satisfy:

[Boson sampling] = |permanent of matrix|2 / S₁! S₂! ... Sn!

We can calculate the "S₁! S₂! ... Sn!" part very quickly (using a classical computer), so we now build a quantum apparatus and measure the [Boson sampling] term for a certain input, we can now get the permanent of matrix very quickly from the above equation.

And we finally put that apparatus in a case, and call this quantum apparatus "a quantum computer that can quickly calculate the permanent of matrix". Just like our switch-gate-light bulb thing.

(There are caveats that I glossed over for simplicity. Read this like an Explain-like-I'm-five-answer. Comments are welcome.)

120

u/Harrison_Fjord Mar 28 '21

This is a cool explanation, thanks. I've never heard this explanation of a quantum computer before (or more likely, I never heard it distilled into simple enough terms for me to understand). Is there a list of these quantum processes that 'happen to be' equivalent to real-world problems we're trying to solve? My main curiosity is what natural quantum process is used for Shor's algorithm, which is the only quantum algorithm I'm tangentially familiar with.

126

u/GroundStateGecko Mar 28 '21 edited Mar 28 '21

Shor's algorithm is quite more "indirect". I'll try to give an explanation here, but the level of explain-like-I'm-five-ness will be significantly higher. So this comment will only give you a feeling and please know that this is not by any means rigorous.

In the following formulas, you can assume all numbers are integers.

Shor's algorithm is to find factors for a number. If we want to find the factor for the number B, we happen to prove that there must exist a relationship:

Ap = m * B + 1

where we just randomly pick some number A (without some trivial scenario), and we can eventually find a power P, that the remainder after divided by B is 1.

We now just assume we have found the power P for an A we picked. We can write:

(Ap/2 + 1)(Ap/2 - 1) = m * B

(It's the same thing, just wrote differently. You can multiply this back to the formula above.)

For example, if we want to find the factor of 85, we randomly pick a number 11, and try multiple power P, until we find one that satisfies Ap = m * B + 1:

112 = 1 * 85 + 36

113 = 15 * 85 + 56

114 = 172 * 85 + 21

115 = 1894 * 85 + 61

116 = 20841 * 85 + 76

117 = 229260 * 85 + 71

118 = 2521869 * 85 + 16

119 = 27740561 * 85 + 6

1110 = 305146171 * 85 + 66

1111 = 3356607889 * 85 + 46

1112 = 36922686784 * 85 + 81

1113 = 406149554634 * 85 + 41

1114 = 4467645100979 * 85 + 26

1115 = 49144096110772 * 85 + 31

1116 = 540585057218496 * 85 + 1

Got it!

Now, we wrote:

(118+1)(118-1) = 540585057218496 * 85

which is

214358882*214358880 = 540585057218496 * 85

Now, remember, we want to find C * D, so that C * D = 85.

So we wrote

214358882*214358880 = 540585057218496 * (C * D)

Now, as the left and the right are the same, they MUST share the same factors.

So if neither 214358882 itself nor 214358880 itself is a multiple of 85, it must satisfy:

214358882 = C * something

214358880 = D * something

(or vise versa)

we now know:

85 = C * something

214358882 = C * something

So 85 and 214358882 share factor.

Also 85 and 214358880 share factor.

There is a fast algorithm that is specifically used for finding common factors, called Euclidean algorithm. Which you can even do it by hand for 85 and 214358882 / 214358880.

214358882 = 2521869 * 85 + 17

And 17 is a prime number, so 85 has a factor 17.

214358880 = 2521869 * 85 + 15

85 = 5 * 15 + 10

15 = 1 * 10 + 5

And 5 is a prime number, so 85 has a factor 5.

So we got it! 85 = 5*17

Now, why do we go through this hell?

(Continue on the second part, as Reddit have a 10000 character limit)

123

u/GroundStateGecko Mar 28 '21 edited Mar 28 '21

(This is the second part, read the first part first)

Now, why do we go through this hell?

Indeed, using a classical computer, this algorithm is definitely not faster than just trying to divide 85 by prime numbers. The main problem is to find a p, so that we have:

Ap = m * B + 1

We now need another fact:

If Ap = m * B + 1, and we pick any number q:

Aq = n * B + k

We multiply those two, you will always get:

Aq * Ap = Ap+q = something * B + k

(you can multiply (m * B + 1)*(n * B + k) yourself to get the something term)

Also:

Aq * Ap * Ap = A2p+q = something * B + k

Aq * Ap * Ap * Ap = A3p+q = something * B + k

.....

You can derive it yourself.

Now we test it with our case:

Our p is 16, we randomly pick q to be 8.

You can test:

118 = 2521869 * 85 + 16

118+16 = [A long number] * 85 + 16

118+16×2 = [A much longer number] * 85 + 16

118+16×3 = [A much much longer number] * 85 + 16

The remainder is always 16.

This satisfies for ANY q:

Like when q is 5:

115 = 1894 * 85 + 61

115+16 = [A long number] * 85 + 61

115+16×2 = [A much longer number] * 85 + 61

115+16×3 = [A much much longer number] * 85 + 61

The remainder is always 61.

So, here is the most important message, this sequence has a period of p. If we find the period (frequency), we find our factors.

The answer to how do we find a period is almost always Fourier transform.

It's kinda like when you hear a sound, the sound signal is very very complicated if you look at the position-time diagram (see this image). But after Fourier transform, you can immediately see it's just the superposition of three sine waves.

Now when you hear a song, you immediately notice that's an A-minus, not because you can calculate really fast, but because there are hair cells, that will resonances with different frequencies (Wikipedia), only the hair cell that has the right frequency will vibrate strongly, forced vibration to the other cells will cancel out as multiple periods of the sound passes through.

In a strikingly accurate way, your ear is a Fourier transform computer!

This finding-period part is where the quantum part comes in.

Now we can do a very similar thing with a quantum computer to crack passwords.

As we said before,

118 , 118+16, 118+16×2,118+16×3 all satisfies [A much much longer number] * 85 + 16

115 , 115+16, 115+16×2,115+16×3 all satisfies [A much much longer number] * 85 + 61

So we can somehow craft a system, which is the superposition of the states including the power and the remainder:

|8, 16> + |8+16, 16> + |8+16*2, 16> + |8+16*3, 16> + ...

|5, 61> + |5+16, 61> + |5+16*2, 61> + |5+16*3, 61> + ...

All this sequence will have a period 16, which is our p.

So this sequence will resonance only with something that also has a period 16 (or the multiple of it)

So, we can somehow build a "quantum ear", called QFT (quantum Fourier transform), so that only the "quantum hair cell" that has a period 16 will vibrate strongly, and the other will stay still.

Why do we need to do this? As I said in the original comment "you can only get ONE answer from the superposition of 2N states." So we must do something, to let the correct answer "pop out".

By constructing the "quantum ear", only the period-16 "hair cell" vibrates, so it has the largest amplitude. If we do a measurement, it's highly likely we will find the period-16 "hair cell" (the wave function will collapse to period-16), instead of any other number.

Now we can find our p (it's 16) with one measurement (one try)!

And with some simple Euclidean algorithm. We can crack the Internet!

(Actually, not all encryption is based on prime factors. There are things like Elliptic-curve Diffie–Hellman that will not be solved by Shor's algorithm and a quantum computer. So not all of the Internet will be cracked.) Edit: This sentence is not correct, as pointed out by u/Oye_Beltalowda. Elliptic-curve can be accelerated by Shor's algorithm. Although people have proposed variants to ECDH like SIDH that can resist quantum computer attacks.

17

u/Oye_Beltalowda Mar 28 '21

There are things like Elliptic-curve Diffie–Hellman that will not be solved by Shor's algorithm and a quantum computer.

Wikipedia says otherwise. In fact, it says that elliptic curve cryptography is even easier to break with Shor's algorithm than traditional RSA.

→ More replies (1)

26

u/Harrison_Fjord Mar 28 '21

Wow. I'm reading through this a slowly, and reading through it a couple of times, but thank you so much for this explanation! The connection between FFTs is I think the biggest thing I was missing, I've tried to get explanations of the actual things that are going on when quantum computers are... executed?, but I always got something like "we wrangle these things called qubits, do black magic process that no one explains, and then we get the results. Easy peasy, what don't you understand?'. I never had a grasp on the translation between "quantum qubits are in a set of superpositions" and "we measure that to get results" until now.

Thanks again for going over all this. Your procedural method for explaining it makes it easy to follow and you do a good job of leading me through all the steps involved, not just the beginning and the end.

→ More replies (1)

4

u/SirSilvan96 Mar 28 '21

Your explanation was beautiful!

2

u/atimholt Mar 28 '21

Quick question: I've read Feynman's book QED (though it's been a long time), and I've built up some (tentative) intuition for superpositions/entanglement. If this isn't a purely philosophical question, is it correct to say that a waveform collapse is still entangled with all the “histories” that could have caused it? That is, the “quantum fourier transform” doesn't necessarily collapse to the most likely outcome because it “picked one of the options”—there can still be a superposition of every Feynman diagram that leads to that outcome.

I figure it has to be this way for time-reversibility to make any sense. Aside from the massive low-entropy well that is the big bang, the past has aspects of unknowability that are the same as those of the future.

2

u/[deleted] Mar 28 '21 edited Mar 29 '21

[removed] — view removed comment

→ More replies (1)
→ More replies (4)

3

u/[deleted] Mar 28 '21

Thanks for taking the time to write this up. great explanation

→ More replies (1)

11

u/JRRudy Mar 28 '21

MinutePhysics made a great video breaking down Shor's algorithm, if you're interested: https://youtu.be/lvTqbM5Dq4Q

→ More replies (1)

14

u/itachiaizen Mar 28 '21

Thank you for including all those links! Really helped!

9

u/[deleted] Mar 28 '21

Wow thank you. I never understood this before. You did a great job explaining the concept of how we’ve built classical computers to use how we know electricity to work and then relate that to quantum computers. I always just thought they did things faster. The fact that we’re taking the way it behaves naturally and constructing the computers to match mathematical formula we know makes a lot more sense.

4

u/Spinster_Tchotchkes Mar 28 '21

Am I kind of comprehending this if my mind conjures up an analogy of a Plinko board?

Like at first we could only drop marbles down through a physical Plinko board and watch how they get distributed in real time. Then digital computing was invented so now we can simulate the plinko board action digitally (much faster than real time). But what would be even better is if we can discover a real life equivalent of Plinko that does the Plinko distribution SUPER fast, like quantum particle fast, provided we can figure out how to record the output.

9

u/[deleted] Mar 28 '21

Boson Sampling is nearly always compared to plinko boards when introduced at lectures etc. So you're right on the money.

It would take a computer a very very long time to calculate the output distribution of a plinko board which uses photons, beamsplitters, and mirrors instead of solid balls and pegs, but light travels at the speed of ... light. So we can conduct a single boson sampling experiment nearly instantaneously using fiber optics, and then repeat that a number of times to get the distribution. That is a de-facto quantum computer, albeit a special purpose one, not a computationally complete one.

This is why boson sampling makes the news from time to time. We are increasing the state of the art to be able to run more and more photons in a larger number of input ports, and we are arguably at or past the point where classical computers are capable of simulating the systems we are making in the lab. That point of technological progress is usually referred to as "quantum supremacy", but that term is getting some controversy for reasons that are likely apparent.

→ More replies (5)

6

u/KJ6BWB Mar 28 '21

It's like saying, "calculating exactly how something is spinning/moving and where it will land when it goes through a Plinko board is basically impossible but just dropping it in then seeing where it ends up is super easy". So if we want to figure out where something will land, the easiest way is to build a Plinko board and see where it lands.

Well, there are some math problems that are super hard but if we had a physical computer that modeled it in the right way then we could just "see where the answer lands" and that's where it is. But for some of these super hard math problems we need a quantum computer to really model the problem accurately.

8

u/prisp Mar 28 '21

Heads up, your link to the wikipedia article for [Permanent_(mathematics)](https://en.wikipedia.org/wiki/Permanent_(mathematics)) is broken - Reddit's formatting thinks the first closing ')' is the one that ends the link, when it should still be a part of it. To circumvent this, you can force Reddit to ignore that ')' by putting a '\' directly in front of it so that it reads "(mathematics\)" instead.

This works because '\' is a so-called "escape character" - a character that, instead of being shown on-screen, removes any special function from the next character and forces that character to be used as-is instead.
(Sidenote: This means that in order to get the '\' to show up above, I had to strip it of it's function as escape character by typing "\\" in my reply.)

3

u/GroundStateGecko Mar 28 '21

Thanks! I've fixed it. Didn't think the "Fancy Editor" of Reddit will miss that.

3

u/[deleted] Mar 28 '21

[removed] — view removed comment

→ More replies (1)
→ More replies (1)
→ More replies (33)