量子运算 简单通俗例子_什么是量子计算机? 用一个简单的例子解释。

量子运算 简单通俗例子

by YK Sugi

由YK Sugi

什么是量子计算机? 用一个简单的例子解释。 (What is a quantum computer? Explained with a simple example.)

Hi everyone!

嗨,大家好!

The other day, I visited D-Wave Systems in Vancouver, Canada. It’s a company that makes cutting-edge quantum computers.

前几天,我参观了加拿大温哥华的D-Wave Systems 。 这是一家生产尖端量子计算机的公司。

I got to learn a lot about quantum computers there, so I’d like to share some of what I learned there with you in this article.

我在那里学习了很多有关量子计算机的知识,所以我想在本文中与大家分享一些我在这里学到的东西。

The goal of this article is to give you an accurate intuition of what a quantum computer is using a simple example.

本文的目的是让您准确了解直觉量子计算机所使用的简单示例。

This article will not require you to have prior knowledge of either quantum physics or computer science to be able to understand it.

本文将不要求您具有量子物理学或计算机科学的先验知识才能理解。

Okay, let’s get started.

好的,让我们开始吧。

Edit (Feb 26, 2019): I recently published a video about the same topic on my YouTube channel. I would recommend watching it (click here) before or after reading this article because I have added some additional, more nuanced arguments in the video.

编辑(2019年2月26日):我最近在我的YouTube频道上发布了关于同一主题的视频 。 我建议在阅读本文之前或之后观看它( 单击此处 ),因为我在视频中添加了一些其他的,更细微的参数。

什么是量子计算机? (What is a quantum computer?)

Here is a one-sentence summary of what a quantum computer is:

这是量子计算机的一句话摘要:

A quantum computer is a type of computer that uses quantum mechanics so that it can perform certain kinds of computation more efficiently than a regular computer can.
量子计算机是一种使用量子力学的计算机,因此它可以比常规计算机更有效地执行某些类型的计算。

There is a lot to unpack in this sentence, so let me walk you through what it is exactly using a simple example.

这句话有很多要解开的地方,所以让我用一个简单的例子向您介绍它的确切含义。

To explain what a quantum computer is, I’ll need to first explain a little bit about regular (non-quantum) computers.

为了解释什么是量子计算机,我首先需要对常规(非量子)计算机进行一些解释。

普通计算机如何存储信息 (How a regular computer stores information)

Now, a regular computer stores information in a series of 0’s and 1’s.

现在,常规计算机以一系列0和1存储信息。

Different kinds of information, such as numbers, text, and images can be represented this way.

可以用这种方式表示不同种类的信息,例如数字,文本和图像。

Each unit in this series of 0’s and 1’s is called a bit. So, a bit can be set to either 0 or 1.

这个系列中的0和1的每个单位称为一位。 因此,可以将某位设置为0或1。

现在,量子计算机呢? (Now, what about quantum computers?)

A quantum computer does not use bits to store information. Instead, it uses something called qubits.

量子计算机使用位来存储信息。 相反,它使用一种称为qubits的东西。

Each qubit can not only be set to 1 or 0, but it can also be set to 1 and 0. But what does that mean exactly?

每个量子位不仅可以设置为1 0,还可以设置为1 0。但这到底意味着什么?

Let me explain this with a simple example. This is going to be a somewhat artificial example. But it’s still going to be helpful in understanding how quantum computers work.

让我用一个简单的例子对此进行解释。 这将是一个人为的例子。 但这仍然有助于理解量子计算机的工作原理。

一个了解量子计算机如何工作的简单示例 (A simple example for understanding how quantum computers work)

Now, suppose you’re running a travel agency, and you need to move a group of people from one location to another.

现在,假设您正在经营一家旅行社,并且需要将一群人从一个地点转移到另一个地点。

To keep this simple, let’s say that you need to move only 3 people for now — Alice, Becky, and Chris.

