15 | Or What Do You Mean They Can Be Both Zero And One At The Same Time!
16 |
17 |
18 |
By David Kemp
19 |
@david_b_kemp
20 |
21 |
22 | This article was originally written in 2014,
23 | but has had some minor improvements in December 2017 and January 2018
24 | when I received some useful feedback after the article
25 | had unexpectedly been posted on
26 | Hacker News
27 | in December 2017.
28 |
29 |
30 |
Heard of quantum computers?
31 |
Heard that they are faster than conventional computers?
32 |
Perhaps you have heard of quantum bits (abbreviated to qubits).
33 |
34 | Maybe you have even heard of the puzzling notion that
35 | qubits can have the values 0 and 1
36 | both at the same time.
37 |
38 |
Let me try to explain what this really means.
39 |
40 |
41 | This is part one of a two part series
42 | for those that want to
43 | learn a little about quantum computing,
44 | but lack the mathematics and quantum physics background required
45 | by many of the introductions out there.
46 | It covers some of the basics of quantum computing,
47 | such as qubits, state phases, and quantum interference.
48 | Part 2
49 | goes on to look at quantum search.
50 |
51 |
52 |
53 |
54 |
Qubits
55 |
56 | I assume you know what plain old ordinary binary bits are.
57 |
58 | Sorry, But I cannot assume you know nothing at all!
59 |
60 |
61 |
62 | Conventional bits are implemented using many different approaches:
63 | e.g. voltages on a wire,
64 | pulses of light on a glass fibre,
65 | etc. etc.
66 |
67 |
Just like bits, qubits have a binary state.
68 |
69 | Qubits represent 0 and 1 using quantum phenomenon like
70 | the nuclear spin direction of individual atoms.
71 |
72 |
73 | E.g. use “clockwise” for 0 and “anti clockwise” for 1.
74 |
75 |
76 |
77 |
78 |
0
79 |
80 |
81 |
82 |
1
83 |
84 |
85 |
86 |
87 |
88 |
The NOT operator
89 |
90 | Consider the conventional NOT (or bit-flip) operator.
91 |
92 | 0 and 1 can represent logical true and false.
93 | NOT true is false, and NOT false is true.
94 | And so, NOT of 1 is 0, and NOT of 0 is 1.
95 |
96 |
97 |
For example, performing a NOT operation on the right most bit of the binary number 111
98 | flips the target bit and results in 110.
99 |
In what follows, it will be convenient to represent the state of a system by listing all possible states
100 | and placing a blue disk next to the current state.
101 |
102 | Click the button labelled “Not bita”
103 | to apply the NOT operation to the left bit,
104 | and click the button labelled “Not bitb”
105 | to apply the NOT operation to the right bit:
106 |
107 |
108 | There is nothing quantum mechanical about these first few interactive examples.
109 | Their main purpose is to familiarise you with
110 | interactive animations I use in this article.
111 |
112 |
113 |
115 |
116 |
117 |
120 |
123 |
124 |
125 |
State:
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
Random NOT
135 |
Random NOT: A NOT operator that has a specified chance of flipping a bit.
136 |
137 | Although not very common,
138 | the “Random NOT” is still just a classical (non-quantum) operator,
139 | but it will help me explain the workings of some quantum operators.
140 |
141 |
142 | Consider applying a Random NOT twice to a bit whose initial value is 0,
143 | where the operator has, for instance, a 30% chance of flipping the bit.
144 | What is the probability of the final state being 0?
145 |
146 |
147 | There are a couple of possible scenarios.
148 | For instance, the first Random NOT might flip the bit from 0 to 1,
149 | and the second Random NOT might flip the bit back to 0.
150 | We represent this as:
151 |
152 |
153 | 0 → 1 → 0
154 |
155 |
There are two paths leading to a final state of 0:
156 |
157 |
158 | 0 → 0 → 0 with probability of 0.7 x 0.7 = 0.49
159 |
160 |
161 | 0 → 1 → 0 with probability of 0.3 x 0.3 = 0.09
162 |
163 |
164 |
And so the final state will be 0 with a probability of 49% + 9% = 58%
165 |
166 |
167 |
168 |
Random NOT (your turn)
169 |
Next we provide an interactive animation of the Random NOT operator.
170 |
The blue disk now splits in two so that we can track the different possible outcomes.
171 |
The probability of being in a state is represented by the radius of the disk.
172 |
173 | Press the “Random NOT” button multiple times and
174 | note how the arrows add head to tail.
175 |
176 |
177 | Still nothing quantum mechanical about any of this.
178 | We are still just warming up.
179 |
180 |
181 |
182 |
183 |
184 |
187 |
188 |
189 |
State:
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
Measurement
199 |
200 | We have seen how a random NOT operator can
201 | cause a conventional computer to have various probabilities
202 | of being in different states.
203 | Of course
204 | in reality it is in only one of those states.
205 | We just don't know which one.
206 | Strangely, this is an assumption about reality that we will need to reconsider
207 | when we look at qubits.
208 |
209 |
210 | If you peek at the system to determine its actual state,
211 | then the probabilities all collapse
212 | so that one state (the observed state)
213 | is deemed to now have a probability of 1,
214 | and all the others are deemed to have a probability of 0.
215 |
216 |
217 | Remember, the larger the blue disk,
218 | the more likely the system will turn out to be in that state.
219 |
220 |
221 | In quantum computing,
222 | the word measurement refers to this act of peeking.
223 |
224 |
225 | Press the “Random NOT” button multiple times
226 | and then press the “measurement” button.
227 |
228 |
229 | Note that there is still nothing quantum mechanical about this yet.
230 | That comes next!
231 |
232 |
233 |
234 |
235 |
236 |
239 |
240 |
241 |
242 |
243 |
244 |
State:
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
Hadamard of 0
254 |
255 | The “Hadamard operator” is
256 | a special quantum operator that can be applied to qubits.
257 |
258 |
259 | Warning: this first look at quantum operators will be pretty boring.
260 | I promise it will get interesting soon!
261 |
262 |
As you will see below, the Hadamard initially acts like a Random NOT with 50% chance of success.
263 |
264 | In this interactive example,
265 | I purposely disable the Hadamard button after you press it.
266 | Later in this article we will see what happens when you apply the Hadamard twice in a row.
267 |
268 |
269 |
270 |
271 |
272 |
273 |
277 |
278 |
279 |
280 |
281 |
282 |
State:
283 |
284 |
285 |
286 |
287 |
288 |
Nothing unusual about that was there?
289 |
But you will be surprised by what comes next...
290 |
291 |
292 |
293 |
294 |
Hadamard of 1
295 |
Things start to become weird when you look at the Hadamard of 1.
296 |
Look carefully at the arrow directions.
297 |
298 |
299 |
300 |
304 |
305 |
306 |
307 |
308 |
309 |
State:
310 |
311 |
312 |
313 |
314 |
315 |
Huh?
316 |
317 |
318 |
319 |
320 |
Phase
321 |
322 | Puzzled?
323 | You should be if this is all new to you.
324 | Please hang in there for a while longer.
325 |
326 |
327 |
328 | The arrow directions represent what physicists call phase:
329 |
330 |
331 |
332 |
it is an abstract concept of quantum mechanics.
333 |
it has no “common sense” interpretation.
334 |
it can only be measured indirectly.
335 |
336 |
337 |
338 | In the case of nuclear spin,
339 | phases can be manipulated by applying electric and/or
340 | magnetic fields.
341 |
342 |
343 | We will see the importance of phase in a moment,
344 | but first let's look at another interesting quantum computing operator...
345 |
346 |
347 |
348 |
349 |
T Operator
350 |
The T operator rotates the phase of 1, but leaves 0 untouched.
351 |
Note how it does not affect the probabilities at all.
352 |
353 |
354 |
355 |
359 |
360 |
361 |
State:
362 |
363 |
364 |
365 |
366 |
367 |
368 |
Measurement Revisited
369 |
Recall:
370 |
371 |
Measurement causes the system to collapse to the observed state.
372 |
The larger the blue disk, the more likely the system will collapse to that state.
373 |
374 | Once the system has collapsed to a particular state,
375 | it will remain in that state until another operation is performed.
376 |
377 |
378 |
379 | Important:
380 | The likelihood of a state being observed
381 | is entirely determined by the size of the blue disk,
382 | and is completely unaffected
383 | by the direction of the arrow.
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
State:
395 |
396 |
397 |
398 |
399 |
400 |
Quantum Interference
401 |
402 |
Consider what happens when we apply a Hadamard operation twice in a row.
403 |
404 |
405 | Let's assume that a qubit is initially known to definitely have the value 0.
406 | If you were to apply the Hadamard to it twice in a row,
407 | then there are four equally likely scenarios
408 | (Recall that “x → y → z”
409 | means “the qubit starts with a value x,
410 | the first Hadamard results in the qubit having the value y,
411 | and the second Hadamard results in the qubit having the value z”):
412 |
413 |
414 |
0 → 0 → 0
415 |
0 → 0 → 1
416 |
0 → 1 → 0
417 |
0 → 1 → 1
418 |
419 |
420 |
421 | So the final value should be equally likely to be 0 or 1 but,
422 | in reality,
423 | applying the Hadamard operator twice in a row
424 | always returns the qubit to its original value.
425 | In our case, where the qubit is initially 0,
426 | two applications of the Hadamard will result in it being 0 again.
427 |
428 |
429 |
430 | Try it out.
431 | Press the “Apply Hadamard” button twice
432 | and watch it return to having a 100% likelihood of having the value 0.
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
State:
442 |
443 |
444 |
445 |
446 |
447 |
Totally confused?
448 |
449 | If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet.
450 |
451 | Niels Bohr
452 |
453 |
454 |
455 |
456 |
What is going on here?
457 |
458 |
459 | The state of the qubit after the first Hadamard
460 | seems to have a 50% chance of being 0
461 | and a 50% chance of being 1.
462 |
463 |
464 | The second Hadamard is applied to both the 0 and 1 states
465 | and the results are combined.
466 |
467 |
468 |
469 | The arrows still add head to tail.
470 |
471 |
472 |
473 |
474 | The two different scenarios ending in a 1 state have opposite phases
475 | and so they cancel each other out.
476 |
477 |
478 |
479 | This process of phases causing possible outcomes to cancel or re-enforce
480 | is what physicists call interference.
481 |
482 |
483 |
This is what philosophers of physics loose sleep over.
484 |
485 |
486 |
487 |
488 | By the way,
489 | the mathematically inclined may be worried about
490 | all the probabilities not adding up to 1 any more.
491 | The trick is that
492 | the arrow lengths now have to represent
493 | the square roots of the probabilities.
494 | We will briefly cover this in more detail in the section entitled
495 | Some mathematics
496 | in Part 2.
497 |
498 |
499 |
500 |
501 |
502 |
Hadamard of 1 (revisited)
503 |
504 | It is instructive to observe the effects of applying
505 | a Hadamard twice in a row when the initial value is 1.
506 | This time, the qubit returns to 1:
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
State:
515 |
516 |
517 |
518 |
519 |
520 |
Different kinds of uncertainty
521 |
522 |
523 | We are actually dealing with two different kinds of uncertainty:
524 |
525 |
526 |
527 |
528 | It is possible that a bit, and even a qubit,
529 | may be in a fixed state of 0 or 1,
530 | but that you simply do not know which one it is.
531 |
532 |
533 | However, it is also possible for
534 | a qubit to be in what is called
535 | a “superposition”
536 | of both 0 and 1.
537 | Such a qubit is in a strange combination of both 0 and 1.
538 |
539 |
540 |
541 |
542 |
543 |
Small Diversion: Superposition of Locations
544 |
545 |
546 | So far, the rather abstract phenomenon of nuclear spin is
547 | the only approach that I have mentioned for creating qubits.
548 |
549 |
550 | Quantum physics seems even more bizarre
551 | when you discover that physical objects can be
552 | in superpositions of different locations.
553 |
554 |
555 | The photons travelling through an “interferometer”
556 | are in superpositions of locations that can be kilometres apart
557 | (as they are in the
558 | LIGO
559 | interferometer).
560 |
561 |
562 | A simple interferometer is shown below.
563 | Photons are emitted by a light source
564 | (e.g. a laser)
565 | that is pointing at a
566 | “half silvered mirror”,
567 | which reflects some of the light and lets some of the light through.
568 |
569 |
570 |
571 | Individual photons end up in a superposition of
572 | having been reflected
573 | and having been let through.
574 | A couple more mirrors are used to bring the split light beam back together
575 | at a detector.
576 | The positions of the mirrors and the detector all effect the lengths of
577 | the two different paths,
578 | so that one path can be longer than the other.
579 | Like the T operator described earlier,
580 | a change in the relative path lengths will alter
581 | the relative phases of the two photon states.
582 | A difference equal to the wavelength of light is enough to
583 | change the relative phases by an entire 360 degrees.
584 | If the phases are exactly opposite,
585 | then they will cancel each other out,
586 | and the detector will not detect anything.
587 | The resulting effect will be an alternating series of light
588 | and dark concentric rings like those shown below.
589 |
590 |
591 |
592 |
593 | This interference effect even happens when
594 | the light source is slowly emitting photons
595 | one at a time.
596 |
597 |
598 |
599 |
600 |
601 |
602 | It is tempting to think that the half silvered mirror
603 | is splitting each photon in two
604 | and that the interference effects are caused by the two photons
605 | interacting with each other.
606 | But this is not what happens.
607 |
608 |
609 | If detectors are placed on the two paths,
610 | and the light source is slowly emitting photons
611 | one at a time,
612 | then the detectors only ever detect a photon
613 | on one path or the other.
614 | They never detect two photons at once!
615 | (Well, they very occasionally do due to the light source
616 | very occasionally emitting two at once,
617 | but the frequency that this should happen is
618 | easily predicted and verified.)
619 |
620 |
621 |
622 | If detectors are placed on either or both of the two paths,
623 | then the act of detecting the presence (or absence) of the photon
624 | causes the superposition to collapse to one or the other,
625 | and the interference effects disappear,
626 | even if the detector lets the photon continue on.
627 |
628 |
629 |
630 |
631 |
632 | It gets even more interesting when you have more than one qubit
633 |
634 |
635 |
636 | The quantum weirdness rises to a whole new level when there are two or more qubits interacting.
637 | This is explored in Part 2.
638 |