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.)

1

u/EatThisShoe Mar 28 '21

When you say we can calculate one measurement, for a problem like the travelling salesman problem finding the shortest path would be a single measurement, but finding the length of all possible paths would be many? Is that right?

Also, what if you have less qbits than your n? Can you decompose a 2 to the nth power to 2 to the n-q? Or n! to n!/q! ?

5

u/EZ-PEAS Mar 28 '21 edited Mar 28 '21

No, not right.

A qubit exists in a superposition of states, meaning there is some percentage change (amplitude) of it having the value 1, and some chance of it being 0. The key here is that it really is random chance. If you repeatedly construct a qubit that has an amplitude of 10% towards 1 and measure it many times, then on average you'll measure a one 10% of the time and a zero 90% of the time.

Suppose you construct an N qubit system that you think informs the solution to your travelling salesman problem. If you measure the system then you get N bits, but there's no guarantee that those bits tell you anything meaningful about your specific problem. They might encode the shortest path, or they might encode the longest path, or they might be garbage.

The way that quantum computers work is by arranging the amplitudes of the quantum states towards a specific solution. They are still quantum amplitudes that yield random measurements, but as long as those amplitudes are biased towards the desired solution even slightly then the whole game just boils down to the signal to noise ratio. In practice you would set up the same quantum system many times, potentially thousands or millions of times, and repeatedly measure the output until you have enough data to distinguish the signal from the noise.

Problems from the complexity class NP are a great candidate for quantum computing because they're hard to solve directly with a classical machine, but any proposed solution can also be checked efficiently. Thus, you can have a quantum machine generate a bunch of proposed solutions and then check to see if any of them actually solve the problem.

Factoring is a good example of this: it's hard to factor large numbers, but given two proposed prime factors of a number you can check whether they actually factor your large numbers with simple multiplication. If you have a noisy quantum machine generating possible factors of a large number, then those factors can all be checked efficiently until you find the right one.

NP-hard problems like the Travelling Salesman Problem are trickier, because they can't necessarily be checked efficiently. For example, I can give you a travelling salesman circuit through a set of cities, but that doesn't tell you anything one way or the other about whether there might exist another shorter path.

1

u/yawkat Mar 29 '21

NP-hard problems like the Travelling Salesman Problem are trickier, because they can't necessarily be checked efficiently. For example, I can give you a travelling salesman circuit through a set of cities, but that doesn't tell you anything one way or the other about whether there might exist another shorter path.

NP problems that return complex solutions like TSP aren't as intuitive, but they can all be efficiently transformed to a verifier in the end. Also see 3SAT, which is NP-complete.