为简单起见,假设您现在只需要移动3个人-爱丽丝,贝基和克里斯。

And suppose that you have booked 2 taxis for this purpose, and you want to figure out who gets into which taxi.

并假设您已经为此预订了2辆出租车,并且您想弄清楚谁乘坐哪辆出租车。

Also, suppose here that you’re given information about who’s friends with who, and who’s enemies with who.

此外,在这里假设您获得有关谁与谁成为朋友以及谁与谁成为敌人的信息。

Here, let’s say that:

在这里,我们说:

  • Alice and Becky are friends

    爱丽丝和贝基是朋友
  • Alice and Chris are enemies

    爱丽丝和克里斯是敌人
  • Becky and Chris are enemies

    贝基和克里斯是敌人

And suppose that your goal here is to divide this group of 3 people into the two taxis to achieve the following two objectives:

并假设您的目标是将3人组成的团队分为两辆出租车,以实现以下两个目标:

  • Maximize the number of friend pairs that share the same car

    最大化共享同一辆车的朋友对的数量

  • Minimize the number of enemy pairs that share the same car

    减少共享同一辆车的敌人对的数量

Okay, so this is the basic premise of this problem. Let’s first think about how we would solve this problem using a regular computer.

好的,这是此问题的基本前提。 首先考虑一下如何使用常规计算机解决此问题。

用常规计算机解决此问题 (Solving this problem with a regular computer)

To solve this problem with a regular, non-quantum computer, you’ll need first to figure out how to store the relevant information with bits.

为了使用常规的非量子计算机解决此问题,您首先需要弄清楚如何使用位存储相关信息。

Let’s label the two taxis Taxi #1 and Taxi #0.

让我们标记两个出租车1号和0号出租车。

Then, you can represent who gets into which car with 3 bits.

然后,您可以用3位代表谁进入哪辆车。

For example, we can set the three bits to 0, 0, and 1 to represent:

例如,我们可以在三个位设置为0,0, 1代表:

  • Alice gets into Taxi #0

    爱丽丝进入出租车0
  • Becky gets into Taxi #0

    贝基进入出租车0
  • Chris gets into Taxi #1

    克里斯进入出租车#1

Since there are two choices for each person, there are 2*2*2 = 8 ways to divide this group of people into two cars.

由于每个人都有两个选择,因此有2 * 2 * 2 = 8种方法可以将这一组人分为两辆车。

Here’s a list of all possible configurations:

以下是所有可能配置的列表:

A | B | C0 | 0 | 00 | 0 | 10 | 1 | 00 | 1 | 11 | 0 | 01 | 0 | 11 | 1 | 01 | 1 | 1

A | B | C0 | 0 | 00 | 0 | 10 | 1 | 00 | 1 | 11 | 0 | 01 | 0 | 11 | 1 | 01 | 1 | 1个

Using 3 bits, you can represent any one of these combinations.

使用3位,您可以代表这些组合中的任何一种。

计算每种配置的分数 (Computing the score for each configuration)

Now, using a regular computer, how would we determine which configuration is the best solution?

现在,使用普通计算机,我们将如何确定哪种配置是最佳解决方案?

To do this, let’s define how we can compute the score for each configuration. This score will represent the extent to which each solution achieves the two objectives I mentioned earlier:

为此,让我们定义如何计算每种配置的得分。 这个分数将代表每种解决方案在多大程度上实现了我之前提到的两个目标:

  • Maximize the number of friend pairs that share the same car

    最大化共享同一辆车的朋友对的数量

  • Minimize the number of enemy pairs that share the same car

    减少共享同一辆车的敌人对的数量

Let’s simply define our score as follows:

让我们简单地定义得分如下:

(the score of a given configuration) = (# friend pairs sharing the same car) - (# enemy pairs sharing the same car)

(给定配置的分数)=(共享同一辆车的#个朋友对)-(共享同一辆车的#个敌人对)

For example, suppose that Alice, Becky, and Chris all get into Taxi #1. With three bits, this can be expressed as 111.

例如,假设Alice,Becky和Chris都进入了出租车1号。 使用三位,这可以表示为111

In this case, there is only one friend pair sharing the same car — Alice and Becky.

在这种情况下,只有一对朋友共享同一辆车-爱丽丝和贝基。

However, there are two enemy pairs sharing the same car — Alice and Chris, and Becky and Chris.

但是,有两个敌对共享同一辆车-爱丽丝和克里斯,贝基和克里斯。

So, the total score of this configuration is 1-2 = -1.

因此,此配置的总分是1-2 = -1。

解决问题 (Solving the problem)

With all of this setup, we can finally go about solving this problem.

通过所有这些设置,我们终于可以解决这个问题了。

With a regular computer, to find the best configuration, you’ll need to essentially go through all configurations to see which one achieves the highest score.

对于常规计算机,要找到最佳配置,您实际上需要仔细检查所有配置,以查看哪个配置得分最高。

So, you can think about constructing a table like this:

因此,您可以考虑构造一个像这样的表:

A | B | C | Score0 | 0 | 0 | -10 | 0 | 1 | 1 <- one of the best solutions0 | 1 | 0 | -10 | 1 | 1 | -11 | 0 | 0 | -11 | 0 | 1 | -11 | 1 | 0 | 1 <- the other best solution1 | 1 | 1 | -1

A | B | C | 得分0 | 0 | 0 | -10 | 0 | 1 | 1 <-最佳解决方案之一 1 | 0 | -10 | 1 | 1 | -11 | 0 | 0 | -11 | 0 | 1 | -11 | 1 | 0 | 1 <-另一个最佳解决方案1 ​​| 1 | 1 | -1

As you can see, there are two correct solutions here — 001 and 110, both achieving the score of 1.

如您所见,这里有两个正确的解决方案-001和110,都达到了1分。

This problem is fairly simple. It quickly becomes too difficult to solve with a regular computer as we increase the number of people in this problem.

这个问题很简单。 随着我们增加处理此问题的人数,使用常规计算机很快变得难以解决。

We saw that with 3 people, we need to go through 8 possible configurations.

我们看到只有3个人,我们需要完成8种可能的配置。

What if there are 4 people? In that case, we’ll need to go through 2*2*2*2 = 16 configurations.

如果有四个人怎么办? 在这种情况下,我们需要进行2 * 2 * 2 * 2 = 16个配置。

With n people, we’ll need to go through (2 to the power of n) configurations to find the best solution.

与n个人一起,我们将需要进行(2的n次方)个配置以找到最佳解决方案。

So, if there are 100 people, we’ll need to go through:

因此,如果有100个人,我们将需要完成以下工作:

  • 2¹⁰⁰ ~= 10³⁰ = one million million million million million configurations.

    2 17 = 10 3 =一亿亿亿亿亿个配置。

This is simply impossible to solve with a regular computer.

这是用常规计算机根本无法解决的。

用量子计算机解决这个问题 (Solving this problem with a quantum computer)

How would we go about solving this problem with a quantum computer?

我们将如何使用量子计算机解决这个问题?

To think about that, let’s go back to the case of dividing 3 people into two taxis.

考虑一下,让我们回到将3个人分为两辆出租车的情况。

As we saw earlier, there were 8 possible solutions to this problem:

正如我们之前看到的,有8种可能的解决方案:

A | B | C0 | 0 | 00 | 0 | 10 | 1 | 00 | 1 | 11 | 0 | 01 | 0 | 11 | 1 | 01 | 1 | 1

A | B | C0 | 0 | 00 | 0 | 10 | 1 | 00 | 1 | 11 | 0 | 01 | 0 | 11 | 1 | 01 | 1 | 1个

With a regular computer, using 3 bits, we were able to represent only one of these solutions at a time — for example, 001.

对于使用3位的常规计算机,我们一次只能代表这些解决方案之一,例如001。

However, with a quantum computer, using 3 qubits, we can represent all 8 of these solutions at the same time.

但是,使用一台量子计算机,使用3个量子位 ,我们可以同时表示所有8个解决方案

There are debates as to what it means exactly, but here’s the way I think about it.

关于确切含义的争论不休,但这是我对它的思考方式。

First, examine the first qubit out of these 3 qubits. When you set it to both 0 and 1, it’s sort of like creating two parallel worlds. (Yes, it’s strange, but just follow along here.)

首先,检查这3个量子位中的第一个量子位。 当你将它设置为 0和1,有点像创建两个平行的世界。 (是的,这很奇怪,但是请遵循此处。)

In one of those parallel worlds, the qubit is set to 0. In the other one, it’s set to 1.

在这些并行世界之一中,量子位设置为0。在另一个世界中,量子位设置为1。

Now, what if you set the second qubit to 0 and 1, too? Then, it’s sort of like creating 4 parallel worlds.

现在,如果您也将第二个量子比特设置为0 1,该怎么办? 然后,就像创建四个平行世界。

In the first world, the two qubits are set to 00. In the second one, they are 01. In the third one, they are 10. In the fourth one, they are 11.

在第一个世界中,两个量子位设置为00。在第二个世界中,它们设置为01。在第三个世界中,它们设置为10。在第四个世界中,它们设置为11。

Similarly, if you set all three qubits to both 0 and 1, you’d be creating 8 parallel worlds — 000, 001, 010, 011, 100, 101, 110, and 111.

同样,如果将所有三个量子位都设置为0和1,则将创建8个并行世界-000、001、010、011、100、101、110和111。

This is a strange way to think, but it is one of the correct ways to interpret how the qubits behave in the real world.

这是一种奇怪的思考方式,但它是解释量子位在现实世界中的行为的正确方法之一。

Now, when you apply some sort of computation on these three qubits, you are actually applying the same computation in all of those 8 parallel worlds at the same time.

现在,当您对这三个量子位应用某种计算时,实际上您实际上同时在所有这8个并行世界中应用了相同的计算。

So, instead of going through each of those potential solutions sequentially, we can compute the scores of all solutions at the same time.

因此,我们可以依次计算所有解决方案的得分,而不必依次检查每个潜在解决方案。

With this particular example, in theory, your quantum computer would be able to find one of the best solutions in a few milliseconds. Again, that’s 001 or 110 as we saw earlier:

通过这个特定的例子,理论上,您的量子计算机将能够在几毫秒内找到最佳解决方案之一。 同样,如我们先前所见,它是001或110:

A | B | C | Score0 | 0 | 0 | -10 | 0 | 1 | 1 <- one of the best solutions0 | 1 | 0 | -10 | 1 | 1 | -11 | 0 | 0 | -11 | 0 | 1 | -11 | 1 | 0 | 1 <- the other best solution1 | 1 | 1 | -1

A | B | C | 得分0 | 0 | 0 | -1 0 | 0 | 1 | 1 <-最佳解决方案之一| 1 | 0 | -10 | 1 | 1 | -11 | 0 | 0 | -11 | 0 | 1 | -1 1 | 1 | 0 | 1 <-其他最佳解决方案1 ​​| 1 | 1 | -1

In reality, to solve this problem, you would need to give your quantum computer two things:

实际上,要解决此问题,您需要给量子计算机两件事:

  • All potential solutions represented with qubits

    量子位表示所有可能的解决方案
  • A function that turns each potential solution into a score. In this case, this is the function that counts the numbers of friend pairs and enemy pairs sharing the same car.

    将每个潜在解决方案转化为得分的功能。 在这种情况下,该功能可以计算共享同一辆汽车的朋友对和敌人对的数量。

Given these two things, your quantum computer will spit out one of the best solutions in a few milliseconds. In this case, that’s 001 or 110 with a score of 1.

鉴于这两件事,您的量子计算机将在几毫秒内吐出最佳解决方案之一。 在这种情况下,分数是1的001或110。

Now, in theory, a quantum computer is able to find one of the best solutions every time it runs.

现在,从理论上讲,量子计算机能够在每次运行时找到最佳解决方案之一。

However, in reality, there are errors when running a quantum computer. So, instead of finding the best solution, it might find the second-best solution, the third best solution, and so on.

但是,实际上,运行量子计算机时会出错。 因此,与其找到最佳解决方案,不如寻找第二好解决方案,第三好解决方案,依此类推。

These errors become more prominent as the problem becomes more and more complex.

随着问题变得越来越复杂,这些错误变得更加突出。

So, in practice, you will probably want to run the same operation on a quantum computer dozens of times or hundreds of times. Then pick the best result out of the many results you get.

因此,实际上,您可能希望在量子计算机上运行数十次或数百次相同的操作。 然后从获得的许多结果中选择最佳结果。

量子计算机如何扩展 (How a quantum computer scales)

Even with the errors I mentioned, the quantum computer does not have the same scaling issue a regular computer suffers from.

即使有我提到的错误,量子计算机也不会像普通计算机那样遇到相同的缩放问题。

When there are 3 people we need to divide into two cars, the number of operations we need to perform on a quantum computer is 1. This is because a quantum computer computes the score of all configurations at the same time.

当我们需要将3个人分为两辆车时,我们需要在量子计算机上执行的操作数为1。这是因为量子计算机同时计算所有配置的得分。

When there are 4 people, the number of operations is still 1.

当有4个人时,操作数仍为1。

When there are 100 people, the number of operations is still 1. With a single operation, a quantum computer computes the scores of all 2¹⁰⁰ ~= 10³⁰ = one million million million million million configurations at the same time.

当有100个人时,操作数仍为1。通过一次操作,量子计算机将同时计算所有2 1〜 = 10 3 = 1亿亿亿亿亿配置的分数。

As I mentioned earlier, in practice, it’s probably best to run your quantum computer dozens of times or hundreds of times and pick the best result out of the many results you get.

如前所述,在实践中,最好是运行量子计算机数十次或数百次,然后从获得的众多结果中挑选出最佳结果。

However, it’s still much better than running the same problem on a regular computer and having to repeat the same type of computation one million million million million million times.

但是,它仍然比在常规计算机上运行相同的问题并且必须重复相同类型的计算1亿亿亿亿亿次更好。

结语 (Wrapping up)

Special thanks to everyone at D-Wave Systems for patiently explaining all of this to me.

特别感谢D-Wave Systems的所有人耐心向我解释了所有这些。

D-Wave recently launched a cloud environment for interacting with a quantum computer.

D-Wave最近推出了一种用于与量子计算机进行交互的云环境。

If you’re a developer and would like actually to try using a quantum computer, it’s probably the easiest way to do so.

如果您是开发人员,并且想实际尝试使用量子计算机,那可能是最简单的方法。

It’s called Leap, and it’s at https://cloud.dwavesys.com/leap. You can use it for free to solve thousands of problems, and they also have easy-to-follow tutorials on getting started with quantum computers once you sign up.

它称为Leap,位于https://cloud.dwavesys.com/leap 。 您可以免费使用它来解决成千上万的问题,并且一旦注册,他们还将提供易于遵循的有关量子计算机入门的教程。

Footnote:

脚注:

  • In this article, I used the term “regular computer” to refer to a non-quantum computer. However, in the quantum computing industry, non-quantum computers are usually referred to as classical computers.

    在本文中,我使用术语“常规计算机”来指代非量子计算机。 然而,在量子计算工业中,非量子计算机通常被称为经典计算机。

翻译自: https://www.freecodecamp.org/news/what-is-a-quantum-computer-explained-with-a-simple-example-b8f602035365/

量子运算 简单通俗例子

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值