quantum mechanics blog post explained simply
https://quantum.country/qcvc
Quantum computing for the very curious
2019-03-18
Matuschak; Andy; Nielsen; Michael
<div><div><p>If humanity ever makes contact with alien intelligences, will those aliens possess computers? In science fiction, alien computers are commonplace. If that's correct, it means there is some way aliens can discover computers independently of humans. After all, we’d be very surprised if aliens had independently invented Coca-Cola or Pokémon or the Harry Potter books. If aliens have computers, it’s because computers are the answer to a question that naturally occurs to both human and alien civilizations.</p><p>Here on Earth, the principal originator of computers was the English mathematician Alan Turing. In his paper, published in 1936Alan M. Turing, <a href="/assets/Turing1936.pdf">On Computable Numbers, with an Application to the Entscheidungsproblem</a> (1936)., Turing wasn’t trying to invent a clever gadget or to create an industry. Rather, he was attacking a problem about the nature of mathematics posed by the German mathematician David Hilbert in 1928. That sounds abstruse, but it’s worth understanding the gist of Hilbert and Turing’s thinking, since it illuminates where computers come from, and what computers will become in the future.</p><p>Through his career, Hilbert was interested in the ultimate limits of mathematical knowledge: what can humans know about mathematics, in principle, and what (if any) parts of mathematics are forever unknowable by humans? Roughly speaking, Hilbert’s 1928 problem asked whether there exists a general algorithm a mathematician can follow which would let them figure out whether any given mathematical statement is provable. Hilbert’s hoped-for algorithm would be a little like the paper-and-pencil algorithm for multiplying two numbers. Except instead of starting with two numbers, you’d start with a mathematical conjecture, and after going through the steps of the algorithm you’d know whether that conjecture was provable. The algorithm might be too time-consuming to use in practice, but if such an algorithm existed, then there would be a sense in which mathematics was knowable, at least in principle.</p><p>In 1928, the notion of an algorithm was pretty vague. Up to that point, algorithms were often carried out by human beings using paper and pencil, as in the multiplication algorithm just mentioned, or the long-division algorithm. Attacking Hilbert’s problem forced Turing to make precise exactly what was meant by an algorithm. To do this, Turing described what we now call a <em>Turing machine</em>: a single, universal programmable computing device that Turing argued could perform any algorithm whatsoever.</p><p>Today we’re used to the idea that computers can be programmed to do many different things. In Turing’s day, however, the idea of a universal programmable computer was remarkable. Turing was arguing that a single, fixed device could imitate <em>any</em> algorithmic process whatsoever, provided the right program was supplied. It was an amazing leap of imagination, and the foundation of modern computing.</p><p>In order to argue that his machine could imitate any algorithmic process, Turing considered what operations a human mathematician could perform when carrying out an algorithm. For each such operation, he had to argue that his machine could always do the same thing. His argument is too long to reproduce in full here, but it’s fun and instructive to see the style of Turing’s reasoning:</p><blockquote>Computing is normally done by writing certain symbols on paper. We may suppose this paper is divided into squares like a child’s arithmetic book. In elementary arithmetic the two-dimensional character of the paper is sometimes used. But such a use is always avoidable, and I think that it will be agreed that the two-dimensional character of paper is no essential of computation. I assume then that the computation is carried out on one-dimensional paper, i.e. on a tape divided into squares. … The behavior of the computer [Turing is referring to the person performing an algorithm, not the machine!] at any moment is determined by the symbols which he is observing, and his “state of mind” at that moment. We may suppose that there is a bound BB to the number of symbols or squares which the computer can observe at one moment. If he wishes to observe more, he must use successive observations. We will also suppose that the number of states of mind which need be taken into account is finite.</blockquote><p>Obviously, this was an informal and heuristic argument! Invoking a child’s arithmetic book, or someone’s mental state is not the stuff of a rigorous, bulletproof argument. But Turing’s argument was convincing enough that later mathematicians and scientists have for the most part been willing to accept it. Turing’s machine became the gold standard: an algorithm was what we could perform on a Turing machine. And since that time, computing has blossomed into an industry, and billions of computers based on Turing’s model have been sold.</p><p>Still, there’s something discomforting about Turing’s analysis. Might he have missed something in his informal reasoning about what an algorithm is? In 1985, the English physicist David Deutsch suggested a deeper approach to the problem of defining what is meant by an algorithmDavid Deutsch, “Quantum theory, the Church-Turing principle and the universal quantum computer” (1985).. Deutsch pointed out that every algorithm is carried out by a physical system, whether it be a mathematician with paper-and-pencil, a mechanical system such as an abacus, or a modern computer. Deutsch then considered the following question (I've slightly rephrased to make it easier to read):</p><blockquote><strong>Is there a (single) universal computing device which can efficiently simulate <em>any</em> other physical system?</strong></blockquote><p>If there was such a device, you could use it to perform any algorithm whatsoever, because algorithms have to be performed on some kind of physical system. And so the device would be a truly universal computer. What’s more, Deutsch pointed out, you wouldn’t need to rely on informal, heuristic arguments to justify your notion of algorithm, as Turing had done. You could use the laws of physics to prove your device was universal.</p><p>So let’s come back to our opening question: will aliens have computers? Deutsch’s question above is a simple, fundamental question about the nature of the universe. It’s the kind of question which alien counterparts to Deutsch could plausibly come to ponder. And the alien civilizations of which they are a part would then be led inexorably to invent computers.</p><p>In this sense, computers aren’t just human inventions. They are a fundamental feature of the universe, the answer to a simple and profound question about how the universe works. And they have likely been discovered over and over again by many alien intelligences.</p><p>There’s a wrinkle in this story. Deutsch is a physicist with a background in quantum mechanics. And in trying to answer his question, Deutsch observed that ordinary, everyday computers based on Turing’s model have a lot of trouble simulating quantum mechanical systemsResearchers such as Yu Manin and Richard Feynman had previously observed this, and as a result had speculated about computers based on quantum mechanics.. In particular, they seem to be extraordinarily slow and inefficient at doing such simulations. To answer his question affirmatively, Deutsch was forced to invent a new type of computing system, a <em>quantum computer</em>. Those quantum computers can do everything conventional computers can do, but are also capable of efficiently simulating quantum-mechanical processes. And so they are arguably a more natural computing model than conventional computers. If we ever meet aliens, my bet is that they’ll use quantum computers (or, perhaps, will have quantum computing brains). After all, it’s likely that aliens will be far more technologically advanced than current human civilization. And so they’ll use the computers natural for any technologically advanced society.</p><p>This essay explains how quantum computers work. It’s not a survey essay, or a popularization based on hand-wavy analogies. We’re going to dig down deep so you understand the details of quantum computing. Along the way, we’ll also learn the basic principles of quantum mechanics, since those are required to understand quantum computation.</p><p>Learning this material is challenging. Quantum computing and quantum mechanics are famously “hard” subjects, often presented as mysterious and forbidding. If this were a conventional essay, chances are that you’d rapidly forget the material. But the essay is also an experiment in the essay form. As I’ll explain in detail below <em>the essay incorporates new user interface ideas to help you remember what you read</em>. That may sound surprising, but uses a well-validated idea from cognitive science known as spaced-repetition testing. More detail on how it works below. The upshot is that anyone who is curious and determined can understand quantum computing deeply and for the long term.</p><p>That said, you need some mathematical background to understand the essay. I’ll assume you’re comfortable with complex numbers and with linear algebra – vectors, matrices, and so on. I’ll also assume you’re comfortable with the logic gates used in conventional computers – gates such as AND, OR, NOT, and so on.</p><p>If you don’t have that mathematical background, you’ll need to acquire it. How you do that depends on your prior experience and learning preferences – there’s no one-size-fits-all approach, you’ll need to figure it out for yourself. But two resources you may find helpful are: (1) <a href="https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab">3Blue1Brown’s series</a> of YouTube videos on linear algebra; and (2) the more in-depth <a href="https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/video-lectures/">linear algebra lectures by Gil Strang</a>. Try them out, and if you find them helpful, keep going. If not, explore other resources.</p><p>It may seem tempting to try to avoid this mathematics. If you look around the web, there are many flashy introductions to quantum computing that avoid mathematics. There are, for instance, many rather slick videos on YouTube. They can be fun to watch, and the better ones give you some analogies to help make sense of quantum computing. But there’s a hollowness to them. Bluntly, if they don’t explain the actual underlying mathematical model, then you could spend years watching and rewatching such videos, and you’d never really get it. It’s like hanging out with a group of basketball players and listening to them talk about basketball. You might enjoy it, and feel as though you’re learning about basketball. But unless you actually spend a lot of time playing, you’re never going to learn to play basketball. To understand quantum computing, you absolutely must become fluent in the mathematical model.</p><h2>Part I: The state of a qubit</h2><p>As you know, in ordinary, everyday computers the fundamental unit of information is the bit. It’s a familiar but astonishing fact that all the things those computers do can be broken down into patterns of 00s and 11s, and simple manipulations of 00s and 11s. For me, I feel this most strongly when playing video games. I’ll be enjoying playing a game, when I’ll suddenly be hit by a realization of the astounding complexity behind the imaginary world visible on my screen:</p><p></p><p><a href="https://play0ad.com/media/screenshots/nggallery/page/1">Source</a>Copyright Wildfire Games, used under a <a href="https://trac.wildfiregames.com/browser/ps/trunk/LICENSE.txt">Creative Commons Attribution-Share Alike 3.0 license</a>..</p><p>Underlying every such image is millions of pixels, described by tens of millions of bits. When I move the game controller, I am effectively conducting an orchestra, tens of millions strong, organized through many layers of intermediary ideas, in such a way as to create enjoyment and occasionally sheer delight.</p><p>I’ve described a bit as an abstract entity, whose state is 00 or 11. But in the real world, not the world of mathematics, we must find some way of storing our bits in a physical system. That can be done in many different ways. In your computer’s memory chips, bits are most likely stored as tiny electric charges on nanometer-scale capacitors (i.e., little reservoirs of charge), just above the surface of the chip. Old-fashioned hard disks take a different approach, using tiny magnets to store bits. Furthermore, different types of memory use different types of capacitor; different types of hard disk use different approaches to magnetization.</p><p>For the most part you don’t notice these differences when you use your computer. Computer designers work very, very hard to make the details of the physical instantiation of the bits invisible not just to the user, but also (often) invisible even to programmers. Many programmers never think about whether a bit is stored in fast on-microprocessor cache memory, in the dynamic RAM chips, or in some type of virtual memory (say, on a hard disk). There are exceptions – programmers working on high-performance programs sometimes do think about these things, to make their programs as fast as possible. But for many programmers it doesn’t much matter how bits are stored. Rather, they can think of the bit in purely abstract terms, as having a state which is either 00 or 11.</p><p>In a manner similar to the way conventional computers are made up of bits, quantum computers are made up of <em>quantum bits</em>, or <em>qubits</em>. Just like a bit, a qubit has a <em>state</em>. But whereas the state of a bit is a number (00 or 11), the state of a qubit is a <em>vector</em>. More specifically, <em>the state of a qubit is a vector in a two-dimensional vector space. This vector space is known as state space.</em> For instance, here’s a possible state for a qubit:</p><p>[10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]</p><p>That perhaps sounds strange! What does it mean that the state of a qubit is a two-dimensional vector? We’re going to unpack the answer slowly and gradually. You won’t have a single epiphany where you think “ahah, that’s what a qubit is!” Rather, you’ll gradually build up many details in your understanding, until you get to the point where you’re comfortable working with qubits, with quantum computations, and more generally with quantum mechanics.</p><p>One way qubits are similar to bits: we’ve said absolutely nothing about what the qubit actually <em>is</em>, physically. Maybe the state of the qubit is being stored somehow on an electron, or a photon, or an atom. Or maybe it’s being stored in something stranger, perhaps inside some exotic particle or state of matter, even further removed from our everyday experience.</p><p>For our purposes in this essay none of this matters, no more than you should worry about what type of capacitor is storing the bits inside your computer’s RAM. What you should take away is that: (a) qubits have a state; (b) much like a bit, that state is an abstract mathematical object; but (c) whereas a bit’s abstract state is a number, 00 or 11, the state of a qubit is a 22-dimensional vector; (d) we call the 22-dimensional vector space where states live state space.</p><p>Alright, let’s review what we’ve learnt. Please indulge me by answering the questions just below. It’ll only take a few seconds – for each question, think about what you believe the answer to be, click to reveal the actual answer, and then mark whether you remembered or not. If you can recall, that’s great. If not, that’s also fine, just note the correct answer, and continue.</p><h2>A medium which makes memory a choice</h2><p>Perhaps you correctly recalled the answers to all three questions just now. Even if so, will you remember the answers in a week? In a year? Human memory is fallible. If your memory is like mine, you <em>might</em> vaguely remember the answers in a week: “what’s the state of a qubit, oh yes, it’s a vector!” But the chances you’ll remember in a month or a year are low. And if you forget such things, you won’t have any durable understanding of quantum computing.</p><p>How can we ensure you don’t remember these answers for just a few minutes or a few hours, but well into the future, perhaps even permanently?</p><p>One way is for you to be supremely virtuous, to keep coming back and re-reviewing the material until it’s firmly locked in your memory. If you are such a virtuous person, congratulations! But for the other 99 percent of us that’s not likely. What can we do?</p><p>For more than a century, cognitive scientists have studied human memory. And they’ve figured out some simple strategies that ensure you’ll remember something permanently. The single most important idea is to <em>re-test you on your knowledge, with expanding time intervals between tests.</em></p><p>As an example, consider the question above: “How many dimensions does the state space of a qubit have?” If you got it right, you’d ideally be tested again in a few weeks. And if you got it right again, you’d be tested again a few months after that. And so on, a gradually expanding schedule. If you get the question wrong on one of those tests, the schedule would contract, so you can relearn the answer.</p><p>It turns out that such an expanding schedule is the optimal way to retain information. Each time you’re re-tested your brain consolidates the answer a little better into long-term memory, until eventually it’s permanent.</p><p>Spaced-repetition testing is a simple idea, but has profound consequences. First, it doesn’t take much overall time. Because of the expanding test schedule, it typically only takes a few minutes of total review time to memorize the answer to a question for years or decades. I won’t go through the math showing that, but you can see it <a href="http://augmentingcognition.com/ltm.html#Anki_analysis">worked out elsewhere</a>.</p><p>Second, spaced-repetition testing gives you a guarantee you will remember the answer to the question. For the most part our memories work in a haphazard manner. We read or hear something interesting, and hope we remember it in future. Spaced-repetition testing makes memory into a choice.</p><p>This sounds great, but also like you’ll need to be very disciplined in re-testing yourself. Fortunately, the computer can handle all the scheduling for you. And so this essay isn’t just a conventional essay, it’s also a new medium, a <em>mnemonic medium</em> which integrates spaced-repetition testing. <em>The medium itself makes memory a choice.</em></p><p>This comes at some cost: you’re committing to future review. But consider what that buys you. This essay will likely take you an hour or two to read. In a conventional essay, you’d forget most of what you learned over the next few weeks, perhaps retaining a handful of ideas. But with spaced-repetition testing built into the medium, a small additional commitment of time means you will remember all the core material of the essay. Doing this won’t be difficult, it will be easier than the initial read. Furthermore, you’ll be able to read other material which builds on these ideas; it will open up an entire world.</p><p>This spaced-repetition approach is why the questions only require a few seconds to read and answer. They’re not complex exercises, in the style of a textbook. Rather, the questions have a different point: the promise each question makes is that you will remember the answer forever. It’s to permanently change your thinking.</p><p>So, I invite you to set up an account by signing in below. If you do so, your review schedule for each question in the essay will be tracked, and you’ll receive periodic reminders containing a link which takes you to an online review session. That review session isn’t this full essay – rather, it looks just like the question set you answered above, but contains instead <em>all</em> the questions which are due, so you can quickly run through them. The time commitment will usually be a few minutes per session – a little more early on, when questions need frequent re-testing, but rapidly dropping off. You can study on your phone while grabbing coffee, or standing in line, or going for a walk, or in transit. The return for that small time commitment is greatly improved fluency in basic quantum computing and quantum mechanics. And that understanding will be internalized, a part of who you are, retained for years instead of days.</p><p>To keep this promise, we’re tracking your review schedule for each question, and sending you occasional reminders to check in, and to run through the questions which are due. You can review on your phone while grabbing coffee, or standing in line, or going for a walk, or on transit. The return for that commitment is greatly improved fluency in basic quantum computing and quantum mechanics. And that understanding will be internalized, a part of who you are, retained for years instead of weeks.</p><div><div><p>Please sign in so we can save your progress and let you know the best times to review.</p></div><div><p>Thank you! Your progress will be saved as you read.</p></div></div><p>Having extolled the virtues of spaced-repetition testing, let’s try another question:</p><p>This question is similar to an earlier question: “How many dimensions does the state space of a qubit have?” It may seem inefficient to have such similar questions, but it helps build fluency with the material when you have the “same” information encoded into memory in multiple ways, triggering off different associations. And so many of the questions below have this nature, elaborating ideas in multiple ways.</p><h2>Connecting qubits to bits: the computational basis states</h2><p>Let’s get back to understanding qubits. I’ve described what the state of a qubit is, but given no hint about how (or whether) that’s connected to the state of a classical bit. (Henceforth we’ll use the phrase “classical bit” instead of “conventional bit”, after “classical physics”). In fact, there are two special quantum states which correspond to the 00 and 11 states of a classical bit. The quantum state corresponding to 00 is usually denoted ∣0⟩|0\rangle. That’s a fancy notation for the following vector:</p><p>∣0⟩:=[10].|0\rangle := \left[ \begin{array}{c} 1 \\ 0 \end{array} \right].</p><p>This special state ∣0⟩|0\rangle is called a <em>computational basis state</em>.</p><p>It’s tempting to see the ∣0⟩|0\rangle notation and wonder what all the separate pieces mean – what, for instance, does the ∣| mean; what does the ⟩\rangle mean; and so on?</p><p>In fact, it’s best to regard ∣0⟩|0\rangle as a single symbol, standing for a single mathematical object – that vector we just saw above, [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]. The ∣| and ⟩\rangle don’t really have separate meanings except to signify this is a quantum state. In this, ∣0⟩|0\rangle is much like the symbol 00: both stand for a single mathematical entity. And, as we’ll gradually come to see, a quantum computer can manipulate ∣0⟩|0\rangle in ways very similar to how a conventional computer can manipulate 00.</p><p>This notation with ∣| and ⟩\rangle is called the <em>ket</em> notation, and things like ∣0⟩|0\rangle are called <em>kets</em>. But don’t be thrown off by the unfamiliar terminology – a ket is just a vector, and when we say something is a ket, all we mean is that it’s a vector.</p><p>That said, the term ket is most often used in connection with notations like ∣0⟩|0\rangle. That is, we wouldn’t usually refer to [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] as a ket; we’d call it a vector, instead. If you’re a fan of really sharp definitions and strict consistency, this may seem vague and wishy-washy, but in practice doesn’t cause confusion. It’s just a convention to be aware of!</p><p>Alright, so ∣0⟩|0\rangle is a computational basis state for a qubit, and plays much the same role as 00 does for a classical bit. It won’t surprise you to learn that there is another computational basis state, denoted ∣1⟩|1\rangle, which plays the same role as 11 does for a bit. Like ∣0⟩|0\rangle, ∣1⟩|1\rangle is just a notation for a two-dimensional vector, in this case:</p><p>∣1⟩:=[01].|1\rangle := \left[ \begin{array}{c} 0 \\ 1 \end{array} \right].</p><p>Again, we’ll gradually come to see that ∣1⟩|1\rangle has all the properties we expect of the 11 state of a classical bit.</p><p>Time for a few more questions. A reminder that these have a different purpose to conventional textbook exercises. Textbook exercises are about setting you challenges; the point of the questions below is instead to help you commit the answer to long-term memory.</p><h2>How to use (or not use!) the questions</h2><blockquote>Mathematics is a process of staring hard enough with enough perseverance at the fog of muddle and confusion to eventually break through to improved clarity. I’m happy when I can admit, at least to myself, that my thinking is muddled, and I try to overcome the embarrassment that I might reveal ignorance or confusion. Over the years, this has helped me develop clarity in some things, but I remain muddled in many others.<p>— William Thurston,<br />Fields-medal winning mathematician</p></blockquote><p>How should you think about it when you get one of these embedded questions wrong? Often in life testing means being judged, and being judged can be uncomfortable. If you don’t know the answer to a question you may feel like you’ve failed.</p><p>But the purpose of these questions has nothing to do with external judgment. Rather, they have two quite different purposes. One purpose is, as explained earlier, to help strengthen your memory, so your new knowledge is consolidated in your long-term memory. The second purpose is to help you diagnose what you do and don’t know, and to help you fill the gaps as rapidly as possible.</p><p>In this view, getting a question wrong is useful information. It pinpoints exactly what you need to understand, and puts the onus on you to figure it out. Honestly, the appropriate response to getting a question wrong is probably to throw your hands up in the air and shout “wonderful!”, since it’s at those points of what may appear to be “failure” that your learning rate will be at its highest.</p><p>With that said, it’s a common canard in education that “it doesn’t matter if you get something right or wrong, so long as you’re learning”. Unfortunately, that statement is often bullshit. If getting something right or wrong is used to determine your grade, or to influence other people’s opinion of you, then it damn well does matter.</p><p>For that reason, I suggest keeping your results private. They are for you alone, and their purpose should be solely to help you learn as rapidly as possible. If they’re not helping you – if they’re making you feel bad, for instance, or being used to judge you – then stop doing the questions.</p><p>You’ve probably noticed the questions are self-assessed. If you want to mark yourself “correct” sometimes, even when you’re not, go for it! What impact do you think that will have on your learning? Do you enjoy the slightly transgressive feeling? I must admit that I do. Don’t be embarrassed, if so: this is supposed to be, above all else, fun. Or try marking yourself wrong when you’re correct, or skipping the questions entirely. What impact do these actions have on your learning? The point is to figure out how to engage with the questions to learn as rapidly as possible. And that means experimenting playfully with how you engage, to find what works for you.</p><h2>How to approach this essay?</h2><p>This essay is an unusual form. It’s certainly not a product in the conventional startup sense; it’s a research project, an experiment in developing a new and improved form of reading. A conventional product would aim to draw you in, and form a regular, long-term habit. There’d be tens (or hundreds) of millions of words of content for you to read, and lots of people on social media excitedly pointing you toward that content. You’d engage every day, learning more and more and more.</p><p>That’s not what’s going on here. “Quantum Computing for the Very Curious” is, instead, like a video game or book or movie, a single one-off project for you to work through. So you commit to it for a while, and then the experience is over. (Also, like a video game, book, or movie, sequels are planned!)</p><p>With that said, it’s different from those forms too. Many people consume games, books, and movies as binge activities, hungrily devouring them until complete. “Quantum Computing for the Very Curious” is, by contrast, intentionally an experience spread out over time. Yes, you probably binge at first, working your way quickly through the text over a couple of hours. But then you return occasionally for brief review sessions, prompted by our notifications. That form of spaced testing is the best way for you to remember what you read. Still, while it might be optimal from the point of view of memory formation, it means not using some of the techniques that games, books, and movies use to keep you interested. Nonetheless, I hope you’ll be willing to trust the team at “Quantum Computing for the Very Curious”, and to participate in the experiment.</p><p>How can you get the most out of reading in this new mnemonic medium? The ideal is to do an initial read, followed by a few short review sessions over the coming weeks (prompted by our notifications) to help you internalize the ideas. Then (optionally) a followup read, where you can more deeply understand the material. And finally, some sessions of followup review to ensure you remember for the long term:</p><p></p><p>As you work through this process, we’ll track your overall progress toward completion (meaning: most questions reliably committed to memory), and each time you review we’ll show you that progress.</p><p>This is a larger commitment than traditional reading. But for a small factor in effort, you will understand the material far more deeply, and remember it for more than 10x as long. What’s more, while the reading process above looks complex, you’ll be cued at each step by reminders that will help the review process become a habit. Trust the reminders, and this will all happen as a matter of course.</p><p>You may find the essay particularly helpful if you’re taking an introductory class on quantum computing. If that’s your situation, I advise you to read the entire essay immediately at the beginning of semester (or even before), answering all the questions as you go. Then continue to follow the procedure described just above, taking a few minutes to complete each review session, prompted by the reminders you’ll be sent. This will make it far easier to understand the rest of the course you’re taking, and help you get much more out of it.</p><h2>General states of a qubit</h2><p>The computational basis states ∣0⟩|0\rangle and ∣1⟩|1\rangle are just two possible states for a qubit. Many more states are possible, and those extra states endow qubits with capabilities not available to ordinary classical bits. In general, remember, a quantum state is a two-dimensional vector. Here’s an example, with a graphical illustration emphasizing the vector nature of the state:</p><p>In this example, the state 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle is just 0.60.6 times the ∣0⟩|0\rangle vector, plus 0.80.8 times the ∣1⟩|1\rangle vector. In the usual vector notation that means the state is:</p><p>0.6∣0⟩+0.8∣1⟩=0.6[10]+0.8[01]=[0.60.8].0.6|0\rangle + 0.8 |1\rangle = 0.6 \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] + 0.8 \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] = \left[ \begin{array}{c} 0.6 \\ 0.8 \end{array} \right].</p><p>I’ve been talking about quantum states as two-dimensional vectors. What I didn’t yet mention is that in general they’re <em>complex vectors</em>, that is, they can have complex numbers as entries. Of course, the example just shown has real entries, as do the computational basis states. But for a general quantum state the entries can be complex numbers. So, for instance, another quantum state is the vector</p><p>1+i2∣0⟩+i2∣1⟩,\frac{1+i}{2} |0\rangle + \frac{i}{\sqrt{2}} |1\rangle,</p><p>which can be written in the conventional component vector representation as</p><p>[1+i2i2].\left[ \begin{array}{c} \frac{1+i}{2} \\ \frac{i}{\sqrt{2}} \end{array} \right].</p><p>Because quantum states are in general vectors with complex entries, the illustration above shouldn’t be taken too literally – the plane is a real vector space, not a complex vector space. Still, visualizing it as a plane is sometimes a handy way of thinking.</p><p>I’ve said what a quantum state is, as a mathematical object: it’s a two-dimensional vector in a complex vector space. But why is that true? What does it mean, physically, that it’s a vector? Why a complex vector space, and how should we think about the complex numbers? And what’s a quantum state good for, anyway?</p><p>These are good questions. But they do take some time to answer. For context consider that the discovery of quantum mechanics wasn’t a single event, but occurred over 25 years of work, from 1900 to 1925. Many Nobel prizes were won for milestones along the way. That includes Albert Einstein’s Nobel Prize, won primarily for work related to quantum mechanics (not relativity, as people sometimes assume).</p><p>When some of the brightest people in the world struggle for 25 years to develop a theory, it’s not an obvious theory! In fact, the idea of describing a simple quantum system using a complex vector in two dimensions summarizes much of what was learned over that 25 years. In that sense, it’s quite a simple and beautiful statement. But it’s not an obvious statement, and it’s not unreasonable that it might take a few hours to understand. That’s better than taking 25 years to understand!</p><p>As part of that journey toward understanding, let’s get familiar with some more nomenclature commonly used for quantum states.</p><p>One of the most common terms is <em>superposition</em>. People will say a state like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle is a <em>superposition</em> of ∣0⟩|0\rangle and ∣1⟩|1\rangle. All they mean is that the state is a linear combination of ∣0⟩|0\rangle and ∣1⟩|1\rangle. You may wonder why they don’t just say “linear combination” (and sometimes they do), but the reason is pretty much the same reason English-speakers say “hello” while Spanish-speakers say “hola” – the two terms come out of different cultures and different histories.</p><p>Another common term is <em>amplitude</em>. An amplitude is the coefficient for a particular state in superposition. For instance, in the state 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle the amplitude for ∣0⟩|0\rangle is 0.60.6, and the amplitude for ∣1⟩|1\rangle is 0.80.8.</p><p>We’ve learnt that a quantum state is a two-dimensional complex vector. Actually, it can’t be just any old vector, a fact you might have guessed from the very particular amplitudes in some of the examples above. There’s a constraint. The constraint is this: <em>the sums of the squares of the amplitudes must be equal to 11</em>.</p><p>So, for example, for the state 0.6∣0⟩+0.8∣1⟩0.6 |0\rangle+0.8 |1\rangle the sum of the squares of the amplitudes is 0.62+0.820.6^2+0.8^2, which is 0.36+0.64=10.36+0.64 = 1, as we desired.</p><p>For a more general quantum state, the amplitudes can be complex numbers, let’s denote them by α\alpha and β\beta so the state is α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. The constraint is now that the sum of the squares of the amplitudes is 11, i.e., ∣α∣2+∣β∣2=1|\alpha|^2+|\beta|^2 = 1.</p><p>This is called the <em>normalization constraint</em>.</p><p>It’s called that because if you think of ∣0⟩|0\rangle and ∣1⟩|1\rangle as orthonormal vectors, as I drew them earlier,</p><p>then the normalization constraint is the requirement that the length of the state is equal to 11. So it’s a unit vector, or a <em>normalized</em> vector, and that’s why this is called a normalization constraint.</p><p>Summing up all these ideas in one sentence: <em>the quantum state of a qubit is a vector of unit length in a two-dimensional complex vector space known as state space.</em></p><p>We’ve gone through a few refinements of this sentence but that sentence is the final version – there’s no missing parts, or further refinement necessary! That’s what the quantum state of a qubit is. Of course, we will explore the definition further, deepening our understanding, but it will always come back to that basic fact.</p><p>One common gotcha in thinking about qubits is to look at the ∣0⟩|0\rangle state and think it must be the zero vector in the vector space, often denoted 00. But that’s not right at all. The zero vector is at the origin, 0=[00]0 = \left[ \begin{array}{c} 0 \\ 0 \end{array} \right], while the ∣0⟩|0\rangle vector is quite different, ∣0⟩=[10]≠0|0\rangle = \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \neq 0. It’s just an unfortunate notational accident that ∣0⟩|0\rangle looks as though it should be the 00 vector. Fortunately, in practice this distinction is easy to get used to, and doesn’t cause confusion. But it’s worth noting.</p><h2>What does the quantum state mean? Why is it a vector in a complex vector space?</h2><blockquote>My own conclusion is that today there is no interpretation of quantum mechanics that does not have serious flaws. This view is not universally shared. Indeed, many physicists are satisfied with their own interpretation of quantum mechanics. But different physicists are satisfied with different interpretations.<p>— Steven Weinberg,<br />Nobel Laureate in Physics</p></blockquote><p>Let’s come back to the question of what the quantum state means, and why it’s a vector in a complex vector space.</p><p>In the case of classical bits, it’s pretty easy to think about the state. You can think of the 00 or 11 states of a bit as corresponding to two very different (but stable) states of a physical system. For instance, a 00 or 11 can be indicated by the presence or absence of a hole at some location in a punch card. And so a single punch card can be used to store hundreds or thousands of bits:</p><p></p><p>Source: <a href="https://commons.wikimedia.org/wiki/File:Blue-punch-card-front.png">Gwern</a> (2006).</p><p>Most ways of storing classical bits are variations on this idea. For instance, the dynamic random access memory (RAM) inside your computer is based on the idea of having two tiny metal plates separated by a miniscule gap. Electric charge is stored on those plates, setting up an electric field between them. The 00 and 11 states of the bit correspond to two different configurations of charge on the plates. In practice, real dynamic RAM systems use slightly more elaborate ideas, but that’s the heart of it. This is harder to think about than punch cards – most of us don’t have so much experience thinking about moving electric charges around metal plates. But it’s still pretty concrete.</p><p>So, how should we think about quantum states? The ∣0⟩|0\rangle and ∣1⟩|1\rangle states often aren’t difficult to think about, since they often correspond to very concrete physical states of the world, much like classical bits. Indeed, in some proposals they may correspond to different charge configurations, similar to dynamic RAM. Or perhaps a photon being in one of two different locations in space – again, a pretty simple, concrete notion, even if photons aren’t that familiar. There are also many more exotic proposals for the ∣0⟩|0\rangle and ∣1⟩|1\rangle states. But by and large you can think of the computational basis states as representing a physical system in one of two well-defined configurations.</p><p>Of course, qubits have states which aren’t computational basis states, states like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle. How should we think about such superposition states? At least in popular media accounts, a very common description is that a state like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle + 0.8|1\rangle is <em>“simultaneously”</em> in the ∣0⟩|0\rangle state and the ∣1⟩|1\rangle state.</p><p>I must confess, I don’t understand what people mean by this. As far as I can tell, what they’re trying to do is explain the quantum state in terms of classical concepts they’re already familiar with. But I can’t make much sense of it – saying 0.6∣0⟩+0.8∣1⟩0.6|0\rangle + 0.8|1\rangle is <em>simultaneously</em> in the ∣0⟩|0\rangle state and the ∣1⟩|1\rangle state seems like word salad, and makes about as much sense to me as Lewis Carroll’s nonsense poem <em>Jabberwocky</em>:</p><blockquote>’Twas brillig, and the slithy toves<br />     Did gyre and gimble in the wabe:<br />All mimsy were the borogoves,<br />    And the mome raths outgrabe.<br />…</blockquote><p>Of course, lacking any other interpretation it’s tempting to try to impose our classical prejudices on the quantum state. Or, even if you reject that, to get hung up worrying about what a quantum state is. But the trouble is that there is enormous disagreement amongst physicists themselves about how to think about the quantum state. Indeed, many active researchers are trying to understand what the correct way of thinking about the quantum state is, exploring multiple approaches in great depth. So we’re going to defer worrying too much about this until later.</p><p>To understand why we’re deferring, suppose someone gives you a Rubik’s cube (or some other challenging puzzle or game) for the first time, all scrambled up. You start to theorize about the best ways of solving it, how to understand it, and so on. But you never actually play around with it, getting familiar with how it behaves.</p><p>Often the best way to understand something is to first use it, to get comfortable, to play a lot, and to do lots of informal experiments. As you build familiarity you understand why things are the way they are. At that point, you can go back and better understand the meaning of the basics.</p><p>Well, we can think of quantum computing and quantum mechanics as an especially complicated type of puzzle! So the strategy we’re taking is to start with the mathematics of quantum computing – we’ll keep getting familiar with qubits and the quantum state, and developing the consequences. Doing that is how we’ll build up intuition, and will give us the chops needed to come back and think harder about the meaning of the quantum state.</p><h2>Part II: Introducing quantum logic gates</h2><p>In Part I we learned about the state of a qubit. But in order to quantum compute, it’s not enough just to understand quantum states. We need to be able to do things with them! We do that using <em>quantum logic gates</em>.</p><p>A quantum logic gate is simply a way of manipulating quantum information, that is, the quantum state of a qubit or a collection of qubits. They’re analogous to the classical logic gates used in ordinary, everyday computers – gates such as the AND, OR, and NOT gates. And, much like classical gates’ role in conventional computers, quantum gates are the basic building blocks of quantum computation. They’re also a convenient way of describing many other quantum information processing tasks, such as quantum teleportation.</p><p>In Part II of this essay we’ll discuss several types of quantum logic gate. As we’ll see, the gates we discuss are sufficient to do any quantum computation. In particular, much as any classical computation can be built up using AND, OR, and NOT gates, the quantum gates we describe over the next few sections suffice to do any quantum computation.</p><p>Many of the quantum gates we’ll learn about are based on familiar classical logic gates. But a few are different. Those differences appear innocuous, almost trivial. But in those differences lies the power of quantum computation, and the possibility for quantum computers to be vastly superior to classical computers.</p><p>Part II is, frankly, a bit of a slog. Learning quantum gates is like learning basic vocabulary in a new language: there’s no getting round spending a fair bit of time working on it. Still, the spaced-repetition testing should make this basic memory work much easier than is ordinarily the case. And it will prepare you well for some of the more conceptual issues discussed in Part III, where we return to high-level questions about the ultimate nature of computation, and what quantum computers are good for.</p><h2>The quantum NOT gate</h2><p>Let’s take a look at our very first quantum logic gate, the <em>quantum NOT gate</em>. As you can no doubt surmise, the quantum NOT gate is a generalization of the classical NOT gate. On the computational basis states the quantum NOT gate does just what you’d expect, mimicking the classical NOT gate. That is, it takes the ∣0⟩|0\rangle state to ∣1⟩|1\rangle, and vice versa:</p><p>NOT∣0⟩=∣1⟩NOT|0\rangle = |1\rangle</p><p>NOT∣1⟩=∣0⟩NOT|1\rangle = |0\rangle</p><p>But the computational basis states aren’t the only states possible for a qubit. What happens when we apply the NOT gate to a general superposition state, that is, α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle? In fact, it does pretty much the simplest possible thing: it acts linearly on the quantum state, interchanging the role of ∣0⟩|0\rangle and ∣1⟩|1\rangle:</p><p>NOT(α∣0⟩+β∣1⟩)=α∣1⟩+β∣0⟩.NOT (\alpha|0\rangle +\beta|1\rangle) = \alpha|1\rangle+\beta |0\rangle.</p><p>I’ve been using the notation NOT for the quantum NOT gate. But for historical reasons people working on quantum computing usually use a different notation, the notation XX. And so the above may be rewritten:</p><p>X(α∣0⟩+β∣1⟩)=α∣1⟩+β∣0⟩.X (\alpha|0\rangle +\beta|1\rangle) = \alpha|1\rangle+\beta |0\rangle.</p><p>I’ll use the terms XX gate and NOT gate interchangeably.</p><p>Historically, the notation XX traces its origin to 1927, when the physicist Wolfgang Pauli introduced an operation sxs_x (often written σx\sigma_x in textbooks today) to help describe rotations of certain objects around the xx spatial axis. This operation later became of interest to people working on quantum computing. But by that point the ss (and the connection to rotation) was irrelevant, and so sxs_x just became XX.</p><p>What we’ve seen so far are very algebraic ways of writing down the way the XX gate works. There’s an alternate representation, the <em>quantum circuit</em> representation. In a quantum circuit we depict an XX gate as follows:</p><p>The line from left to right is what’s called a <em>quantum wire</em>. A quantum wire represents a single qubit. The term “wire” and the way it’s drawn looks like the qubit is moving through space. But it's often helpful to instead think of left-to-right as representing the passage of time. So the initial segment of wire is just the passage of time, with nothing happening to the qubit. Then the XX gate is applied. And then the quantum wire continues, leaving the desired output.</p><p>Sometimes we’ll put the input and output states explicitly in the quantum circuit, so we have something like:</p><p>So that’s the quantum circuit representation of the XX gate. It is, in fact, our first quantum computation. A simple computation, involving just a single qubit and a single gate, but a genuine quantum computation nonetheless!</p><p>There’s a third representation for the XX gate that’s worth knowing about, a representation as a 2×22 \times 2 matrix:</p><p>X=[0110].X = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right].</p><p>To understand in what sense this is a representation of the NOT gate, recall that α∣0⟩+β∣1⟩\alpha|0\rangle + \beta|1\rangle is just the vector [αβ]\left[ \begin{array}{c} \alpha \\ \beta \end{array} \right]. And so we have:</p><p>[0110](α∣0⟩+β∣1⟩)=[0110][αβ]=[βα]=α∣1⟩+β∣0⟩=X(α∣0⟩+β∣1⟩).\begin{aligned} \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] (\alpha|0\rangle + \beta|1\rangle) &amp; = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] \left[ \begin{array}{c} \alpha \\ \beta \end{array} \right] \\ &amp; = \left[ \begin{array}{c} \beta \\ \alpha \end{array} \right] \\ &amp; = \alpha|1\rangle+\beta|0\rangle \\ &amp; = X (\alpha|0\rangle + \beta|1\rangle). \end{aligned}</p><p>This tells us that XX and [0110]\left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] act in exactly the same way on all vectors, and thus are the same operation. In fact, as we’ll see later, it turns out that all quantum gates can be thought of as matrices, with the matrix entries specifying the exact details of the gate.</p><p>By the way, regarding the XX gate as a matrix clarifies what may have been a confusing point earlier. I wrote the XX gate as having the action X∣0⟩=∣1⟩X|0\rangle = |1\rangle, X∣1⟩=∣0⟩X|1\rangle = |0\rangle. Implicitly – I never quite said this, though it’s true – the XX gate is a mathematical function, taking input states to output states. But when we write functions we usually use parentheses, so why didn’t I write X(∣0⟩)X(|0\rangle) and similarly for ∣1⟩|1\rangle? The reason is that for linear functions, i.e., matrices, it’s conventional to omit parentheses and just write X∣0⟩X|0\rangle – function application <em>is</em> just matrix multiplication.</p><h2>Quantum wires: why the simplest quantum circuit is often also the hardest to implement</h2><p>We’ve now seen a simple quantum circuit and quantum logic gate. But it’s not quite the simplest possible quantum circuit. The simplest possible quantum circuit does nothing at all. That is, it’s a single quantum wire:</p><p>This circuit is just a single qubit being preserved in time. To be more explicit, if some arbitrary quantum state ∣ψ⟩|\psi\rangle is input to the circuit, then the exact same state ∣ψ⟩|\psi\rangle is output (it’s common practice to use the Greek letter ψ\psi to denote an arbitrary quantum state):</p><p>Mathematically, this circuit is trivial. But physically it’s far from trivial. In many physical systems, the quantum wire is actually one of the hardest quantum computations to implement!</p><p>The reason is that quantum states are often incredibly fragile. If your qubit is being stored in some tiny system – perhaps a single photon or a single atom – then it’s very, very easy to disturb that state. It really doesn’t take much to upset an atom or a photon. And so while quantum wires are mathematically trivial, they can be one of the hardest elements to build in real systems.</p><p>That said, there are some systems where quantum wires are easy to implement. If you store your qubit in a neutrino then the state will actually be pretty well preserved. The reason is that neutrinos barely interact with other forms of matter at all – a neutrino can easily pass through a mile of lead without being disturbed. But while it’s intriguing that neutrinos are so stable, it doesn’t mean they make good qubits. The trouble is that since there’s no easy way of using ordinary matter to interact with them, we can’t manipulate their quantum state in a controlled fashion, and so can’t implement a quantum gate.</p><p>There’s a tension here that applies to many proposals to do quantum information processing, not just neutrinos. If we want to store the quantum state, then it’s helpful if our qubits only interact very weakly with other systems, so those systems don’t disrupt them. But if the qubits only interact weakly with other systems then that also makes it hard to manipulate the qubits. Thus, systems which make good quantum wires are often hard to build quantum gates for. Much of the art of designing quantum computers is about finding ways to navigate this tension. Often, that means trying to design systems which interact weakly most of the time, but some of the time can be caused to interact strongly, and so serve as part of a quantum gate.</p><p>You’ll note that some of the questions above have a different flavor to the questions earlier in the essay. Early questions had cut-and-dried answers. The answer to the question “What’s the standard notation for the quantum NOT gate?” is just: “XX”. But some of the questions above have less well-specified answers. They’re a little fluffy.</p><p>This fluffiness may cause you difficulties as you decide how to respond. Your answer to the question “Why is it that systems which make good quantum wires are often hard to build quantum gates for?” may not quite match the answer given. If this is the case, don’t worry. You should mark yourself correct if you’re confident you’ve understood the point, even in terms different from my phrasing. And mark yourself incorrect if the point still needs reinforcement.</p><h2>A multi-gate quantum circuit</h2><p>Let’s take a look at a simple multiple-gate quantum circuit. It’s just a circuit with two XX gates in a row:</p><p>It’s worth pausing for a moment, and trying to guess what this circuit does to the input state. It’s worth doing this even if you usually find this kind of guessing frustrating. Even when you get stuck, building up strategies for dealing with stuckness is part of learning any difficult subject. So take a minute or so now.</p><p>We’ll try two different ways of figuring out what’s going on. Here’s one approach, based on applying XX twice to an arbitrary input state, α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. It’s simple algebra, using the fact XX interchanges the ∣0⟩|0\rangle and ∣1⟩|1\rangle states:</p><p>X(X(α∣0⟩+β∣1⟩))=X(α∣1⟩+β∣0⟩)=α∣0⟩+β∣1⟩\begin{aligned} X(X(\alpha|0\rangle+\beta|1\rangle)) &amp; = X(\alpha|1\rangle + \beta|0\rangle) \\ &amp; = \alpha|0\rangle + \beta|1\rangle \end{aligned}</p><p>So the net effect is to recover the original quantum state, no matter what that state was. In other words, this circuit is equivalent to a quantum wire:</p><p>A second way of seeing this is based on the matrix representation we found earlier for the XX gate. Observe that if the input is some arbitrary quantum state ∣ψ⟩|\psi\rangle, then after the first gate the state is X∣ψ⟩X|\psi\rangle, and after the second gate the state is XX∣ψ⟩X X |\psi\rangle. Then we observe that the product XXX X is</p><p>XX=[0110][0110]=[1001].\begin{aligned} XX &amp; = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] \\ &amp; = \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; 1 \end{array} \right]. \end{aligned}</p><p>That is, XXXX is the identity operation, and so the output XX∣ψ⟩XX|\psi\rangle is just the original input ∣ψ⟩|\psi\rangle. In other words, two XX gates is the same as a quantum wire. And so we’ve arrived at the same conclusion in a different way, using matrix multiplication. Doing such matrix multiplications is a pretty common way of analyzing quantum circuits.</p><h2>The Hadamard gate</h2><p>We’ve seen our first quantum gate, the NOT or XX gate. Of course, the XX didn’t appear to do all that much beyond what is possible with a classical NOT gate. In this section I introduce a gate that clearly involves quantum effects, the <em>Hadamard</em> gate.</p><p>As with the XX gate, we’ll start by explaining how the Hadamard gate acts on computational basis states. Denoting the gate by HH, here’s what it does:</p><p>H∣0⟩=∣0⟩+∣1⟩2H|0\rangle = \frac{|0\rangle +|1\rangle}{\sqrt 2}</p><p>H∣1⟩=∣0⟩−∣1⟩2H|1\rangle = \frac{|0\rangle -|1\rangle}{\sqrt 2}</p><p>Of course, ∣0⟩|0\rangle and ∣1⟩|1\rangle aren’t the only quantum states. How does the Hadamard gate act on more general quantum states?</p><p>It won’t surprise you to learn that it acts linearly, as did the quantum NOT gate. In particular, the Hadamard gate takes a superposition α∣0⟩+β∣1⟩\alpha|0\rangle + \beta|1\rangle to the corresponding superposition of outputs:</p><p>H(α∣0⟩+β∣1⟩)=α(∣0⟩+∣1⟩2)+β(∣0⟩−∣1⟩2).H(\alpha|0\rangle + \beta|1\rangle) = \alpha \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} \right) + \beta \left( \frac{|0\rangle-|1\rangle}{\sqrt 2} \right).</p><p>That’s a mess. We can make it less of a mess by combining the ∣0⟩|0\rangle terms together, and also the ∣1⟩|1\rangle terms together:</p><p>H(α∣0⟩+β∣1⟩)=α+β2∣0⟩+α−β2∣1⟩.H(\alpha|0\rangle + \beta|1\rangle) = \frac{\alpha+\beta}{\sqrt 2} |0\rangle + \frac{\alpha-\beta}{\sqrt 2}|1\rangle.</p><p>That’s better, but still not pretty! Fortunately, we mostly won’t be dealing with such complex expressions. The only reason I’ve done it here is to be really explicit. Instead of dealing with such explicit expressions, we’ll mostly work with the HH gate in its circuit and matrix representations (see below). Those let us focus at a more enlightening level of abstraction, rather than messing around with coefficients.</p><p>Indeed, much work on quantum computing is about attempting to develop ways of moving from low levels of abstraction to higher, more conceptual levels. Up to now most of our work has been at a very low level, seeming more an exercise in linear algebra than a discussion of a new model of computing. That perhaps seems strange. After all, if you were explaining classical computers to someone, you wouldn’t start in the weeds, with AND and NOT gates and the like. You’d start with a well-designed high-level programming language, and then bounce back and forth between different layers of abstraction. Modern computers aren’t just about logic gates – they’re at least as much about beautiful higher-level ideas: say, lazy evaluation, or higher-order functions, or homoiconicity, and so on.</p><p>I wish I could start with high-level abstractions for quantum computers. However, we’re still in the early days of quantum computing, and for the most part humanity hasn’t yet discovered such high-level abstractions. People are still scratching around, trying to find good ideas.</p><p>That’s an exciting situation: it means almost all the big breakthroughs are ahead. There’s a sense in which we still understand very little about quantum computing. That might sound surprising: after all, there are <a href="https://www.amazon.com/Quantum-Computation-Information-10th-Anniversary/dp/1107002176/ref=sr_1_2?s=books&amp;ie=UTF8&amp;qid=1541350337&amp;sr=1-2">great big fat textbooks on the subject</a>. But you could have written a great big fat textbook about the ENIAC computer in the late 1940s. It was, after all, a very complex system. That textbook would have looked intimidating, but it wouldn’t have been the final word in computing. For the most part the way we understand quantum computing today is at an ENIAC-like level, looking at the nuts-and-bolts of qubits and logic gates and linear algebra, and wondering what the higher-level understanding may be. The situation can be thought of as much like programming language design before the breakthroughs that led to languages such as Lisp and Haskell and Prolog and Smalltalk. That makes it a remarkable creative opportunity, a challenge for the decades and centuries ahead.</p><p>Speaking of nuts-and-bolts, let’s get back to the Hadamard gate. Here’s the circuit representation for the Hadamard gate. It looks just like the XX gate in the circuit representation, except we change the gate label to HH:</p><p>Just like the XX gate, HH has a matrix representation:</p><p>H=12[111−1].H = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right].</p><p>To see that this matrix representation is correct, let’s check the action of the matrix on the ∣0⟩|0\rangle and the ∣1⟩|1\rangle states. Here we check for the ∣0⟩|0\rangle state:</p><p>12[111−1]∣0⟩=12[111−1][10]=12[11]=∣0⟩+∣1⟩2.\begin{aligned} \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] |0\rangle &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \\ &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{c} 1 \\ 1 \end{array} \right] \\ &amp; = \frac{|0\rangle+|1\rangle}{\sqrt 2}. \end{aligned}</p><p>That is, this matrix acts the same way as the Hadamard gate on the ∣0⟩|0\rangle state. Now let’s check on the ∣1⟩|1\rangle state:</p><p>12[111−1]∣1⟩=12[111−1][01]=12[1−1]=∣0⟩−∣1⟩2.\begin{aligned} \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] |1\rangle &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] \\ &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{c} 1 \\ -1 \end{array} \right] \\ &amp; = \frac{|0\rangle-|1\rangle}{\sqrt 2}. \end{aligned}</p><p>So the matrix acts the same way as the Hadamard gate on both the ∣0⟩|0\rangle and ∣1⟩|1\rangle states. By the linearity of matrix multiplication it follows that the matrix acts the same way as the Hadamard on all input states, and so they are the same operation.</p><p>What makes the Hadamard gate interesting as a quantum gate? What can we use it to do?</p><p>We don’t (quite) have enough background to give precise answers to these questions yet. But there is an analogy which gives insight.</p><p>Imagine you are living in North Africa, thousands of years in the past, and decide for some reason that you want to get over to the Iberian peninsula. If you don’t yet have boats or some other reliable method of moving across large bodies of water, you need to go all the way across Africa, past the Arabian peninsula, up and around through Europe, back to the Iberian peninsula:</p><p></p><p>Original photo source: Reto Stöckli, <a href="https://visibleearth.nasa.gov/view.php?id=73884">NASA Earth Observatory</a> (2004).</p><p>Suppose, however, that you invent a new device, the boat, which expands the range of locations you can traverse. Then you can take a much more direct route over to the Iberian peninsula, greatly cutting down the time required:</p><p></p><p>What the Hadamard and similar gates do is expand the range of operations that it’s possible for a computer to perform. That expansion makes it possible for the computer to take shortcuts, as the computer “moves” in a way that’s not possible in a conventional classical computer. And, we hope, that may enable us to solve some computational problems faster.</p><p>Another helpful analogy is to the game of chess. Imagine you’re playing chess and the rules are changed in your favor, enabling your rook an expanded range of moves. That extra flexibility might enable you to achieve checkmate much faster because you can get to new positions much more quickly.</p><p>A similar thing is going on with the Hadamard gate. By expanding the range of states we can access (or, more precisely, the range of dynamical operations we can generate) beyond what’s possible on a classical computer, it becomes possible to take shortcuts in our computation.</p><p>We’ll see explicit examples in subsequent essays.</p><p>To get more familiar with the Hadamard gate, let’s analyze a simple circuit:</p><p>What’s this circuit do?</p><p>Before we compute, it’s worth pausing for a second to try guessing the result. The point of guessing isn’t to get it right – rather, it’s to challenge yourself to start coming up with heuristic mental models for thinking about what’s going on in quantum circuits. Those mental models likely won’t be very good at first, but that’s okay – if you keep doing this, they’ll get better.</p><p>Here’s one heuristic you can use to think about this circuit: you can think of HH as sort of mixing the ∣0⟩|0\rangle and ∣1⟩|1\rangle states together. So if you apply HH twice to ∣0⟩|0\rangle, perhaps it would thoroughly mix the ∣0⟩|0\rangle and ∣1⟩|1\rangle up together. What sort of state do you think would result, according to this heuristic? Do you believe the result? Why or why not? Can you think of other heuristics that might help you guess an answer?</p><p>Alright, let’s compute what actually happens. After we apply the first Hadamard to ∣0⟩|0\rangle we get</p><p>∣0⟩+∣1⟩2.\frac{|0\rangle+|1\rangle}{\sqrt{2}}.</p><p>Then we apply a second Hadamard gate. This takes the ∣0⟩|0\rangle term above to ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} and the ∣1⟩|1\rangle term to ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2}, so the output is:</p><p>12(∣0⟩+∣1⟩2+∣0⟩−∣1⟩2).\frac{1}{\sqrt 2} \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} + \frac{|0\rangle-|1\rangle}{\sqrt 2} \right).</p><p>If you look at the expression above, you’ll notice that the ∣1⟩|1\rangle terms cancel each other out, so you’re just left with the ∣0⟩|0\rangle terms. Collecting them up, we’re left with the ∣0⟩|0\rangle state, same as we started with:</p><p>12(∣0⟩2+∣0⟩2)=∣0⟩.\frac{1}{\sqrt 2} \left(\frac{|0\rangle}{\sqrt 2}+ \frac{|0\rangle}{\sqrt 2} \right) = |0\rangle.</p><p>In a similar fashion, after we run the ∣1⟩|1\rangle state through the first Hadamard gate, we get:</p><p>∣0⟩−∣1⟩2.\frac{|0\rangle-|1\rangle}{\sqrt{2}}.</p><p>Then we apply a second Hadamard gate to get:</p><p>12(∣0⟩+∣1⟩2−∣0⟩−∣1⟩2).\frac{1}{\sqrt 2} \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} - \frac{|0\rangle-|1\rangle}{\sqrt 2} \right).</p><p>This time it’s the ∣0⟩|0\rangle terms which cancel out, and the ∣1⟩|1\rangle terms reinforce. When we collect up these terms, we see that the output is just the ∣1⟩|1\rangle state, same as we started with. And so both the ∣0⟩|0\rangle and ∣1⟩|1\rangle states are left unchanged by this quantum circuit, and the net effect of the circuit is exactly the same as a quantum wire:</p><p></p><p>There’s an alternate way of seeing this, which I’ll sketch out without working through in detail. It’s to note that if we input an arbitrary quantum state ∣ψ⟩|\psi\rangle to the circuit, then the output must be HH∣ψ⟩H H |\psi\rangle, i.e., the result of applying two HH matrices to ∣ψ⟩|\psi\rangle. But if you just compute the matrix product HHH H it turns out to be the 2×22 \times 2 identity matrix, HH=IH H = I. And so the output from the circuit must be the same as the input, HH∣ψ⟩=I∣ψ⟩=∣ψ⟩HH|\psi\rangle = I |\psi\rangle = |\psi\rangle, just as from a quantum wire.</p><p>Of course, this result violates our intuitive guess, which was that two Hadamards would thoroughly mix up the ∣0⟩|0\rangle and the ∣1⟩|1\rangle. It’s interesting to ponder what went wrong with our intuition, say by looking through the calculation for HH acting twice on ∣0⟩|0\rangle. You see that after the second gate the ∣1⟩|1\rangle terms exactly cancel one another out, while the ∣0⟩|0\rangle terms reinforce one another.</p><p>This seems innocuous, almost like a mathematical accident. Still, I draw your attention to it because this type of cancellation or reinforcement is crucial in many algorithms for quantum computers. Without getting into details, the rough way many such algorithms work is to first use Hadamard gates to “spread out” in quantum states like ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} (or many-qubit analogs), i.e., in superpositions of multiple computational basis states. At the end of the algorithm they use clever patterns of cancellation and reinforcement to bring things back together again into one (or possibly a few, in the many-qubit case) computational basis state, containing the desired answer. That’s a somewhat vague and perhaps tantalizing description, but the point to take away is that the kind of cancellation-or-reinforcement we saw above is actually crucial in many quantum computations.</p><div><p>I’ll now pose a few simple exercises related to the Hadamard gate. Unlike the spaced-repetition questions, the point of the exercises below isn’t as an aid to memory, and so you won’t see these exercises repeatedly. Rather, they’re here because (should you choose to work through them) they will help you better understand the material of the essay. But they’ll only incidentally help with memorization. We’ll follow them with some spaced-repetition questions. Note that even if you don't work through the exercises, it's worth at least reading through them, since some of the results will be tested in the spaced-repetition questions.</p><p><strong>Exercise:</strong> Verify that HH=IHH = I, where II is the 2×22 \times 2 identity matrix, I=[1001]I = \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; 1 \end{array} \right].</p><p><strong>Exercise:</strong> Suppose that instead of HH we’d defined a matrix JJ by:</p><p>J:=12[1111]J := \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; 1 \end{array} \right]</p><p>At first, it might seem that JJ would make an interesting quantum gate, along lines similar to HH. For instance, J∣0⟩=∣0⟩+∣1⟩2J|0\rangle = \frac{|0\rangle+|1\rangle}{\sqrt 2}, and J∣1⟩=∣0⟩+∣1⟩2J|1\rangle = \frac{|0\rangle+|1\rangle}{\sqrt 2}. These are both good, normalized quantum states. But what happens if we apply JJ to the quantum state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2}? Why does this make JJ unsuitable for use as a quantum gate?</p><p><strong>Exercise:</strong> Consider the quantum circuit:</p><p></p><p>Explain why the output from this circuit is XH∣ψ⟩XH|\psi\rangle, not HX∣ψ⟩HX|\psi\rangle, as you might naively assume if you wrote down gates in the order they occur in the circuit. This is a common gotcha to be aware of – it occurs because quantum gates compose left-to-right in the circuit representation, while matrix multiplications compose right-to-left.</p></div><h2>Measuring a qubit</h2><p>Suppose a (hypothetical!) quantum physicist named Alice prepares a qubit in her laboratory, in a quantum state α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. Then she gives her qubit to another quantum physicist, Bob, but doesn’t tell him the values of α\alpha and β\beta. Is there some way Bob can figure out α\alpha and β\beta? That is, is there some experiment Bob can do to figure out the identity of the quantum state?</p><p>The surprising answer to this question turns out to be <em>NO!</em> There is, in fact, no way to figure out α\alpha and β\beta if they start out unknown. To put it a slightly different way, the quantum state of any system – whether it be a qubit or a some other system – is not directly observable.</p><p>I say this is surprising, because it’s very different from our usual everyday way of thinking about how the world works. If there’s something wrong with your car, a mechanic can use diagnostic tools to learn about the internal state of the engine. The better the diagnostic tools, the more they can learn. Of course, there may be parts of the engine that would be impractical to access – maybe they’d have to break a part, or use a microscope, for instance. But you’d probably be rather suspicious if the mechanic told you the laws of physics prohibited them from figuring out the internal state of the engine.</p><p>Similarly, when you first start learning about quantum circuits, it seems like we should be able to observe the amplitudes of a quantum state whenever we like. But that turns out to be prohibited by the laws of physics. Those amplitudes are better thought of as a kind of hidden information.</p><p>So, what can we figure out from the quantum state? Rather than somehow measuring α\alpha and β\beta, there are other ways of getting useful information out of a qubit. Let me describe an especially important process called <em>measurement in the computational basis</em>. This is a fundamental primitive in quantum computing: it’s the way we typically extract information from our quantum computers. I’ll explain now how it works for a single qubit, and later generalize to multi-qubit systems.</p><p>Suppose a qubit is in the state α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. When you measure this qubit in the computational basis it gives you a classical bit of information: it gives you the outcome 00 with probability ∣α∣2|\alpha|^2, and the outcome 11 with probability ∣β∣2|\beta|^2.</p><p>To think a little more concretely about this process, suppose your qubit is instantiated in some physical system. Perhaps it’s being stored in the state of an atom somehow. It doesn’t matter exactly what, but you have this qubit in your laboratory. And you have some measurement apparatus, probably something large and complicated, maybe involving lasers and microprocessors and a screen for readout of the measurement result. And this measurement apparatus interacts in some way with your qubit.</p><p>After the measurement interaction, your measurement apparatus registers an outcome. For instance, it might be that you get the outcome 00. Or maybe instead you get the outcome 11. The crucial fact is that the outcome is ordinary classical information – the stuff you already know how to think about – which you can then use to do other things, and to control other processes.</p><p>So the way a quantum computation works is that we manipulate a quantum state using a series of quantum gates, and then at the end of the computation (typically) we do a measurement to read out the result of the computation. If our quantum computer is just a single qubit, then that result will be a single classical bit. If, as is more usually the case, it’s multiple qubits, then the measurement result will be multiple classical bits.</p><p>A fundamental fact about this measurement process is that it disturbs the state of the quantum system. In particular, it doesn’t just leave the quantum state alone. After the measurement, if you get the outcome 00 then the state of the qubit afterwards (the “posterior state”) is the computational basis state ∣0⟩|0\rangle. On the other hand, if you get the outcome 11 then the posterior state of the qubit is the computational basis state ∣1⟩|1\rangle.</p><p>Summing all this up: if we measure a qubit with state α∣0⟩+β∣1⟩\alpha |0\rangle+\beta|1\rangle in the computational basis, then the outcome is a classical bit: either 00, with probability ∣α∣2|\alpha|^2, or 11, with probability ∣β∣2|\beta|^2. The corresponding state of the qubit after the measurement is ∣0⟩|0\rangle or ∣1⟩|1\rangle.</p><p>A key point to note is that after the measurement, no matter what the outcome, α\alpha and β\beta are gone. No matter whether the posterior state is ∣0⟩|0\rangle or ∣1⟩|1\rangle, there is no trace of α\alpha or β\beta. And so you can’t get any more information about them. In that sense, α\alpha and β\beta are a kind of hidden information – the measurement doesn’t tell you what they were.</p><p>One reason this is important is because it means you can’t store an infinite amount of classical information in a qubit. After all, α\alpha is a complex number, and you could imagine storing lots of classical bits in the binary expansion of the real component of α\alpha. If there was some experimental way you could measure the value of α\alpha exactly, then you could extract that classical information. But without a way of measuring α\alpha that’s not possible.</p><p>I’ve been talking about measurement in the computational basis. In fact, there are other types of measurement you can do in quantum systems. But there’s a sense in which computational basis measurements turn out to be fundamental. The reason is that by combining computational basis measurements with quantum gates like the Hadamard and NOT (and other) gates, it’s possible to simulate arbitrary quantum measurements. So this is all you absolutely need to know about measurement, from an in-principle point of view.</p><p>It’s useful to have a way of denoting measurements in the quantum circuit model. Here’s a simple example:</p><p></p><p>It’s a single-qubit quantum circuit, with input the state ∣ψ⟩|\psi\rangle. A NOT gate is applied, followed by a Hadamard gate. The circuit finishes with a measurement in the computational basis, denoted by the slightly elongated semi-circle. The mm is a classical bit denoting the measurement result – either 00 or 11 – and we use the double wire to indicate the classical bit mm going off and being used to do something else.</p><p>Of course, I said above that after measurement the qubit is in either the ∣0⟩|0\rangle or the ∣1⟩|1\rangle state. You might think we’d draw a corresponding quantum wire coming out the other side of the measurement. But often in quantum circuits the qubit is discarded after measurement, and that’s assumed by this notation.</p><p>One final comment on measurement is that it’s connected to the normalization condition for quantum states that we discussed earlier. Suppose we have the quantum state:</p><p>α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle</p><p>Then the probability of the two possible measurement outcomes, 00 and 11, must sum to 11, and so we have:</p><p>∣α∣2+∣β∣2=1.|\alpha|^2+|\beta|^2 = 1.</p><p>This is exactly the normalization condition for quantum states – i.e., the quantum state must have length 11. The origin of that constraint is really just the fact that measurement probabilities must add up to 11.</p><div><p><strong>Exercise:</strong> Suppose we’ve been given either the state ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} or the state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2}, but not told which state we’ve been given. We’d like to figure out which state we’ve been given. If we just do a computational basis measurement, then for both states we get outcome 00 with probability 12\frac 12, and outcome 11 with probability 12\frac 12. So we can’t distinguish the states directly using a computational basis measurement. But suppose instead we put the state into the following circuit:</p><p></p><p>Show that if the state ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} is input then the output is m=0m = 0 with probability 11, while if the state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2} is input then the output is m=1m = 1 with probability 11. Thus while these two states are indistinguishable if just measured in the computational basis, they can be distinguished with the help of a simple quantum circuit.</p></div><h2>General single-qubit gates</h2><p>So far we’ve learned about two quantum gates, the NOT and the Hadamard gate, and also about the measurement process that can be used to extract classical information from our quantum circuits. In this section, I return to quantum gates, and take a look at the most general single-qubit gate. To do that it helps to recall the matrix representations of the NOT and Hadamard gates:</p><p>X=[0110];    H=12[111−1]\begin{aligned} X = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right]; \,\,\,\, H = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] \end{aligned}</p><p>If the input to these gates is the quantum state ∣ψ⟩|\psi\rangle, then the output is X∣ψ⟩X|\psi\rangle and H∣ψ⟩H|\psi\rangle respectively.</p><p>A general single-qubit gate works similarly. In particular, a general single-qubit gate can be represented as a 2×22 \times 2 unitary matrix, UU. (If you’re rusty, I’ll remind you what it means for a matrix to be unitary in a moment, and you can just think of it as a matrix for now.) If the input to the gate is the state ∣ψ⟩|\psi\rangle then the output from the gate is U∣ψ⟩U|\psi\rangle. And so the NOT and Hadamard gates correspond to the special cases where U=XU = X and U=HU = H, respectively.</p><p>What does it mean for a matrix UU to be unitary? It’s easiest to answer this question algebraically, where it simply means that U†U=IU^\dagger U = I, that is, the adjoint of UU, denoted U†U^\dagger, times UU, is equal to the identity matrix. That adjoint is, recall, the complex transpose of UU:</p><p>U†:=(UT)∗.U^\dagger := (U^T)^*.</p><p>So for a 2×22 \times 2 matrix, the adjoint operation is just:</p><p>[abcd]†=[a∗c∗b∗d∗].\left[ \begin{array}{cc} a &amp; b \\ c &amp; d \end{array} \right]^\dagger = \left[ \begin{array}{cc} a^* &amp; c^* \\ b^* &amp; d^* \end{array} \right].</p><p>(Note that the †\dagger is also sometimes called the <em>dagger operation</em>, or <em>Hermitian conjugation</em>, or just the <em>conjugation</em> operation. We’ll use all three terms on occasion.)</p><p>There are a few basic questions you might ask: why are single-qubit gates described by unitary matrices? And how can we get an intuitive feel for what it means for a matrix to be unitary, anyway? While the equation U†U=IU^\dagger U = I is easy to check algebraically, we’d like some intuition for what that equation means.</p><p>Another natural question is whether the NOT gate and the Hadamard gate are unitary? Of course, we’ll see that they are – I wouldn’t have described them as quantum gates if not – but we should go to the trouble of checking.</p><p>Yet another good question is whether there are useful examples of single-qubit gates that aren’t the NOT or Hadamard gates? The equation U†U=IU^\dagger U = I is all very well, but it’d be nice to have more concrete examples than just an abstract equation.</p><p>We’ll answer all these questions over the next few sections.</p><p>Let’s start by checking the unitarity of the Hadamard gate. We start by computing the adjoint of HH:</p><p>H†=((12[111−1])T)∗.H^\dagger = \left( \left( \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right]\right)^T\right)^*.</p><p>Note that taking the transpose doesn’t change the matrix, since it is already symmetric. And taking the complex conjugate doesn’t change anything, since all the entries are real. So we have H†=HH^\dagger = H, and thus H†H=HHH^\dagger H = HH. But we saw earlier in the essay that HH=IHH = I. So HH is, indeed, unitary.</p><div><p><strong>Exercise:</strong> Show that XX is unitary.</p><p><strong>Exercise:</strong> Show that the identity matrix II is unitary.</p><p><strong>Exercise:</strong> Can you find an example of a 2×22 \times 2 matrix that is unitary, and is not II, XX, or HH?</p></div><p>For flavor, let’s give a few more examples of single-qubit quantum gates. Earlier in the essay, I mentioned that the NOT gate XX was introduced by the physicist Wolfgang Pauli in the early days of quantum mechanics. He introduced two other matrices, YY and ZZ, which are also useful quantum gates. The three gates, X,YX, Y, and ZZ are known collectively as the <em>Pauli matrices</em>. The YY and ZZ gates will be useful extra tools in our toolkit of quantum gates; in terms of the earlier analogy they expand the repertoire of moves we have available to us. They’re crucial, for example, in protocols such as quantum teleportation and quantum error correction.</p><p>The YY gate is similar to the XX gate, but instead of 11s on the off-diagonal, it has ii and −i-i, so it takes ∣0⟩|0\rangle to i∣1⟩i|1\rangle and ∣1⟩|1\rangle to −i∣0⟩-i|0\rangle:</p><p>Y:=[0−ii0].Y := \left[ \begin{array}{cc} 0 &amp; -i \\ i &amp; 0 \end{array} \right].</p><p>The ZZ gate leaves ∣0⟩|0\rangle unchanged, and takes ∣1⟩|1\rangle to −∣1⟩-|1\rangle:</p><p>Z:=[100−1].Z := \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; -1 \end{array} \right].</p><p><strong>Exercise:</strong> Show that the YY and ZZ matrices are unitary, and so legitimate quantum gates.</p><p>Another good example of a quantum gate is a rotation, the kind of matrix you’ve most likely been seeing since high school. It’s just the ordinary rotation of the 22-dimensional plane by an angle θ\theta:</p><p>[cos⁡(θ)−sin⁡(θ)sin⁡(θ)cos⁡(θ)].\left[ \begin{array}{cc} \cos(\theta) &amp; -\sin(\theta) \\ \sin(\theta) &amp; \cos(\theta) \end{array} \right].</p><p>You can easily check that this is a unitary matrix, and so it’s valid quantum gate. And sometimes it’s a very useful quantum gate!</p><p>That mostly wraps up our little library of single-qubit gates. In the next couple of sections we’ll build up some intuition about what unitarity means, but we won’t add any extra elements to our quantum computing model. In fact, at this point we know almost everything needed for quantum computation. There are just two extra elements needed: extending our description of single qubits to multiple qubits, and describing a simple two-qubit quantum gate. We’ll get to those things shortly – not surprisingly, they look much like what we’ve already seen.</p><p>I am, by the way, somewhat uncomfortable with some of the questions just asked. My personal experience is that spaced-repetition learning works well when learning facts I have a lot of context for, and care a lot about. It’s a rare person who finds the detailed entries in a unitary matrix fascinating! That’s not to say they aren’t – actually, they <em>are</em>, but you need a lot more context than I’ve provided to see why (for instance) that −i-i in the YY is just so darn interesting.</p><p>With that said, this essay is genuinely an experiment, and the questions above are included in that spirit. Maybe it will turn out that readers can use spaced-repetition to learn the entries of unitary matrices. And maybe they cannot. No matter which that’ll be a valuable thing to learn about the world, and to inform future experiments with spaced-repetition learning.</p><h2>What does it mean for a matrix to be unitary?</h2><p>Can we get an intuition for what it means for a matrix to be unitary? It turns out that unitary matrices <em>preserve the length of their inputs</em>. In other words, if we take any vector ∣ψ⟩|\psi\rangle and compute the length ∥U∣ψ⟩∥\| U|\psi\rangle \| it’s always equal to the length ∥∣ψ⟩∥\||\psi\rangle\| of the original vector. In this, they’re much like rotations or reflections in ordinary (real) space, which also don’t change lengths. In a sense, the unitary matrices are a complex generalization of real rotations and reflections.</p><p>Up to now we’ve been dealing mostly with vectors which are states of qubits, i.e., normalized 2-dimensional vectors. But in fact the statement of the last paragraph is true for d×dd \times d unitary matrices, too, i.e., ∥U∣ψ⟩∥=∥∣ψ⟩∥\|U|\psi\rangle\| = \||\psi\rangle\| is true for any vector ∣ψ⟩|\psi\rangle in dd dimensions.</p><p>The proof is actually pretty simple – mostly, we just compute ∥U∣ψ⟩∥\|U|\psi\rangle \| and use a little algebra to check that it’s equal to the length ∥∣ψ⟩∥\||\psi\rangle\|. But before we get to the proof, observe that this result is good news for quantum gates. The reason is that in a quantum gate the input state will be normalized (have length 11), since that’s a requirement for a quantum state. And we’d expect the corresponding output state to also be normalized, otherwise it wouldn’t be a legitimate quantum state. Fortunately, the length-preserving property of unitary matrices ensures the output state is properly normalized.</p><p>Recall also the larger story this is part of: not only are gates unitary, to ensure that states remain normalized; also, quantum states are normalized, since measurement probabilities must sum to 11. It all fits together.</p><p>In fact it turns out that unitary matrices are the <em>only</em> matrices which preserve length in this way. And so a good way of thinking about unitary matrices is that they’re exactly the class of matrices which preserve length. That’s the geometric interpretation (and intuitive meaning) of the algebraic condition U†U=IU^\dagger U = I.</p><p>Let’s prove now that unitary matrices really are length-preserving.</p><p>The proof is straightforward. The main thing is to compute ∥U∣ψ⟩∥\|U|\psi\rangle\|. Actually, it’s a little easier to compute the square of the length, ∥U∣ψ⟩∥2\|U|\psi\rangle\|^2. This is just the sum of the squares of the absolute values of the components of the vector U∣ψ⟩U|\psi\rangle:</p><p>∥U∣ψ⟩∥2=∑j(Uψ)j∗(Uψ)j\|U|\psi\rangle\|^2 = \sum_j (U\psi)_j^* (U\psi)_j</p><p>Note that I’ve used (Uψ)j(U\psi)_j to denote the jjth component of U∣ψ⟩U|\psi\rangle, dropping the full ket notation, and just using ψ\psi alone. To proceed, we’ll expand the equation above out, and look for opportunities to apply the unitarity of UU. In particular, the component (Uψ)j(U\psi)_j is given by ∑lUjlψl\sum_l U_{jl} \psi_l and similarly for the complex conjugate term. So we can rewrite the above equation as:</p><p>∥U∣ψ⟩∥2=∑jklUjk∗ψk∗Ujlψl\|U|\psi\rangle\|^2 = \sum_{jkl} U_{jk}^*\psi_k^* U_{jl}\psi_l</p><p>To make use of the unitarity of UU we’ll move the UU terms together, and rewrite in terms of U†U^\dagger. This gives</p><p>∥U∣ψ⟩∥2=∑jklUkj†Ujlψk∗ψl,\|U|\psi\rangle\|^2 = \sum_{jkl} U_{kj}^\dagger U_{jl} \psi_k^* \psi_l,</p><p>where we interchanged the jkjk indices on the first UU in order to rewrite it in terms of U†U^\dagger. The only place the jj index appears anywhere in this equation is in the Ukj†UjlU_{kj}^\dagger U_{jl} term. We can therefore perform the sum over jj and those terms become (U†U)kl(U^\dagger U)_{kl}, which is just the klklth term in the identity matrix, since U†U=IU^\dagger U = I. So the above equation becomes:</p><p>∥U∣ψ⟩∥2=∑klδklψk∗ψl.\|U|\psi\rangle\|^2 = \sum_{kl} \delta_{kl} \psi_k^* \psi_l.</p><p>When we sum, the only time δkl\delta_{kl} is not equal to zero is when k=lk=l, in which case it’s 11. And so we can get rid of one of the summation indices, and the equation simplifies to:</p><p>∥U∣ψ⟩∥2=∑kψk∗ψk.\|U|\psi\rangle\|^2 = \sum_{k} \psi_k^* \psi_k.</p><p>The right-hand side is, of course, equal to the norm of ∣ψ⟩|\psi\rangle squared. And so we’ve shown ∥U∣ψ⟩∥2=∥∣ψ⟩∥2\|U|\psi\rangle\|^2 = \||\psi\rangle\|^2, and therefore ∥U∣ψ⟩∥=∥∣ψ⟩∥\|U|\psi\rangle\| = \||\psi\rangle\|. That completes the proof that unitary matrices are length-preserving. <strong>QED</strong></p><p>In fact, as I mentioned earlier, it’s also possible to prove that unitary matrices are the only matrices which preserve lengths in this way. Let me state that a little more precisely:</p><p><strong>Theorem:</strong> Let MM be a matrix. Then ∥M∣ψ⟩∥=∥∣ψ⟩∥\|M|\psi\rangle \| = \||\psi\rangle\| for all vectors ∣ψ⟩|\psi\rangle if and only if MM is unitary.</p><p>We’ve proved one half of this already; we’ll prove the other half in the next section. This theorem answers many of our questions from earlier: we see why quantum gates must be unitary, since they’re the only matrices which preserve normalization. Of course, it doesn’t completely answer the question, since it doesn’t tell us why quantum gates should be matrices (i.e., linear operations) in the first place. That fact we’re simply going to accept. In fact, it is possible to develop deeper levels of understanding of why that is true, but in this essay we’ll be satisfied with the partial explanation that unitary matrices are length-preserving.</p><h2>Why are unitaries the only matrices which preserve length?</h2><p>Alright, let’s prove the missing part from the last section: let’s show that unitaries are the only matrices which preserve length.</p><p>The proof is a little messy. But it turns out to be a good way to get familiar with a few extra pieces of standard quantum mechanical terminology and notation. I’ll be frank: while these pieces of terminology are extremely useful in quantum computing, we don’t strictly need them elsewhere in this essay (though we will in later essays). If you want to skip the section, or skim it, that’s okay – this is the best section of the essay to skip. But at some point you should come back and work through the material. And there is, in any case, a certain beauty to the proof.</p><p>We’ve been dealing with 2-dimensional vectors up to now, but what I’m about to say applies no matter how many dimensions we’re working in. So suppose we have a vector ∣ψ⟩|\psi\rangle which can be written in component form as:</p><p>∣ψ⟩=[ab⋮z].|\psi\rangle = \left[ \begin{array}{c} a \\ b \\ \vdots \\ z \end{array} \right].</p><p>We’re going to define a new object, also labeled with a ψ\psi, but now with a bracket in the other direction:</p><p>⟨ψ∣:=[a∗b∗…z∗].\langle \psi| := [a^* b^* \dots z^*].</p><p>That is, ⟨ψ∣\langle\psi| is a row vector, whose entries are the same as ∣ψ⟩|\psi\rangle, but complex conjugated. The vector ∣ψ⟩|\psi\rangle was called a ket, and (you’re going to groan) ⟨ψ∣\langle \psi| is called a <em>bra</em>, making this the <em>bra-ket</em>, or <em>bracket</em> notation. Yes, theoretical physicists make dad jokes, too. These names were given by the theoretical physicist Paul Dirac in 1939, and it’s often called the Dirac bra-ket notation, or sometimes just the Dirac notation.</p><p>A key fact about the bra ⟨ψ∣\langle \psi| is that it’s related to the ket ∣ψ⟩|\psi\rangle by the dagger operation:</p><p>∣ψ⟩†=⟨ψ∣.|\psi\rangle^\dagger = \langle \psi|.</p><p>It’s easy to see why this identity is true. Take the vector</p><p>∣ψ⟩=[ab⋮z],|\psi\rangle = \left[ \begin{array}{c} a \\ b \\ \vdots \\ z \end{array} \right],</p><p>and apply the dagger operation, which means taking the transpose, turning it into a row vector with entries a,b,…,za, b, \ldots, z, and then take the complex conjugate, giving us [a∗b∗…z∗][a^* b^* \ldots z^*], which is just the definition of ⟨ψ∣\langle \psi|.</p><p>In a similar way we see that ⟨ψ∣†=∣ψ⟩\langle \psi|^\dagger = |\psi\rangle.</p><p>Another useful identity expresses the length of ∣ψ⟩|\psi\rangle in terms of the Dirac notation:</p><p>∥∣ψ⟩∥2=⟨ψ∣∣ψ⟩.\||\psi\rangle\|^2 = \langle \psi| |\psi\rangle.</p><p>That is, the length squared is just equal to the product of the row vector ⟨ψ∣\langle \psi| with the column vector ∣ψ⟩|\psi\rangle. To prove it just notice that the right-hand side is</p><p>[a∗b∗…][ab⋮]=∣a∣2+∣b∣2+…[a^* b^* \ldots ] \left[ \begin{array}{c} a \\ b \\ \vdots \end{array} \right] = |a|^2 + |b|^2 + \ldots</p><p>And that, of course, is ∥∣ψ⟩∥2\||\psi\rangle\|^2, just as we wanted.</p><p>Physicists using the Dirac notation don’t usually write ⟨ψ∣∣ψ⟩\langle \psi| |\psi\rangle. They simplify it slightly, omitting one of the vertical bars ∣| in the middle, and just write it as:</p><p>⟨ψ∣ψ⟩.\langle \psi| \psi \rangle.</p><p>It’s only a slight simplification, but this omission of the extra bar turns out to make life considerably easier, and is well worth it. I’ve shown it above just for the special case of ⟨ψ∣ψ⟩\langle \psi| \psi \rangle but the same omission of a vertical bar is done often in other contexts. In practice, it rarely causes confusion, although of course you do need to get used to it.</p><p>Another useful identity is that if MM is a matrix and ∣ψ⟩|\psi\rangle is a ket, then</p><p>(M∣ψ⟩)†=⟨ψ∣M†.(M|\psi\rangle)^\dagger = \langle \psi|M^\dagger.</p><p>If you think of ⟨ψ∣\langle \psi| as the dagger of ∣ψ⟩|\psi\rangle, then what this equation means is that taking the dagger of the product M∣ψ⟩M|\psi\rangle is the same as taking the product of the dagger of MM with the dagger ∣ψ⟩|\psi\rangle, but reversing the order. This is a useful little mnemonic for remembering the above identity.</p><p>The identity is easy to prove. As a challenge to yourself you might want to stop right now and take a shot at proving it. Here’s the details if you get stuck.</p><p><strong>Proof:</strong> The way to prove the identity is to apply the definitions. We’re going to look at the jjth component of the left-hand side, (M∣ψ⟩)j†(M|\psi\rangle)^\dagger_j, and we’ll show it’s equal to the jjth component of the right-hand side. By definition, the jjth row component (M∣ψ⟩)j†(M|\psi\rangle)^\dagger_j is equal to the complex conjugate of the jjth column component of M∣ψ⟩M|\psi\rangle, i.e., (M∣ψ⟩)j∗(M|\psi\rangle)^*_j. That column component is ∑kMjk∗ψk∗\sum_k M_{jk}^* \psi_k^*. We can move the ψ\psi terms to the left, and swap the indices on the MM term to convert the ∗* to a dagger, giving ∑kψk∗Mkj†\sum_k \psi_k^* M_{kj}^\dagger. That’s just the jjth component of the row vector ⟨ψ∣M†\langle \psi|M^\dagger, as we set out to show. <strong>QED</strong></p><div><p>With all these ideas in mind, here’s an exercise for you to work through, putting several of these ideas together:</p><p><strong>Exercise:</strong> Show that for any matrix MM and vector ∣ψ⟩|\psi\rangle, the following identity holds, expressing the length of M∣ψ⟩M|\psi\rangle:</p><p>∥M∣ψ⟩∥2=⟨ψ∣M†M∣ψ⟩.\|M|\psi\rangle\|^2 = \langle\psi|M^\dagger M |\psi\rangle.</p></div><p>You may be wondering why we care about all these identities? Of course, really I’m just frontloading them – they’re all identities we’re going to find useful in a moment in the proof. So in some sense they are a bit <em>ad hoc</em> in motivation. But an underlying theme is that they’re about relating lengths to matrix operations. And it’s not so surprising that’s of interest – we’re going to assume we have a length-preserving operation. It’s very convenient to be able to relate that property to familiar operations about matrix multiplication. That’s the essential source of the interest in the above identities.</p><p>Alright, we’ve been working through some heavy, detailed material. We’ve got just a little more background to get through, but it’s easier going. I’m going to introduce a unit vector, denoted ∣ej⟩|e_j\rangle, meaning the vector with a 11 in the jjth component, and 00s everywhere else. So, for instance, for a qubit:</p><p>∣e0⟩=[10]∣e1⟩=[01]\begin{aligned} |e_0\rangle &amp; = \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \\ |e_1\rangle &amp; = \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] \end{aligned}</p><p>From elementary linear algebra, if MM is a matrix, then M∣ek⟩M|e_k\rangle is just the kkth column of MM. (If you don’t recall that from elementary linear algebra, I encourage you to stop and figure out why it’s true.) And from that you can deduce easily that ⟨ej∣M∣ek⟩\langle e_j|M|e_k\rangle is the jkjkth entry of MM.</p><p><strong>Exercise:</strong> If you’re not familiar with the proof, show that M∣ek⟩M|e_k\rangle is the kkth column of the matrix MM, and that ⟨ej∣M∣ek⟩\langle e_j|M|e_k\rangle is the jkjkth entry of MM.</p><p>Alright, that’s more than enough notational background! Let’s get to the main event. In particular, let’s recall the statement of the theorem we want to complete the proof of. Also recall that we proved the reverse implication in the last section, so we just need to prove the forward implication:</p><p><strong>Theorem:</strong> Let MM be a matrix. Then ∥M∣ψ⟩∥=∥∣ψ⟩∥\|M|\psi\rangle \| = \| |\psi\rangle\| for all vectors ∣ψ⟩|\psi\rangle if and only if MM is unitary.</p><p><strong>Proof:</strong> We’ll assume MM is length-preserving, and analyze the matrix M†MM^\dagger M. Our goal is to show that this is the identity matrix, and thus MM is unitary. To do this, we’re going to start by analyzing the diagonal elements (M†M)jj(M^\dagger M)_{jj}, and show that they’re all equal to 11. Then we’ll turn our attention to the off-diagonal elements and show that they’re all equal to 00.</p><p>To understand the diagonal elements, we know from earlier that: (M†M)jj=⟨ej∣M†M∣ej⟩=∥M∣ej⟩∥2(M^\dagger M)_{jj} = \langle e_j|M^\dagger M|e_j\rangle = \|M|e_j\rangle\|^2. But since MM is length-preserving, the latter is just ∥∣ej⟩∥2\||e_j\rangle\|^2, which is 11. And so we conclude that all the diagonal elements are, indeed, 11.</p><p>What about the off-diagonal elements, i.e., (M†M)jk(M^\dagger M)_{jk} where j≠kj \neq k? Can we show that these are all equal to 00? Well, what we’d like to do is somehow to relate (M†M)jk(M^\dagger M)_{jk} to the length of some vector M∣ψ⟩M|\psi\rangle, and then use the length-preserving property. One idea is to try using ∣ψ⟩=∣ej⟩+∣ek⟩|\psi\rangle = |e_j\rangle + |e_k\rangle, since that involves both the jjth and kkth directions. From the length-preserving property we have:</p><p>∥M∣ψ⟩∥2=∥∣ψ⟩∥2=12+12=2.\|M|\psi\rangle\|^2 = \| |\psi\rangle\|^2 = 1^2+1^2 = 2.</p><p>We also have:</p><p>∥M∣ψ⟩∥2=⟨ψ∣M†M∣ψ⟩=⟨ej∣M†M∣ej⟩+⟨ej∣M†M∣ek⟩==+⟨ek∣M†M∣ej⟩+⟨ek∣M†M∣ek⟩=1+⟨ej∣M†M∣ek⟩+⟨ek∣M†M∣ej⟩+1\begin{aligned} \|M|\psi\rangle\|^2 &amp; = \langle \psi| M^\dagger M |\psi\rangle \\ &amp; = \langle e_j|M^\dagger M|e_j\rangle + \langle e_j|M^\dagger M|e_k\rangle \\ &amp; \hphantom{ == } + \langle e_k|M^\dagger M|e_j\rangle + \langle e_k|M^\dagger M |e_k\rangle \\ &amp; = 1 + \langle e_j|M^\dagger M|e_k\rangle + \langle e_k|M^\dagger M|e_j\rangle + 1 \end{aligned}</p><p>Comparing the last two sets of equations, we have:</p><p>⟨ej∣M†M∣ek⟩+⟨ek∣M†M∣ej⟩=0.\langle e_j|M^\dagger M|e_k\rangle + \langle e_k|M^\dagger M|e_j\rangle = 0.</p><p>This is close to what we want, but isn’t quite right. It tells us that (M†M)jk+(M†M)kj=0(M^\dagger M)_{jk} + (M^\dagger M)_{kj} = 0. Can we do better? It’s tempting to go back and fiddle around and try to find some way of eliminating one or the other of those terms. But there’s no direct way to do it – at least, no direct way that I know of.</p><p>But what if we’d done something slightly different, and instead of using ∣ψ⟩=∣ej⟩+∣ek⟩|\psi\rangle = |e_j\rangle+|e_k\rangle we’d used ∣ψ⟩=∣ej⟩+i∣ek⟩|\psi\rangle = |e_j\rangle+i|e_k\rangle? It seems pretty plausible that following the same line of reasoning we’d get an equation involving (M†M)jk(M^\dagger M)_{jk} and (M†M)kj(M^\dagger M)_{kj} again. I won’t explicitly go through the steps – you can do that yourself – but if you do go through them you end up with the equation:</p><p>(M†M)jk−(M†M)kj=0.(M^\dagger M)_{jk} - (M^\dagger M)_{kj} = 0.</p><p>This is great! We can add it to the earlier equation to deduce that (M†M)jk=0(M^\dagger M)_{jk} = 0 whenever j≠kj \neq k, and so we conclude that M†M=IM^\dagger M = I, i.e., MM is unitary. <strong>QED</strong></p><h2>The controlled-NOT gate</h2><p>We’ve developed most of the ideas needed to do universal quantum computing. We understand qubits, quantum states, and have a repertoire of quantum gates. However, all our gates involve just a single qubit. To compute, we need some way for qubits to interact with one another. That is, we need quantum gates which involve two (or more) qubits.</p><p>An example of such a gate is the controlled-NOT (or CNOT) gate. In the quantum circuit language we have two wires, representing two qubits, and the following notation to represent the CNOT gate:</p><p></p><p>The wire with the small, filled dot on it (the top wire, in this example) is called the <em>control</em> qubit, for reasons which will become clear in a moment. And the wire with the larger, unfilled circle on it is called the <em>target</em> qubit.</p><p>Up to now I haven’t said what the possible states of a two-qubit system are, but you can probably guess. We now have four computational basis states, corresponding to the four possible states of a two-bit system: ∣00⟩,∣01⟩,∣10⟩|00\rangle, |01\rangle, |10\rangle, and ∣11⟩|11\rangle. And, for a two-qubit system, not only can we have those four states, we can also have superpositions (i.e., linear combinations) of them:</p><p>α∣00⟩+β∣01⟩+γ∣10⟩+δ∣11⟩\alpha|00\rangle+\beta|01\rangle+\gamma |10\rangle+\delta|11\rangle</p><p>Here, the amplitudes α,β,γ,δ\alpha, \beta, \gamma, \delta are just complex numbers, and the sum of the squares of the absolute values is 11, i.e, ∣α∣2+∣β∣2+∣γ∣2+∣δ∣2=1|\alpha|^2+|\beta|^2+|\gamma|^2+|\delta|^2 = 1. This is the same kind of normalization condition as we had for a single qubit.</p><p>Now, the CNOT gate is, much like the quantum NOT gate, inspired directly by a classical gate. What it does is very simple. If the control qubit is set to 11, as in the states ∣10⟩|10\rangle and ∣11⟩|11\rangle, then it flips (i.e., NOTs) the target qubit. And otherwise it does nothing. Writing out the action on all four computational basis states we have:</p><p>∣00⟩→∣00⟩∣01⟩→∣01⟩∣10⟩→∣11⟩∣11⟩→∣10⟩\begin{aligned} |00\rangle &amp; \rightarrow &amp; |00\rangle \\ |01\rangle &amp; \rightarrow &amp; |01\rangle \\ |10\rangle &amp; \rightarrow &amp; |11\rangle \\ |11\rangle &amp; \rightarrow &amp; |10\rangle \end{aligned}</p><p>If you’re familiar with classical programming languages, then you can think of the CNOT as a very simple kind of <code>if-then</code> statement: <code>if</code> the control qubit is set, <code>then</code> NOT the target qubit. But while simple, it can be used as a building block to build up other, more complex kinds of conditional behavior.</p><p>There’s a way of summing up all four of the equations above in a single equation. Suppose xx and yy are classical bits, i.e., 00 or 11. Then we can rewrite the equations above in a single equation as:</p><p>∣x,y⟩→∣x,y⊕x⟩.\begin{aligned} |x, y\rangle &amp; \rightarrow &amp; |x, y\oplus x\rangle. \end{aligned}</p><p>Note the commas inserted to make this easier to read – this is pretty common in working with multi-qubit states.</p><p>The above equation makes clear that the CNOT leaves the control qubit xx alone, but flips the target qubit yy if xx is set to 11. Note that ⊕\oplus is addition modulo 22, where 1⊕1=01 \oplus 1 = 0, as we would expect from the fact that the CNOT takes ∣11⟩|11\rangle to ∣10⟩|10\rangle.</p><p>That’s all there is to the CNOT. It’s really a very simple idea and quantum gate. Note that it of course acts linearly on superpositions of computational basis states, as we expect for a quantum gate. So:</p><p>→α∣00⟩+β∣01⟩+γ∣10⟩+δ∣11⟩→α∣00⟩+β∣01⟩+γ∣11⟩+δ∣10⟩\begin{aligned} &amp; \hphantom{ \rightarrow } \alpha|00\rangle+\beta|01\rangle+\gamma |10\rangle+\delta|11\rangle \\ &amp; \rightarrow \alpha|00\rangle+\beta|01\rangle+\gamma |11\rangle+\delta|10\rangle \end{aligned}</p><p>And, though I won’t explicitly carry out the verification, the CNOT is unitary, and thus preserves the length of quantum states, as we expect.</p><p>Of course, the CNOT doesn’t just appear in two-qubit computations. It also appears in computations involving more qubits. Let’s suppose we have three qubits, for instance, and computational basis states such as ∣000⟩,∣001⟩|000\rangle, |001\rangle, and so on. Here’s a CNOT with the second qubit as the control qubit and the third qubit as the target:</p><p></p><p>What goes on? Well, we can write out what happens on an arbitrary computational basis state, ∣x,y,z⟩|x, y, z\rangle, where x,yx, y and zz are all classical bits. Of course, the first bit xx isn’t changed at all, since it’s not involved in the CNOT. The second bit yy is the control bit, and so isn’t changed. But the third bit zz is flipped if the control bit yy is set to 11. And so we can write the action of the CNOT as:</p><p>∣x,y,z⟩→∣x,y,z⊕y⟩|x,y,z\rangle \rightarrow |x,y, z\oplus y\rangle</p><p>I’ve described the CNOT as a “classical” gate, but it can be combined with single-qubit gates to do non-classical things. Let me give you an explicit example. It’s another two-qubit computation. It starts with the ∣00⟩|00\rangle computational basis state, we apply a Hadamard gate to the first qubit, and then do a CNOT:</p><p></p><p>Recall that for a single qubit the Hadamard gate takes ∣0⟩|0\rangle to an equal superposition (∣0⟩+∣1⟩)/2(|0\rangle+|1\rangle)/\sqrt{2}. For these two qubits it doesn’t affect the second qubit at all, and so it takes ∣00⟩|00\rangle to (∣00⟩+∣10⟩)/2(|00\rangle+|10\rangle)/\sqrt{2}.</p><p>Next we apply the CNOT gate. This leaves the ∣00⟩|00\rangle state unchanged, since the control bit is 00. And it takes ∣10⟩|10\rangle to ∣11⟩|11\rangle, since the control bit is 11. And so the output from the circuit is:</p><p>∣00⟩+∣11⟩2.\frac{|00\rangle+|11\rangle}{\sqrt 2}.</p><p>This output state is a highly non-classical state – it’s actually a type of state called an <em>entangled state</em>. There’s no obvious interpretation of this state as a classical state, unlike say a computational basis state such as ∣00⟩|00\rangle. In fact, entangled states can be used to do all sorts of interesting information processing tasks, including quantum teleportation and fast quantum algorithms.</p><p>A point I glossed over above, but worth mentioning: in the circuit I drew ∣0⟩|0\rangle and ∣0⟩|0\rangle separately as input qubits. It’s conventional to do that kind of thing to denote a combined input of ∣00⟩|00\rangle. More generally, people use ∣0⟩∣0⟩|0\rangle|0\rangle interchangeably with ∣00⟩|00\rangle, ∣0⟩∣1⟩|0\rangle|1\rangle interchangeably with ∣01⟩|01\rangle, and so on. Going back and forth takes a bit of getting used to, but everything works pretty much as you expect, and you just need a little practice before it seems quite natural.</p><p>More generally, if we have single-qubit states α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle and γ∣0⟩+δ∣1⟩\gamma|0\rangle+\delta|1\rangle, then the combined state when the two qubits are put together is just:</p><p>=(α∣0⟩+β∣1⟩)(γ∣0⟩+δ∣1⟩)=αγ∣00⟩+αδ∣01⟩+βγ∣10⟩+βδ∣11⟩.\begin{aligned} &amp; \hphantom{ = } (\alpha|0\rangle+\beta|1\rangle)(\gamma|0\rangle+\delta|1\rangle) \\ &amp; = \alpha\gamma|00\rangle+\alpha\delta |01\rangle+ \beta\gamma |10\rangle+ \beta\delta |11\rangle. \end{aligned}</p><p>I said that the CNOT leaves the control qubit alone, and modifies the target qubit. That’s true in the computational basis. In fact, it’s actually possible for the target qubit to affect the control qubit. It’s worth taking a minute or two to at least understand (and, if you’re feeling energetic, attempting to solve) the following exercise:</p><p><strong>Exercise:</strong> Can you find single-qubit states ∣a⟩|a\rangle and ∣b⟩|b\rangle so that applying a CNOT to the combined state ∣ab⟩|ab\rangle changes the first qubit, i.e., the control qubit?</p><p>Let me give you an example which solves the above exercise. Suppose we introduce single-qubit states ∣+⟩|+\rangle and ∣−⟩|-\rangle, defined by:</p><p>∣+⟩:=∣0⟩+∣1⟩2∣−⟩:=∣0⟩−∣1⟩2\begin{aligned} |+\rangle &amp; := \frac{|0\rangle+|1\rangle}{\sqrt 2} \\ |-\rangle &amp; := \frac{|0\rangle-|1\rangle}{\sqrt 2} \end{aligned}</p><p>A mnemonic for this notation is that these are both equal superpositions of ∣0⟩|0\rangle and ∣1⟩|1\rangle, but the “+” or “-” corresponds to the sign of the amplitude for the ∣1⟩|1\rangle state. The following circuit identity holds:</p><p></p><p>That is, if we put ∣+−⟩|+-\rangle in, then ∣−−⟩|--\rangle comes out, i.e., the target qubit isn’t changed, but the control qubit is! The proof is just to follow the definitions and the algebra through. It’s honestly not terribly enlightening to follow the algebra through at this point – it’s a lot easier once certain other facts are known to you. But, again, if you’re feeling enthusiastic it’s a good exercise to work through to become familiar with how things work.</p><p>It’s worth taking some caution from this example. It means that intuitions coming from the computational basis can sometimes be incomplete or misleading. The CNOT isn’t simply doing something to the target, conditional on the control. It’s also doing something to the control, conditional on the target.</p><div><p><strong>Exercise:</strong> Show that the inverse of the CNOT gate is just the CNOT gate.</p></div><h2>Part III: Universal quantum computing</h2><blockquote>In natural science, Nature has given us a world and we’re just to discover its laws. In computers, we can stuff laws into it and create a world.<p>— Alan Kay</p></blockquote><p>Let’s return to the question we began with: is there a single computing device that can efficiently simulate <em>any</em> other physical system? At the moment, the best candidate humanity has for such a computing device is a quantum computer. As you’ve probably guessed, you make such a device by combining all the elements we’ve been discussing. In Part III of this essay we’ll discuss what a quantum computer is, why they’re useful, and whether they can be used to efficiently simulate any other physical system.</p><h2>The quantum computing model</h2><blockquote>The theory of computation has traditionally been studied almost entirely in the abstract, as a topic in pure mathematics. This is to miss the point of it. Computers are physical objects, and computations are physical processes. What computers can or cannot compute is determined by the laws of physics alone, and not by pure mathematics.<p>— David Deutsch</p></blockquote><p>In a general quantum computation, you start out with many qubits – I’ll draw four here, but in general it might be many more (or less). You apply quantum gates of various kinds, in particular, single-qubit gates and CNOT gates. And at the end of the circuit you read out the result by measuring in the computational basis. Here’s what it all looks like:</p><p></p><p>I haven’t labeled the single-qubit gates explicitly, but they might be various things – Hadamard gates, NOT gates, rotations, and perhaps others. Note also that while the computation starts in the computational basis state ∣0000⟩|0000\rangle, you can also start in some other computational basis state. I’ve just chosen ∣0000⟩|0000\rangle for definiteness.</p><p>We can summarize the three steps in a quantum computation as follows:</p><ol><li>Start in a computational basis state.</li><li>Apply a sequence of CNOT and single-qubit gates.</li><li>To obtain the result, measure in the computational basis. The probability of any result, say 00…000\ldots 0, is just the square of the absolute value of the corresponding amplitude.</li></ol><p>That’s all a general quantum computation is! If you understand this model, you know what a quantum computer is. It's pretty simple, really – enough so that I've sometimes heard people say “Is that all there is to it?” But while the model is simple, it contains remarkable depths, and exploring it could occupy many lifetimes.</p><p>In practice, people sometimes introduce other ideas into the way they describe quantum computations. If you’re a programmer, you can think of this as like the way programming language designers introduce higher-level abstractions to help people design different kinds of programs. In principle, those abstractions can always be reduced down to the level of AND and NOT gates. And if you understand that level – AND and NOT, or the type of quantum circuit shown above – then you have a foundation for building an understanding of the other ideas.</p><p>That may leave you wondering: does that mean you <em>also</em> need to master all the higher-level abstractions? The answer is no!</p><p>There are several reasons for this. One reason is that, as we discussed earlier, humanity doesn’t yet know what the higher-level abstractions are. We’re still trying to figure them out. A second reason is that it seems likely that the list of higher-level abstractions is inexhaustible. My guess – and it’s just a guess – is that we will continue to discover beautiful new abstractions <em>forever</em>, in both classical and quantum computing.</p><p>A related idea is that there are models of quantum computation different to the quantum circuit model. Some are merely small variations on the model I’ve described. For instance, instead of only using CNOT gates, we might allow any two-qubit unitary gate to be used in the circuit. Or perhaps instead of using qubits, we might use some other type of basic quantum system – say, the <em>qutrit</em>, which has three computational basis states, ∣0⟩,∣1⟩|0\rangle, |1\rangle, and ∣2⟩|2\rangle. It probably won’t surprise you that the resulting models of computation are essentially equivalent to the quantum circuit model I’ve described. By this, I mean they can simulate the quantum circuit model (and vice versa) using roughly comparable numbers of gates and other physical resources.</p><p>There are also much more exotic variations, ideas such as measurement-based quantum computation, topological quantum computation, and others. I won’t describe these in any detail here, but suffice to say that they appear superficially very different to the circuit model. Nonetheless, they’re all mathematically equivalent to one another, including to the quantum circuit model. Thus a quantum computation in any of those models can be translated into an equivalent in the quantum circuit model, with only a small overhead in the cost of computation. And vice versa.</p><p>You may wonder why people bother thinking about other models, if they’re mathematically equivalent to the quantum circuit model. The reason is that just because two models are mathematically equivalent doesn’t mean they’re psychologically equivalent. Different models of computation stimulate different ways of thinking, and give rise to different ideas. And so it’s valuable to have other equivalent models.</p><div><p><strong>Exercise:</strong> We saw earlier that composition of quantum gates corresponds to matrix multiplication (in reverse order). Show that the product of two unitary matrices UU and VV is also unitary. As a consequence, the net effect of any quantum circuit (before measurement) is to effect a unitary operation on the state space of the system.</p></div><p>Let me conclude this section with a brief comment about a particular class of quantum gates. These are gates which are multiples of the identity matrix, II:</p><p>[eiθ00eiθ]=eiθ[1001]=eiθI.\begin{aligned} \left[ \begin{array}{cc} e^{i\theta} &amp; 0 \\ 0 &amp; e^{i\theta} \end{array} \right] = e^{i\theta} \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; 1 \end{array} \right] = e^{i \theta} I. \end{aligned}</p><p>When θ\theta is a real number this is a unitary matrix, and so a valid quantum gate. The effect of the gate is simply to multiply the state of the quantum computer by eiθe^{i\theta}. The number eiθe^{i\theta} is called a <em>global phase factor</em>. But even though the gate is valid, we rarely explicitly put such gates into quantum circuits. The reason is that such global phase factors have no impact on the results of the computation. To see why, imagine a quantum circuit which includes many such quantum gates, possibly for different values, θ1,θ2,…\theta_1, \theta_2, \ldots. No matter where in the circuit the gates occur, the net effect is to multiply the state output from the circuit by an overall factor of eiθ1+iθ2+…e^{i \theta_1 + i\theta_2 + \ldots}. This doesn’t change the squared amplitudes of the computational basis states, and so has no impact on the measurement probabilities at the end of the computation. We could have left the gates out and it would make no difference.</p><p>Quantum computing people tend to be rather blase about such global phase factors. They’ll do things like not bother to distinguish between unitary gates such as XX and −X-X, saying these gates are “the same up to a global phase factor”. They simply mean the −X-X gate is the same as doing the XX gate, followed by the −I-I gate. Since the latter gate makes no difference to the output from the computation, it can safely be omitted. We’ll see examples in the next essay, about the quantum search algorithm, where at a couple of places it makes sense to multiply the quantum state by a global phase factor of −1-1.</p><h2>What are quantum computers good for?</h2><p>Now we know what a quantum computer is, what are they good for? Earlier, I suggested quantum computers expand the range of operations available when computing. This is similar to the way boats expand the range of ways we can traverse space, so instead of having to get from point A to point B by land,</p><p></p><p>we can take a shortcut greatly cutting down the time required:</p><p></p><p>In order for the analogous story to hold for quantum computers, they need to be at least as capable as classical computers. Fortunately, it’s possible to convert any classical circuit into a quantum circuit. This requires some care. The obvious thing to do is to imagine that your classical circuit is expressed in terms of some standard universal set – say, the AND and NOT gates – and then to convert those gates into equivalent quantum gates.</p><p>This is easy to do with the NOT gate – we just turn it into an XX gate. But what’s not so easy is the AND gate. You might wonder if there’s some quantum gate which takes two bits xx and yy as input, in the computational basis, ∣x,y⟩|x,y\rangle, and then outputs a single qubit ∣x∧y⟩|x \wedge y\rangle, where x∧yx \wedge y is just the logical AND of the bits xx and yy.</p><p>Unfortunately, that “quantum gate” makes no sense at all! Not only is it not unitary, it’s not even close: a unitary gate with two qubits as input necessarily has two qubits as output. The “gate” I described has just a single qubit as output, so there’s no way it can be unitary.</p><p>You might wonder if instead there’s some way we can find a two-qubit quantum gate which has x∧yx \wedge y as one output, and something else as the other output. I won’t prove it, but it turns out that this is impossible. The proof actually isn’t all that hard – it’s a fun exercise to think through, if you want a challenge – but is more of a digression than I want to get into here.</p><p>That’s all rather disappointing. But there is a solution. It’s to use a three-qubit quantum gate called the <em>Toffoli gate</em>. The Toffoli gate is much like the CNOT gate, but instead of having a single control qubit, it has two control qubits, xx and yy, and a single target qubit, zz. If both controls qubits are set, then the target is flipped. Otherwise, the target is left alone:</p><p></p><p>If the target starts out as z=0z = 0, then you can see that the target output is just x∧yx \wedge y, and so the Toffoli gate can be used to simulate a classical AND gate. So if we have any classical circuit of AND and NOT gates then there’s a corresponding quantum circuit involving the same number of XX and Toffoli gates which computes the same function.</p><div><p><strong>Exercise:</strong> What’s a quantum circuit that can compute the NAND gate? Recall that the NAND of two bits xx and yy is just the NOT of x∧yx \wedge y.</p><p><strong>Exercise:</strong> Can you find a way of implementing a NAND gate using just a single Toffoli gate and no other quantum gates? Note that your answer here may be the same as your answer to the previous exercise, if you answered that exercise using just a single Toffoli gate and no other quantum gates.</p></div><p>A wrinkle in all this is that the Toffoli gate isn’t in our standard set of basic quantum gates. However, it’s possible to build the Toffoli gate up out of CNOT and single-qubit unitary gates. One way of doing the breakdown is shown below:</p><p></p><p>There are various slick ways of “explaining” why this circuit works, but I’ll let you in on a secret: much of the earliest work on this was done by pure brute force, people simply trying lots and lots of different ways of implementing the Toffoli gate (sometimes, using a computer to assist in doing the search). Frankly, I wouldn’t worry too much about why this circuit works, just take it for granted that it does. You can look it up if you ever need to, or dig down into why. Needing to know the circuit details actually isn’t all that common, so I wouldn’t suggest memorizing it – not until you have a good reason.</p><div><p><strong>Exercise:</strong> Show that the inverse of the Toffoli gate is just the Toffoli gate.</p></div><h2>No, really, what are quantum computers good for?</h2><p>It’s comforting that we can always simulate a classical circuit – it means quantum computers aren’t slower than classical computers – but doesn’t answer the question of the last section: what problems are quantum computers good for? Can we find shortcuts that make them systematically faster than classical computers? It turns out there’s no general way known to do that. But there are some interesting classes of computation where quantum computers outperform classical.</p><p>Over the long term, I believe the most important use of quantum computers will be simulating other quantum systems. That may sound esoteric – why would anyone apart from a quantum physicist care about simulating quantum systems? But <em>everybody</em> in the future will (or, at least, will care about the consequences). The world is made up of quantum systems. Pharmaceutical companies employ thousands of chemists who synthesize molecules and characterize their properties. This is currently a very slow and painstaking process. In an ideal world they’d get the same information thousands or millions of times faster, by doing highly accurate computer simulations. And they’d get much more useful information, answering questions chemists can’t possibly hope to answer today. Unfortunately, classical computers are terrible at simulating quantum systems.</p><p>The reason classical computers are bad at simulating quantum systems isn’t difficult to understand. Suppose we have a molecule containing nn atoms – for a small molecule, nn may be 11-1010, for a complex molecule it may be hundreds or thousands or even more. And suppose we think of each atom as a qubit (not true, but go with it): to describe the system we’d need 2n2^n different amplitudes, one amplitude for each nn-bit computational basis state, e.g., ∣010011…⟩|010011\ldots\rangle.</p><p>Of course, atoms aren’t qubits. They’re more complicated, and we need more amplitudes to describe them. Without getting into details, the rough scaling for an nn-atom molecule is that we need knk^n amplitudes, where k≥2k \geq 2. The value of kk depends upon context – which aspects of the atom’s behavior are important. For generic quantum simulations kk may be in the hundreds or more.</p><p>That’s a <em>lot</em> of amplitudes! Even for comparatively simple atoms and small values of nn, it means the number of amplitudes will be in the trillions. And it rises very rapidly, doubling or more for each extra atom. If k=100k=100, then even n=10n = 10 atoms will require 100 million trillion amplitudes. That’s a lot of amplitudes for a pretty simple molecule.</p><p>The result is that simulating such systems is incredibly hard. Just storing the amplitudes requires mindboggling amounts of computer memory. Simulating how they change in time is even more challenging, involving immensely complicated updates to all the amplitudes.</p><p>Physicists and chemists have found some clever tricks for simplifying the situation. But even with those tricks simulating quantum systems on classical computers seems to be impractical, except for tiny molecules, or in special situations. The reason most educated people today don’t know simulating quantum systems is important is because classical computers are so bad at it that it’s never been practical to do. We’ve been living too early in history to understand how incredibly important quantum simulation really is.</p><p>That’s going to change over the coming century. Many of these problems will become vastly easier when we have scalable quantum computers, since quantum computers turn out to be fantastically well suited to simulating quantum systems. Instead of each extra simulated atom requiring a doubling (or more) in classical computer memory, a quantum computer will need just a small (and constant) number of extra qubits. One way of thinking of this is as a loose quantum corollary to Moore’s law:</p><blockquote><strong>The quantum corollary to Moore’s law:</strong> Assuming both quantum and classical computers double in capacity every few years, the size of the quantum system we can simulate scales linearly with time on the best available classical computers, and exponentially with time on the best available quantum computers.</blockquote><p>In the long run, quantum computers will win, and win easily.</p><p>The punchline is that it’s reasonable to suspect that if we could simulate quantum systems easily, we could greatly speed up drug discovery, and the discovery of other new types of materials.</p><p>I will risk the ire of my (understandably) hype-averse colleagues and say bluntly what I believe the likely impact of quantum simulation will be: there’s at least a 50 percent chance quantum simulation will result in one or more multi-trillion dollar industries. And there’s at least a 30 percent chance it will completely change human civilization. The catch: I don’t mean in 5 years, or 10 years, or even 20 years. I’m talking more over 100 years. And I could be wrong.</p><p>What makes me suspect this may be so important?</p><p>For most of history we humans understood almost nothing about what matter is. That’s changed over the past century or so, as we’ve built an amazingly detailed understanding of matter. But while that understanding has grown, our ability to control matter has lagged. Essentially, we’ve relied on what nature accidentally provided for us. We’ve gotten somewhat better at doing things like synthesizing new chemical elements and new molecules, but our control is still very primitive.</p><p>We’re now in the early days of a transition where we go from having almost no control of matter to having almost complete control of matter. Matter will become programmable; it will be designable. This will be as big a transition in our understanding of matter as the move from mechanical computing devices to modern computers was for computing. What qualitatively new forms of matter will we create? I don’t know, but the ability to use quantum computers to simulate quantum systems will be an essential part of this burgeoning design science.</p><p>Alright, enough speculation.</p><p>Let me also briefly mention the sober-minded conventional answer given to the question “what are quantum computers good for?” That answer is to list various algorithmic problems that we have some evidence can be solved faster on a quantum computer than on a classical computer.</p><p>The most famous example is Peter Shor’s beautiful quantum factoring algorithm. To find the prime factors of an nn-bit integer seems to be a very difficult problem on a classical computer. The best existing algorithms are incredibly computationally expensive, with a cost that rises exponentially with nn. Even numbers with just a few hundred digits aren’t currently feasible to factor on classical computers. By contrast, Shor’s quantum factoring algorithm would make factoring into a comparatively easy task, if large-scale quantum computers can be built.</p><p>Factoring perhaps doesn’t seem like a very interesting application. But it turns out that the ability to factor lets you break some of the most widely-used encryption schemes, used by services such as Gmail and Amazon to keep your communications private. This ability to break encryption has made the world’s intelligence agencies very interested in factoring, and they’ve poured enormous sums of money into quantum computing research since the mid-1990s. Indeed, there’s a good (as yet unwritten) history book to be written about how the rise of quantum computing was caused by the interest of the world’s intelligence agencies in accessing humanity’s private thoughts.</p><p>There’s been surprisingly little public reflection about this on the part of the quantum computing community. I occasionally meet quantum computing researchers who complain in private about what they perceive as privacy violations by governments, and the dangers of surveillance states. But then some of those same people will take money to help those governments in their plans for surveillance, usually with some transparently self-serving justification about how they’re not <em>really</em> helping. One exception to this lack of public reflection is a brief discussion in Ronald de Wolf’s thoughtful essay <a href="https://arxiv.org/abs/1712.05380">The Potential Impact of Quantum Computers on Society</a> (2017).</p><h2>Are quantum computers really universal devices?</h2><blockquote>The eternal mystery of the world is its comprehensibility… The fact that it is comprehensible is a miracle.<p>— Albert Einstein</p></blockquote><p>At the beginning of this essay I asked whether there is any single universal computing device that can efficiently simulate any other physical system? We’ve learned that classical computers seem to have a lot of trouble efficiently simulating quantum systems.</p><p>What about quantum computers? While they can certainly simulate many quantum systems, does that mean they can be used to efficiently simulate <em>any</em> physical system?</p><p>This question is an open problem! We don’t yet know the answer.</p><p>Part of the trouble in answering the question is that humanity hasn’t yet discovered the final fundamental laws of physics. Modern physics is based on two astonishingly effective theories: Einstein’s general theory of relativity, which describes how gravitation works; and the standard model of particle physics, which explains how pretty much everything else (electromagnetism, the strong and weak nuclear forces) work.</p><p>Trouble is, we don’t yet have a good theory of quantum gravity which combines general relativity and the standard model. Without such a theory of quantum gravity we’re not able to answer the question of whether quantum computers can efficiently simulate any other physical system. Perhaps some future class of quantum gravitating computers, more powerful even than quantum computers, will be needed to simulate quantum gravity.</p><p>Let’s ask a slightly less ambitious question, which is whether we can use quantum computers to efficiently simulate general relativity and the standard model?</p><p>The standard model is an example of a particular type of quantum mechanical theory called a quantum field theory. John Preskill and his collaborators have written a series of papersFor a review of progress see: John Preskill, <a href="https://arxiv.org/abs/1811.10085">Simulating quantum field theory with a quantum computer</a> (2018). explaining how to use quantum computers to efficiently simulate quantum field theories. Those papers don’t yet simulate the full standard model, but they do make considerable progress. It remains an exciting open problem, albeit a problem where much encouraging progress has been made.</p><p>In the case of general relativity, as far as I know the problem remains open. Indeed, even stating what the problem means is not trivial. General relativity supports the existence of closed timelike curves, which can be used in some sense to send information back in time. This has interesting consequences for computation: there’s a way in which the computer can know the results of future computations. Unsurprisingly, this changes what is possible! Another complication is that when you talk about an “efficient simulation” in computation you mean the time and space overhead isn’t too large. But in general relativity even the basic units of space and time aren’t so clear. It’s hard to say what efficiency means. Finally, near singularities time and space get distorted in strange ways, again making it challenging to say exactly what it means to do an efficient computation.</p><p>There is, by the way, significant issue that I've been sweeping under the rug, and which may be bugging you: as I've explained it, a quantum computer isn't a <em>single</em> computing device at all, since there are many possible quantum circuits. This is okay, though, since there's a model known as the universal quantum Turing machine, which is a single computing device, and which can simulate any quantum circuit. So you should understand the discussion above as being implicitly about the universal quantum Turing machine. I won't explain the details of the universal quantum Turing machine in this essay, since in practice the quantum circuit model is far more commonly used. But if you're interested in the details, I recommend this <a href="https://epubs.siam.org/doi/abs/10.1137/S0097539796300921">paper by Bernstein and Vazirani</a>.</p><p>The existence of universal computers is easy to take for granted. But there’s no <em>a priori</em> logical reason there should be a single machine that can efficiently simulate every other physical system. It’s like being able to use your car also as a surfboard, a supermarket trolley, and a rainforestIn fact, there’s a sense in which this is possible, within limits: if you could rearrange protons, neutrons, and electrons arbitrarily well, you could turn a car into a surfboard, a supermarket trolley, or a (small) part of a rainforest. So matter does have intriguing universality properties. This is also remarkable, of course.. Yet the evidence so far suggests our universe does allow such universal machines. It’s a good problem – and, so far as I know, largely unexplored – to think about sets of laws of physics in which such a universal machine is not possible. That might sound pointless – why imagine other possible universes? Yet exploring such radical counterfactuals is often an excellent strategy for better understanding our own universe.</p><p>So there’s a very strange loop here. It’s that the laws of physics determine what kind of computations can be done. And yet the kind of computations which can be done seem to be powerful enough to describe the laws of physics. And that description can then be used to (efficiently!) simulate any physical system:</p><p></p><p>The top part of the loop is almost tautological. The bottom half of the loop is extraordinary. There’s no <em>a priori</em> reason the laws of physics should enable the existence of machines which can simulate physical systems. You might argue on anthropic grounds – we humans are here in the universe, and doing physics pretty successfully, so conditioned on that, it must be true. But that’s not a very satisfactory explanation of why. It remains a mystery. Einstein was right: the fact that the world is comprehensible at all is a miracle.</p><h2>Final Reflections</h2><p>We’ve worked through all the basics of the quantum computing model, but we haven’t yet used it in a full-on application – the sort of application which make people excited about quantum computing. But there will soon be available two considerably shorter(!) followup essays, explaining the quantum search algorithm and quantum teleportation. Someone who understands all three essays will have a good understanding of elementary quantum computing.</p><p>And what of the experimental mnemonic medium we’ve developed in this essay? Mastering new subjects requires internalizing the basic terminology and ideas of the subject. The mnemonic medium should radically speed up this memory step, converting it from a challenging obstruction into a routine step. Frankly, I believe it would accelerate human progress if all the deepest ideas of our civilization were available in a form like this. Perhaps some day.</p><p>With that said, memory is only part of what it means to understand. Is it possible to build powerful environments which enable deeper forms of understanding? That enable people to take action in new ways, to grow their sense of agency and of ability to contribute? This requires many things beyond memory: the ability to problem solve and to problem find; to connect with opportunities that genuinely matter, and to find pathways for meaningful contribution. We, the team at “Quantum Computing for the Very Curious”, believe there are many powerful and under-exploited patterns available to achieve these goals. In future projects we will explore and develop these patterns. Some of this exploration will continue to be done in the context of quantum computing. But we also hope to launch projects discussing some of humanity’s other great challenges, including optimistic, detailed visions of problems such as space travel, climate change, longevity, and the development of new forms of matter.</p><p>Thanks for reading this far. In a few days, you’ll receive a notification containing a link to your first review session. In that review session you’ll be retested on the material you’ve learned, helping you further commit it to memory. It should only take a few minutes. In subsequent days you’ll receive more notifications linking you to re-review, gradually working toward genuine long-term memory of all the core material in the essay.</p><p>Thanks for reading this far. If you’d like to remember the core ideas of this essay durably, please sign in below to set up an account. We’ll track your review schedule and send you occasional reminders containing links that will take you to the review experience.</p><div><div><p>Please sign in so we can save your progress and let you know the best times to review.</p></div><div><p>Thank you! Your progress will be saved as you read.</p></div></div></div>||||I|||| Quantum computing for the very curious

 Andy Matuschak and Michael Nielsen

 Part of a series of essays in a mnemonic medium which makes it almost effortless to remember what you read.

 * Quantum computing for the very curious
 * How the quantum search algorithm works
 * How quantum teleportation works
 * Quantum mechanics distilled

 by Andy Matuschak and Michael Nielsen

 Presented in a new mnemonic medium which makes it almost effortless to remember what you read.

 * Quantum computing for the very curious
 In-text
 5 days
 2 weeks
 1 month
 2 months
 Long-term
 + Part I: The state of a qubit
 + Part II: Introducing quantum logic gates
 + Part III: Universal quantum computing
 * How the quantum search algorithm works
 * How quantum teleportation works
 * Quantum mechanics distilled
 Support us on Patreon

 Our future projects are funded in part by readers like you.

 Special thanks to our sponsor-level patrons,
 Adam Wiggins, Andrew Sutherland, Bert Muthalaly, Calvin French-Owen, Dwight Crow, fnnch, James Hill-Khurana, Lambda AI Hardware, Ludwig Petersson, Mickey McManus, Mintter, Patrick Collison, Paul Sutter, Peter Hartree, Sana Labs, Shripriya Mahesh, Tim O'Reilly.

 If humanity ever makes contact with alien intelligences, will those aliens possess computers? In science fiction, alien computers are commonplace. If that's correct, it means there is some way aliens can discover computers independently of humans. After all, we’d be very surprised if aliens had independently invented Coca-Cola or Pokémon or the Harry Potter books. If aliens have computers, it’s because computers are the answer to a question that naturally occurs to both human and alien civilizations.

 Here on Earth, the principal originator of computers was the English mathematician Alan Turing. In his paper, published in 1936 Alan M. Turing, On Computable Numbers, with an Application to the Entscheidungsproblem (1936). , Turing wasn’t trying to invent a clever gadget or to create an industry. Rather, he was attacking a problem about the nature of mathematics posed by the German mathematician David Hilbert in 1928. That sounds abstruse, but it’s worth understanding the gist of Hilbert and Turing’s thinking, since it illuminates where computers come from, and what computers will become in the future.

 Through his career, Hilbert was interested in the ultimate limits of mathematical knowledge: what can humans know about mathematics, in principle, and what (if any) parts of mathematics are forever unknowable by humans? Roughly speaking, Hilbert’s 1928 problem asked whether there exists a general algorithm a mathematician can follow which would let them figure out whether any given mathematical statement is provable. Hilbert’s hoped-for algorithm would be a little like the paper-and-pencil algorithm for multiplying two numbers. Except instead of starting with two numbers, you’d start with a mathematical conjecture, and after going through the steps of the algorithm you’d know whether that conjecture was provable. The algorithm might be too time-consuming to use in practice, but if such an algorithm existed, then there would be a sense in which mathematics was knowable, at least in principle.

 In 1928, the notion of an algorithm was pretty vague. Up to that point, algorithms were often carried out by human beings using paper and pencil, as in the multiplication algorithm just mentioned, or the long-division algorithm. Attacking Hilbert’s problem forced Turing to make precise exactly what was meant by an algorithm. To do this, Turing described what we now call a Turing machine: a single, universal programmable computing device that Turing argued could perform any algorithm whatsoever.

 Today we’re used to the idea that computers can be programmed to do many different things. In Turing’s day, however, the idea of a universal programmable computer was remarkable. Turing was arguing that a single, fixed device could imitate any algorithmic process whatsoever, provided the right program was supplied. It was an amazing leap of imagination, and the foundation of modern computing.

 In order to argue that his machine could imitate any algorithmic process, Turing considered what operations a human mathematician could perform when carrying out an algorithm. For each such operation, he had to argue that his machine could always do the same thing. His argument is too long to reproduce in full here, but it’s fun and instructive to see the style of Turing’s reasoning:

 Computing is normally done by writing certain symbols on paper. We may suppose this paper is divided into squares like a child’s arithmetic book. In elementary arithmetic the two-dimensional character of the paper is sometimes used. But such a use is always avoidable, and I think that it will be agreed that the two-dimensional character of paper is no essential of computation. I assume then that the computation is carried out on one-dimensional paper, i.e. on a tape divided into squares. … The behavior of the computer [Turing is referring to the person performing an algorithm, not the machine!] at any moment is determined by the symbols which he is observing, and his “state of mind” at that moment. We may suppose that there is a bound BB B to the number of symbols or squares which the computer can observe at one moment. If he wishes to observe more, he must use successive observations. We will also suppose that the number of states of mind which need be taken into account is finite.

 Obviously, this was an informal and heuristic argument! Invoking a child’s arithmetic book, or someone’s mental state is not the stuff of a rigorous, bulletproof argument. But Turing’s argument was convincing enough that later mathematicians and scientists have for the most part been willing to accept it. Turing’s machine became the gold standard: an algorithm was what we could perform on a Turing machine. And since that time, computing has blossomed into an industry, and billions of computers based on Turing’s model have been sold.

 Still, there’s something discomforting about Turing’s analysis. Might he have missed something in his informal reasoning about what an algorithm is? In 1985, the English physicist David Deutsch suggested a deeper approach to the problem of defining what is meant by an algorithm David Deutsch, “Quantum theory, the Church-Turing principle and the universal quantum computer” (1985). . Deutsch pointed out that every algorithm is carried out by a physical system, whether it be a mathematician with paper-and-pencil, a mechanical system such as an abacus, or a modern computer. Deutsch then considered the following question (I've slightly rephrased to make it easier to read):

 Is there a (single) universal computing device which can efficiently simulate any other physical system?

 If there was such a device, you could use it to perform any algorithm whatsoever, because algorithms have to be performed on some kind of physical system. And so the device would be a truly universal computer. What’s more, Deutsch pointed out, you wouldn’t need to rely on informal, heuristic arguments to justify your notion of algorithm, as Turing had done. You could use the laws of physics to prove your device was universal.

 So let’s come back to our opening question: will aliens have computers? Deutsch’s question above is a simple, fundamental question about the nature of the universe. It’s the kind of question which alien counterparts to Deutsch could plausibly come to ponder. And the alien civilizations of which they are a part would then be led inexorably to invent computers.

 In this sense, computers aren’t just human inventions. They are a fundamental feature of the universe, the answer to a simple and profound question about how the universe works. And they have likely been discovered over and over again by many alien intelligences.

 There’s a wrinkle in this story. Deutsch is a physicist with a background in quantum mechanics. And in trying to answer his question, Deutsch observed that ordinary, everyday computers based on Turing’s model have a lot of trouble simulating quantum mechanical systems Researchers such as Yu Manin and Richard Feynman had previously observed this, and as a result had speculated about computers based on quantum mechanics. . In particular, they seem to be extraordinarily slow and inefficient at doing such simulations. To answer his question affirmatively, Deutsch was forced to invent a new type of computing system, a quantum computer. Those quantum computers can do everything conventional computers can do, but are also capable of efficiently simulating quantum-mechanical processes. And so they are arguably a more natural computing model than conventional computers. If we ever meet aliens, my bet is that they’ll use quantum computers (or, perhaps, will have quantum computing brains). After all, it’s likely that aliens will be far more technologically advanced than current human civilization. And so they’ll use the computers natural for any technologically advanced society.

 This essay explains how quantum computers work. It’s not a survey essay, or a popularization based on hand-wavy analogies. We’re going to dig down deep so you understand the details of quantum computing. Along the way, we’ll also learn the basic principles of quantum mechanics, since those are required to understand quantum computation.

 Learning this material is challenging. Quantum computing and quantum mechanics are famously “hard” subjects, often presented as mysterious and forbidding. If this were a conventional essay, chances are that you’d rapidly forget the material. But the essay is also an experiment in the essay form. As I’ll explain in detail below the essay incorporates new user interface ideas to help you remember what you read. That may sound surprising, but uses a well-validated idea from cognitive science known as spaced-repetition testing. More detail on how it works below. The upshot is that anyone who is curious and determined can understand quantum computing deeply and for the long term.

 That said, you need some mathematical background to understand the essay. I’ll assume you’re comfortable with complex numbers and with linear algebra – vectors, matrices, and so on. I’ll also assume you’re comfortable with the logic gates used in conventional computers – gates such as AND, OR, NOT, and so on.

 If you don’t have that mathematical background, you’ll need to acquire it. How you do that depends on your prior experience and learning preferences – there’s no one-size-fits-all approach, you’ll need to figure it out for yourself. But two resources you may find helpful are: (1) 3Blue1Brown’s series of YouTube videos on linear algebra; and (2) the more in-depth linear algebra lectures by Gil Strang. Try them out, and if you find them helpful, keep going. If not, explore other resources.

 It may seem tempting to try to avoid this mathematics. If you look around the web, there are many flashy introductions to quantum computing that avoid mathematics. There are, for instance, many rather slick videos on YouTube. They can be fun to watch, and the better ones give you some analogies to help make sense of quantum computing. But there’s a hollowness to them. Bluntly, if they don’t explain the actual underlying mathematical model, then you could spend years watching and rewatching such videos, and you’d never really get it. It’s like hanging out with a group of basketball players and listening to them talk about basketball. You might enjoy it, and feel as though you’re learning about basketball. But unless you actually spend a lot of time playing, you’re never going to learn to play basketball. To understand quantum computing, you absolutely must become fluent in the mathematical model.

 Part I: The state of a qubit

 As you know, in ordinary, everyday computers the fundamental unit of information is the bit. It’s a familiar but astonishing fact that all the things those computers do can be broken down into patterns of 00 0 s and 11 1 s , and simple manipulations of 00 0 s and 11 1 s . For me, I feel this most strongly when playing video games. I’ll be enjoying playing a game, when I’ll suddenly be hit by a realization of the astounding complexity behind the imaginary world visible on my screen:

 Source Copyright Wildfire Games, used under a Creative Commons Attribution-Share Alike 3.0 license . .

 Underlying every such image is millions of pixels, described by tens of millions of bits. When I move the game controller, I am effectively conducting an orchestra, tens of millions strong, organized through many layers of intermediary ideas, in such a way as to create enjoyment and occasionally sheer delight.

 I’ve described a bit as an abstract entity, whose state is 00 0 or 11 1 . But in the real world, not the world of mathematics, we must find some way of storing our bits in a physical system. That can be done in many different ways. In your computer’s memory chips, bits are most likely stored as tiny electric charges on nanometer-scale capacitors (i.e., little reservoirs of charge), just above the surface of the chip. Old-fashioned hard disks take a different approach, using tiny magnets to store bits. Furthermore, different types of memory use different types of capacitor; different types of hard disk use different approaches to magnetization.

 For the most part you don’t notice these differences when you use your computer. Computer designers work very, very hard to make the details of the physical instantiation of the bits invisible not just to the user, but also (often) invisible even to programmers. Many programmers never think about whether a bit is stored in fast on-microprocessor cache memory, in the dynamic RAM chips, or in some type of virtual memory (say, on a hard disk). There are exceptions – programmers working on high-performance programs sometimes do think about these things, to make their programs as fast as possible. But for many programmers it doesn’t much matter how bits are stored. Rather, they can think of the bit in purely abstract terms, as having a state which is either 00 0 or 11 1 .

 In a manner similar to the way conventional computers are made up of bits, quantum computers are made up of quantum bits, or qubits. Just like a bit, a qubit has a state. But whereas the state of a bit is a number (00 0 or 11 1 ) , the state of a qubit is a vector. More specifically, the state of a qubit is a vector in a two-dimensional vector space. This vector space is known as state space. For instance, here’s a possible state for a qubit:

 [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] [ 1 0 ​ ]

 That perhaps sounds strange! What does it mean that the state of a qubit is a two-dimensional vector? We’re going to unpack the answer slowly and gradually. You won’t have a single epiphany where you think “ahah, that’s what a qubit is!” Rather, you’ll gradually build up many details in your understanding, until you get to the point where you’re comfortable working with qubits, with quantum computations, and more generally with quantum mechanics.

 One way qubits are similar to bits: we’ve said absolutely nothing about what the qubit actually is, physically. Maybe the state of the qubit is being stored somehow on an electron, or a photon, or an atom. Or maybe it’s being stored in something stranger, perhaps inside some exotic particle or state of matter, even further removed from our everyday experience.

 For our purposes in this essay none of this matters, no more than you should worry about what type of capacitor is storing the bits inside your computer’s RAM. What you should take away is that: (a) qubits have a state; (b) much like a bit, that state is an abstract mathematical object; but (c) whereas a bit’s abstract state is a number, 00 0 or 11 1 , the state of a qubit is a 22 2 - dimensional vector; (d) we call the 22 2 - dimensional vector space where states live state space.

 Alright, let’s review what we’ve learnt. Please indulge me by answering the questions just below. It’ll only take a few seconds – for each question, think about what you believe the answer to be, click to reveal the actual answer, and then mark whether you remembered or not. If you can recall, that’s great. If not, that’s also fine, just note the correct answer, and continue.

 Didn’t rememberRemembered

 A medium which makes memory a choice

 Perhaps you correctly recalled the answers to all three questions just now. Even if so, will you remember the answers in a week? In a year? Human memory is fallible. If your memory is like mine, you might vaguely remember the answers in a week: “what’s the state of a qubit, oh yes, it’s a vector!” But the chances you’ll remember in a month or a year are low. And if you forget such things, you won’t have any durable understanding of quantum computing.

 How can we ensure you don’t remember these answers for just a few minutes or a few hours, but well into the future, perhaps even permanently?

 One way is for you to be supremely virtuous, to keep coming back and re-reviewing the material until it’s firmly locked in your memory. If you are such a virtuous person, congratulations! But for the other 99 percent of us that’s not likely. What can we do?

 For more than a century, cognitive scientists have studied human memory. And they’ve figured out some simple strategies that ensure you’ll remember something permanently. The single most important idea is to re-test you on your knowledge, with expanding time intervals between tests.

 As an example, consider the question above: “How many dimensions does the state space of a qubit have?” If you got it right, you’d ideally be tested again in a few weeks. And if you got it right again, you’d be tested again a few months after that. And so on, a gradually expanding schedule. If you get the question wrong on one of those tests, the schedule would contract, so you can relearn the answer.

 It turns out that such an expanding schedule is the optimal way to retain information. Each time you’re re-tested your brain consolidates the answer a little better into long-term memory, until eventually it’s permanent.

 Spaced-repetition testing is a simple idea, but has profound consequences. First, it doesn’t take much overall time. Because of the expanding test schedule, it typically only takes a few minutes of total review time to memorize the answer to a question for years or decades. I won’t go through the math showing that, but you can see it worked out elsewhere.

 Second, spaced-repetition testing gives you a guarantee you will remember the answer to the question. For the most part our memories work in a haphazard manner. We read or hear something interesting, and hope we remember it in future. Spaced-repetition testing makes memory into a choice.

 This sounds great, but also like you’ll need to be very disciplined in re-testing yourself. Fortunately, the computer can handle all the scheduling for you. And so this essay isn’t just a conventional essay, it’s also a new medium, a mnemonic medium which integrates spaced-repetition testing. The medium itself makes memory a choice.

 This comes at some cost: you’re committing to future review. But consider what that buys you. This essay will likely take you an hour or two to read. In a conventional essay, you’d forget most of what you learned over the next few weeks, perhaps retaining a handful of ideas. But with spaced-repetition testing built into the medium, a small additional commitment of time means you will remember all the core material of the essay. Doing this won’t be difficult, it will be easier than the initial read. Furthermore, you’ll be able to read other material which builds on these ideas; it will open up an entire world.

 This spaced-repetition approach is why the questions only require a few seconds to read and answer. They’re not complex exercises, in the style of a textbook. Rather, the questions have a different point: the promise each question makes is that you will remember the answer forever. It’s to permanently change your thinking.

 So, I invite you to set up an account by signing in below. If you do so, your review schedule for each question in the essay will be tracked, and you’ll receive periodic reminders containing a link which takes you to an online review session. That review session isn’t this full essay – rather, it looks just like the question set you answered above, but contains instead all the questions which are due, so you can quickly run through them. The time commitment will usually be a few minutes per session – a little more early on, when questions need frequent re-testing, but rapidly dropping off. You can study on your phone while grabbing coffee, or standing in line, or going for a walk, or in transit. The return for that small time commitment is greatly improved fluency in basic quantum computing and quantum mechanics. And that understanding will be internalized, a part of who you are, retained for years instead of days.

 To keep this promise, we’re tracking your review schedule for each question, and sending you occasional reminders to check in, and to run through the questions which are due. You can review on your phone while grabbing coffee, or standing in line, or going for a walk, or on transit. The return for that commitment is greatly improved fluency in basic quantum computing and quantum mechanics. And that understanding will be internalized, a part of who you are, retained for years instead of weeks.

 Please sign in so we can save your progress and let you know the best times to review.
 Thank you! Your progress will be saved as you read.

 Having extolled the virtues of spaced-repetition testing, let’s try another question:

 Didn’t rememberRemembered

 This question is similar to an earlier question: “How many dimensions does the state space of a qubit have?” It may seem inefficient to have such similar questions, but it helps build fluency with the material when you have the “same” information encoded into memory in multiple ways, triggering off different associations. And so many of the questions below have this nature, elaborating ideas in multiple ways.

 Connecting qubits to bits: the computational basis states

 Let’s get back to understanding qubits. I’ve described what the state of a qubit is, but given no hint about how (or whether) that’s connected to the state of a classical bit. (Henceforth we’ll use the phrase “classical bit” instead of “conventional bit”, after “classical physics”). In fact, there are two special quantum states which correspond to the 00 0 and 11 1 states of a classical bit. The quantum state corresponding to 00 0 is usually denoted ∣0⟩|0\rangle ∣ 0 ⟩ . That’s a fancy notation for the following vector:

 ∣0⟩:=[10].|0\rangle := \left[ \begin{array}{c} 1 \\ 0 \end{array} \right]. ∣ 0 ⟩ : = [ 1 0 ​ ] .

 This special state ∣0⟩|0\rangle ∣ 0 ⟩ is called a computational basis state.

 It’s tempting to see the ∣0⟩|0\rangle ∣ 0 ⟩ notation and wonder what all the separate pieces mean – what, for instance, does the ∣| ∣ mean; what does the ⟩\rangle ⟩ mean; and so on?

 In fact, it’s best to regard ∣0⟩|0\rangle ∣ 0 ⟩ as a single symbol, standing for a single mathematical object – that vector we just saw above, [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] [ 1 0 ​ ] . The ∣| ∣ and ⟩\rangle ⟩ don’t really have separate meanings except to signify this is a quantum state. In this, ∣0⟩|0\rangle ∣ 0 ⟩ is much like the symbol 00 0 : both stand for a single mathematical entity. And, as we’ll gradually come to see, a quantum computer can manipulate ∣0⟩|0\rangle ∣ 0 ⟩ in ways very similar to how a conventional computer can manipulate 00 0 .

 This notation with ∣| ∣ and ⟩\rangle ⟩ is called the ket notation, and things like ∣0⟩|0\rangle ∣ 0 ⟩ are called kets. But don’t be thrown off by the unfamiliar terminology – a ket is just a vector, and when we say something is a ket, all we mean is that it’s a vector.

 That said, the term ket is most often used in connection with notations like ∣0⟩|0\rangle ∣ 0 ⟩ . That is, we wouldn’t usually refer to [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] [ 1 0 ​ ] as a ket; we’d call it a vector, instead. If you’re a fan of really sharp definitions and strict consistency, this may seem vague and wishy-washy, but in practice doesn’t cause confusion. It’s just a convention to be aware of!

 Alright, so ∣0⟩|0\rangle ∣ 0 ⟩ is a computational basis state for a qubit, and plays much the same role as 00 0 does for a classical bit. It won’t surprise you to learn that there is another computational basis state, denoted ∣1⟩|1\rangle ∣ 1 ⟩ , which plays the same role as 11 1 does for a bit. Like ∣0⟩|0\rangle ∣ 0 ⟩ , ∣1⟩|1\rangle ∣ 1 ⟩ is just a notation for a two-dimensional vector, in this case:

 ∣1⟩:=[01].|1\rangle := \left[ \begin{array}{c} 0 \\ 1 \end{array} \right]. ∣ 1 ⟩ : = [ 0 1 ​ ] .

 Again, we’ll gradually come to see that ∣1⟩|1\rangle ∣ 1 ⟩ has all the properties we expect of the 11 1 state of a classical bit.

 Time for a few more questions. A reminder that these have a different purpose to conventional textbook exercises. Textbook exercises are about setting you challenges; the point of the questions below is instead to help you commit the answer to long-term memory.

 Didn’t rememberRemembered

 How to use (or not use!) the questions

 Mathematics is a process of staring hard enough with enough perseverance at the fog of muddle and confusion to eventually break through to improved clarity. I’m happy when I can admit, at least to myself, that my thinking is muddled, and I try to overcome the embarrassment that I might reveal ignorance or confusion. Over the years, this has helped me develop clarity in some things, but I remain muddled in many others.

 — William Thurston,
 Fields-medal winning mathematician

 How should you think about it when you get one of these embedded questions wrong? Often in life testing means being judged, and being judged can be uncomfortable. If you don’t know the answer to a question you may feel like you’ve failed.

 But the purpose of these questions has nothing to do with external judgment. Rather, they have two quite different purposes. One purpose is, as explained earlier, to help strengthen your memory, so your new knowledge is consolidated in your long-term memory. The second purpose is to help you diagnose what you do and don’t know, and to help you fill the gaps as rapidly as possible.

 In this view, getting a question wrong is useful information. It pinpoints exactly what you need to understand, and puts the onus on you to figure it out. Honestly, the appropriate response to getting a question wrong is probably to throw your hands up in the air and shout “wonderful!”, since it’s at those points of what may appear to be “failure” that your learning rate will be at its highest.

 With that said, it’s a common canard in education that “it doesn’t matter if you get something right or wrong, so long as you’re learning”. Unfortunately, that statement is often bullshit. If getting something right or wrong is used to determine your grade, or to influence other people’s opinion of you, then it damn well does matter.

 For that reason, I suggest keeping your results private. They are for you alone, and their purpose should be solely to help you learn as rapidly as possible. If they’re not helping you – if they’re making you feel bad, for instance, or being used to judge you – then stop doing the questions.

 You’ve probably noticed the questions are self-assessed. If you want to mark yourself “correct” sometimes, even when you’re not, go for it! What impact do you think that will have on your learning? Do you enjoy the slightly transgressive feeling? I must admit that I do. Don’t be embarrassed, if so: this is supposed to be, above all else, fun. Or try marking yourself wrong when you’re correct, or skipping the questions entirely. What impact do these actions have on your learning? The point is to figure out how to engage with the questions to learn as rapidly as possible. And that means experimenting playfully with how you engage, to find what works for you.

 How to approach this essay?

 This essay is an unusual form. It’s certainly not a product in the conventional startup sense; it’s a research project, an experiment in developing a new and improved form of reading. A conventional product would aim to draw you in, and form a regular, long-term habit. There’d be tens (or hundreds) of millions of words of content for you to read, and lots of people on social media excitedly pointing you toward that content. You’d engage every day, learning more and more and more.

 That’s not what’s going on here. “Quantum Computing for the Very Curious” is, instead, like a video game or book or movie, a single one-off project for you to work through. So you commit to it for a while, and then the experience is over. (Also, like a video game, book, or movie, sequels are planned!)

 With that said, it’s different from those forms too. Many people consume games, books, and movies as binge activities, hungrily devouring them until complete. “Quantum Computing for the Very Curious” is, by contrast, intentionally an experience spread out over time. Yes, you probably binge at first, working your way quickly through the text over a couple of hours. But then you return occasionally for brief review sessions, prompted by our notifications. That form of spaced testing is the best way for you to remember what you read. Still, while it might be optimal from the point of view of memory formation, it means not using some of the techniques that games, books, and movies use to keep you interested. Nonetheless, I hope you’ll be willing to trust the team at “Quantum Computing for the Very Curious”, and to participate in the experiment.

 How can you get the most out of reading in this new mnemonic medium? The ideal is to do an initial read, followed by a few short review sessions over the coming weeks (prompted by our notifications) to help you internalize the ideas. Then (optionally) a followup read, where you can more deeply understand the material. And finally, some sessions of followup review to ensure you remember for the long term:

 As you work through this process, we’ll track your overall progress toward completion (meaning: most questions reliably committed to memory), and each time you review we’ll show you that progress.

 This is a larger commitment than traditional reading. But for a small factor in effort, you will understand the material far more deeply, and remember it for more than 10x as long. What’s more, while the reading process above looks complex, you’ll be cued at each step by reminders that will help the review process become a habit. Trust the reminders, and this will all happen as a matter of course.

 You may find the essay particularly helpful if you’re taking an introductory class on quantum computing. If that’s your situation, I advise you to read the entire essay immediately at the beginning of semester (or even before), answering all the questions as you go. Then continue to follow the procedure described just above, taking a few minutes to complete each review session, prompted by the reminders you’ll be sent. This will make it far easier to understand the rest of the course you’re taking, and help you get much more out of it.

 General states of a qubit

 The computational basis states ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ are just two possible states for a qubit. Many more states are possible, and those extra states endow qubits with capabilities not available to ordinary classical bits. In general, remember, a quantum state is a two-dimensional vector. Here’s an example, with a graphical illustration emphasizing the vector nature of the state:

 In this example, the state 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ is just 0.60.6 0 . 6 times the ∣0⟩|0\rangle ∣ 0 ⟩ vector, plus 0.80.8 0 . 8 times the ∣1⟩|1\rangle ∣ 1 ⟩ vector. In the usual vector notation that means the state is:

 0.6∣0⟩+0.8∣1⟩=0.6[10]+0.8[01]=[0.60.8].0.6|0\rangle + 0.8 |1\rangle = 0.6 \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] + 0.8 \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] = \left[ \begin{array}{c} 0.6 \\ 0.8 \end{array} \right]. 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ = 0 . 6 [ 1 0 ​ ] + 0 . 8 [ 0 1 ​ ] = [ 0 . 6 0 . 8 ​ ] .

 I’ve been talking about quantum states as two-dimensional vectors. What I didn’t yet mention is that in general they’re complex vectors, that is, they can have complex numbers as entries. Of course, the example just shown has real entries, as do the computational basis states. But for a general quantum state the entries can be complex numbers. So, for instance, another quantum state is the vector

 1+i2∣0⟩+i2∣1⟩,\frac{1+i}{2} |0\rangle + \frac{i}{\sqrt{2}} |1\rangle, 2 1 + i ​ ∣ 0 ⟩ + 2 ​ i ​ ∣ 1 ⟩ ,

 which can be written in the conventional component vector representation as

 [1+i2i2].\left[ \begin{array}{c} \frac{1+i}{2} \\ \frac{i}{\sqrt{2}} \end{array} \right]. [ 2 1 + i ​ 2 ​ i ​ ​ ] .

 Because quantum states are in general vectors with complex entries, the illustration above shouldn’t be taken too literally – the plane is a real vector space, not a complex vector space. Still, visualizing it as a plane is sometimes a handy way of thinking.

 I’ve said what a quantum state is, as a mathematical object: it’s a two-dimensional vector in a complex vector space. But why is that true? What does it mean, physically, that it’s a vector? Why a complex vector space, and how should we think about the complex numbers? And what’s a quantum state good for, anyway?

 These are good questions. But they do take some time to answer. For context consider that the discovery of quantum mechanics wasn’t a single event, but occurred over 25 years of work, from 1900 to 1925. Many Nobel prizes were won for milestones along the way. That includes Albert Einstein’s Nobel Prize, won primarily for work related to quantum mechanics (not relativity, as people sometimes assume).

 When some of the brightest people in the world struggle for 25 years to develop a theory, it’s not an obvious theory! In fact, the idea of describing a simple quantum system using a complex vector in two dimensions summarizes much of what was learned over that 25 years. In that sense, it’s quite a simple and beautiful statement. But it’s not an obvious statement, and it’s not unreasonable that it might take a few hours to understand. That’s better than taking 25 years to understand!

 As part of that journey toward understanding, let’s get familiar with some more nomenclature commonly used for quantum states.

 One of the most common terms is superposition. People will say a state like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ is a superposition of ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ . All they mean is that the state is a linear combination of ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ . You may wonder why they don’t just say “linear combination” (and sometimes they do), but the reason is pretty much the same reason English-speakers say “hello” while Spanish-speakers say “hola” – the two terms come out of different cultures and different histories.

 Another common term is amplitude. An amplitude is the coefficient for a particular state in superposition. For instance, in the state 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ the amplitude for ∣0⟩|0\rangle ∣ 0 ⟩ is 0.60.6 0 . 6 , and the amplitude for ∣1⟩|1\rangle ∣ 1 ⟩ is 0.80.8 0 . 8 .

 We’ve learnt that a quantum state is a two-dimensional complex vector. Actually, it can’t be just any old vector, a fact you might have guessed from the very particular amplitudes in some of the examples above. There’s a constraint. The constraint is this: the sums of the squares of the amplitudes must be equal to 11 1 .

 So, for example, for the state 0.6∣0⟩+0.8∣1⟩0.6 |0\rangle+0.8 |1\rangle 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ the sum of the squares of the amplitudes is 0.62+0.820.6^2+0.8^2 0 . 6 2 + 0 . 8 2 , which is 0.36+0.64=10.36+0.64 = 1 0 . 3 6 + 0 . 6 4 = 1 , as we desired.

 For a more general quantum state, the amplitudes can be complex numbers, let’s denote them by α\alpha α and β\beta β so the state is α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ . The constraint is now that the sum of the squares of the amplitudes is 11 1 , i.e., ∣α∣2+∣β∣2=1|\alpha|^2+|\beta|^2 = 1 ∣ α ∣ 2 + ∣ β ∣ 2 = 1 .

 This is called the normalization constraint.

 It’s called that because if you think of ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ as orthonormal vectors, as I drew them earlier,

 then the normalization constraint is the requirement that the length of the state is equal to 11 1 . So it’s a unit vector, or a normalized vector, and that’s why this is called a normalization constraint.

 Summing up all these ideas in one sentence: the quantum state of a qubit is a vector of unit length in a two-dimensional complex vector space known as state space.

 We’ve gone through a few refinements of this sentence but that sentence is the final version – there’s no missing parts, or further refinement necessary! That’s what the quantum state of a qubit is. Of course, we will explore the definition further, deepening our understanding, but it will always come back to that basic fact.

 One common gotcha in thinking about qubits is to look at the ∣0⟩|0\rangle ∣ 0 ⟩ state and think it must be the zero vector in the vector space, often denoted 00 0 . But that’s not right at all. The zero vector is at the origin, 0=[00]0 = \left[ \begin{array}{c} 0 \\ 0 \end{array} \right] 0 = [ 0 0 ​ ] , while the ∣0⟩|0\rangle ∣ 0 ⟩ vector is quite different, ∣0⟩=[10]≠0|0\rangle = \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \neq 0 ∣ 0 ⟩ = [ 1 0 ​ ]  ​ = 0 . It’s just an unfortunate notational accident that ∣0⟩|0\rangle ∣ 0 ⟩ looks as though it should be the 00 0 vector. Fortunately, in practice this distinction is easy to get used to, and doesn’t cause confusion. But it’s worth noting.

 Didn’t rememberRemembered

 What does the quantum state mean? Why is it a vector in a complex vector space?

 My own conclusion is that today there is no interpretation of quantum mechanics that does not have serious flaws. This view is not universally shared. Indeed, many physicists are satisfied with their own interpretation of quantum mechanics. But different physicists are satisfied with different interpretations.

 — Steven Weinberg,
 Nobel Laureate in Physics

 Let’s come back to the question of what the quantum state means, and why it’s a vector in a complex vector space.

 In the case of classical bits, it’s pretty easy to think about the state. You can think of the 00 0 or 11 1 states of a bit as corresponding to two very different (but stable) states of a physical system. For instance, a 00 0 or 11 1 can be indicated by the presence or absence of a hole at some location in a punch card. And so a single punch card can be used to store hundreds or thousands of bits:

 Source: Gwern (2006).

 Most ways of storing classical bits are variations on this idea. For instance, the dynamic random access memory (RAM) inside your computer is based on the idea of having two tiny metal plates separated by a miniscule gap. Electric charge is stored on those plates, setting up an electric field between them. The 00 0 and 11 1 states of the bit correspond to two different configurations of charge on the plates. In practice, real dynamic RAM systems use slightly more elaborate ideas, but that’s the heart of it. This is harder to think about than punch cards – most of us don’t have so much experience thinking about moving electric charges around metal plates. But it’s still pretty concrete.

 So, how should we think about quantum states? The ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ states often aren’t difficult to think about, since they often correspond to very concrete physical states of the world, much like classical bits. Indeed, in some proposals they may correspond to different charge configurations, similar to dynamic RAM. Or perhaps a photon being in one of two different locations in space – again, a pretty simple, concrete notion, even if photons aren’t that familiar. There are also many more exotic proposals for the ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ states. But by and large you can think of the computational basis states as representing a physical system in one of two well-defined configurations.

 Of course, qubits have states which aren’t computational basis states, states like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ . How should we think about such superposition states? At least in popular media accounts, a very common description is that a state like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle + 0.8|1\rangle 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ is “simultaneously” in the ∣0⟩|0\rangle ∣ 0 ⟩ state and the ∣1⟩|1\rangle ∣ 1 ⟩ state.

 I must confess, I don’t understand what people mean by this. As far as I can tell, what they’re trying to do is explain the quantum state in terms of classical concepts they’re already familiar with. But I can’t make much sense of it – saying 0.6∣0⟩+0.8∣1⟩0.6|0\rangle + 0.8|1\rangle 0 . 6 ∣ 0 ⟩ + 0 . 8 ∣ 1 ⟩ is simultaneously in the ∣0⟩|0\rangle ∣ 0 ⟩ state and the ∣1⟩|1\rangle ∣ 1 ⟩ state seems like word salad, and makes about as much sense to me as Lewis Carroll’s nonsense poem Jabberwocky:

 ’Twas brillig, and the slithy toves
 Did gyre and gimble in the wabe:
 All mimsy were the borogoves,
 And the mome raths outgrabe.
 …

 Of course, lacking any other interpretation it’s tempting to try to impose our classical prejudices on the quantum state. Or, even if you reject that, to get hung up worrying about what a quantum state is. But the trouble is that there is enormous disagreement amongst physicists themselves about how to think about the quantum state. Indeed, many active researchers are trying to understand what the correct way of thinking about the quantum state is, exploring multiple approaches in great depth. So we’re going to defer worrying too much about this until later.

 To understand why we’re deferring, suppose someone gives you a Rubik’s cube (or some other challenging puzzle or game) for the first time, all scrambled up. You start to theorize about the best ways of solving it, how to understand it, and so on. But you never actually play around with it, getting familiar with how it behaves.

 Often the best way to understand something is to first use it, to get comfortable, to play a lot, and to do lots of informal experiments. As you build familiarity you understand why things are the way they are. At that point, you can go back and better understand the meaning of the basics.

 Well, we can think of quantum computing and quantum mechanics as an especially complicated type of puzzle! So the strategy we’re taking is to start with the mathematics of quantum computing – we’ll keep getting familiar with qubits and the quantum state, and developing the consequences. Doing that is how we’ll build up intuition, and will give us the chops needed to come back and think harder about the meaning of the quantum state.

 Part II: Introducing quantum logic gates

 In Part I we learned about the state of a qubit. But in order to quantum compute, it’s not enough just to understand quantum states. We need to be able to do things with them! We do that using quantum logic gates.

 A quantum logic gate is simply a way of manipulating quantum information, that is, the quantum state of a qubit or a collection of qubits. They’re analogous to the classical logic gates used in ordinary, everyday computers – gates such as the AND, OR, and NOT gates. And, much like classical gates’ role in conventional computers, quantum gates are the basic building blocks of quantum computation. They’re also a convenient way of describing many other quantum information processing tasks, such as quantum teleportation.

 In Part II of this essay we’ll discuss several types of quantum logic gate. As we’ll see, the gates we discuss are sufficient to do any quantum computation. In particular, much as any classical computation can be built up using AND, OR, and NOT gates, the quantum gates we describe over the next few sections suffice to do any quantum computation.

 Many of the quantum gates we’ll learn about are based on familiar classical logic gates. But a few are different. Those differences appear innocuous, almost trivial. But in those differences lies the power of quantum computation, and the possibility for quantum computers to be vastly superior to classical computers.

 Part II is, frankly, a bit of a slog. Learning quantum gates is like learning basic vocabulary in a new language: there’s no getting round spending a fair bit of time working on it. Still, the spaced-repetition testing should make this basic memory work much easier than is ordinarily the case. And it will prepare you well for some of the more conceptual issues discussed in Part III, where we return to high-level questions about the ultimate nature of computation, and what quantum computers are good for.

 The quantum NOT gate

 Let’s take a look at our very first quantum logic gate, the quantum NOT gate. As you can no doubt surmise, the quantum NOT gate is a generalization of the classical NOT gate. On the computational basis states the quantum NOT gate does just what you’d expect, mimicking the classical NOT gate. That is, it takes the ∣0⟩|0\rangle ∣ 0 ⟩ state to ∣1⟩|1\rangle ∣ 1 ⟩ , and vice versa:

 NOT∣0⟩=∣1⟩NOT|0\rangle = |1\rangle N O T ∣ 0 ⟩ = ∣ 1 ⟩

 NOT∣1⟩=∣0⟩NOT|1\rangle = |0\rangle N O T ∣ 1 ⟩ = ∣ 0 ⟩

 But the computational basis states aren’t the only states possible for a qubit. What happens when we apply the NOT gate to a general superposition state, that is, α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ ? In fact, it does pretty much the simplest possible thing: it acts linearly on the quantum state, interchanging the role of ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ :

 NOT(α∣0⟩+β∣1⟩)=α∣1⟩+β∣0⟩.NOT (\alpha|0\rangle +\beta|1\rangle) = \alpha|1\rangle+\beta |0\rangle. N O T ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) = α ∣ 1 ⟩ + β ∣ 0 ⟩ .

 I’ve been using the notation NOT for the quantum NOT gate. But for historical reasons people working on quantum computing usually use a different notation, the notation XX X . And so the above may be rewritten:

 X(α∣0⟩+β∣1⟩)=α∣1⟩+β∣0⟩.X (\alpha|0\rangle +\beta|1\rangle) = \alpha|1\rangle+\beta |0\rangle. X ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) = α ∣ 1 ⟩ + β ∣ 0 ⟩ .

 I’ll use the terms XX X gate and NOT gate interchangeably.

 Historically, the notation XX X traces its origin to 1927, when the physicist Wolfgang Pauli introduced an operation sxs_x s x ​ (often written σx\sigma_x σ x ​ in textbooks today) to help describe rotations of certain objects around the xx x spatial axis. This operation later became of interest to people working on quantum computing. But by that point the ss s (and the connection to rotation) was irrelevant, and so sxs_x s x ​ just became XX X .

 What we’ve seen so far are very algebraic ways of writing down the way the XX X gate works. There’s an alternate representation, the quantum circuit representation. In a quantum circuit we depict an XX X gate as follows:

 The line from left to right is what’s called a quantum wire. A quantum wire represents a single qubit. The term “wire” and the way it’s drawn looks like the qubit is moving through space. But it's often helpful to instead think of left-to-right as representing the passage of time. So the initial segment of wire is just the passage of time, with nothing happening to the qubit. Then the XX X gate is applied. And then the quantum wire continues, leaving the desired output.

 Sometimes we’ll put the input and output states explicitly in the quantum circuit, so we have something like:

 So that’s the quantum circuit representation of the XX X gate. It is, in fact, our first quantum computation. A simple computation, involving just a single qubit and a single gate, but a genuine quantum computation nonetheless!

 There’s a third representation for the XX X gate that’s worth knowing about, a representation as a 2×22 \times 2 2 × 2 matrix:

 X=[0110].X = \left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right]. X = [ 0 1 ​ 1 0 ​ ] .

 To understand in what sense this is a representation of the NOT gate, recall that α∣0⟩+β∣1⟩\alpha|0\rangle + \beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ is just the vector [αβ]\left[ \begin{array}{c} \alpha \\ \beta \end{array} \right] [ α β ​ ] . And so we have:

 [0110](α∣0⟩+β∣1⟩)=[0110][αβ]=[βα]=α∣1⟩+β∣0⟩=X(α∣0⟩+β∣1⟩).\begin{aligned} \left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right] (\alpha|0\rangle + \beta|1\rangle) & = \left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right] \left[ \begin{array}{c} \alpha \\ \beta \end{array} \right] \\ & = \left[ \begin{array}{c} \beta \\ \alpha \end{array} \right] \\ & = \alpha|1\rangle+\beta|0\rangle \\ & = X (\alpha|0\rangle + \beta|1\rangle). \end{aligned} [ 0 1 ​ 1 0 ​ ] ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) ​ = [ 0 1 ​ 1 0 ​ ] [ α β ​ ] = [ β α ​ ] = α ∣ 1 ⟩ + β ∣ 0 ⟩ = X ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) . ​

 This tells us that XX X and [0110]\left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right] [ 0 1 ​ 1 0 ​ ] act in exactly the same way on all vectors, and thus are the same operation. In fact, as we’ll see later, it turns out that all quantum gates can be thought of as matrices, with the matrix entries specifying the exact details of the gate.

 By the way, regarding the XX X gate as a matrix clarifies what may have been a confusing point earlier. I wrote the XX X gate as having the action X∣0⟩=∣1⟩X|0\rangle = |1\rangle X ∣ 0 ⟩ = ∣ 1 ⟩ , X∣1⟩=∣0⟩X|1\rangle = |0\rangle X ∣ 1 ⟩ = ∣ 0 ⟩ . Implicitly – I never quite said this, though it’s true – the XX X gate is a mathematical function, taking input states to output states. But when we write functions we usually use parentheses, so why didn’t I write X(∣0⟩)X(|0\rangle) X ( ∣ 0 ⟩ ) and similarly for ∣1⟩|1\rangle ∣ 1 ⟩ ? The reason is that for linear functions, i.e., matrices, it’s conventional to omit parentheses and just write X∣0⟩X|0\rangle X ∣ 0 ⟩ – function application is just matrix multiplication.

 Didn’t rememberRemembered

 Quantum wires: why the simplest quantum circuit is often also the hardest to implement

 We’ve now seen a simple quantum circuit and quantum logic gate. But it’s not quite the simplest possible quantum circuit. The simplest possible quantum circuit does nothing at all. That is, it’s a single quantum wire:

 This circuit is just a single qubit being preserved in time. To be more explicit, if some arbitrary quantum state ∣ψ⟩|\psi\rangle ∣ ψ ⟩ is input to the circuit, then the exact same state ∣ψ⟩|\psi\rangle ∣ ψ ⟩ is output (it’s common practice to use the Greek letter ψ\psi ψ to denote an arbitrary quantum state):

 Mathematically, this circuit is trivial. But physically it’s far from trivial. In many physical systems, the quantum wire is actually one of the hardest quantum computations to implement!

 The reason is that quantum states are often incredibly fragile. If your qubit is being stored in some tiny system – perhaps a single photon or a single atom – then it’s very, very easy to disturb that state. It really doesn’t take much to upset an atom or a photon. And so while quantum wires are mathematically trivial, they can be one of the hardest elements to build in real systems.

 That said, there are some systems where quantum wires are easy to implement. If you store your qubit in a neutrino then the state will actually be pretty well preserved. The reason is that neutrinos barely interact with other forms of matter at all – a neutrino can easily pass through a mile of lead without being disturbed. But while it’s intriguing that neutrinos are so stable, it doesn’t mean they make good qubits. The trouble is that since there’s no easy way of using ordinary matter to interact with them, we can’t manipulate their quantum state in a controlled fashion, and so can’t implement a quantum gate.

 There’s a tension here that applies to many proposals to do quantum information processing, not just neutrinos. If we want to store the quantum state, then it’s helpful if our qubits only interact very weakly with other systems, so those systems don’t disrupt them. But if the qubits only interact weakly with other systems then that also makes it hard to manipulate the qubits. Thus, systems which make good quantum wires are often hard to build quantum gates for. Much of the art of designing quantum computers is about finding ways to navigate this tension. Often, that means trying to design systems which interact weakly most of the time, but some of the time can be caused to interact strongly, and so serve as part of a quantum gate.

 Didn’t rememberRemembered

 You’ll note that some of the questions above have a different flavor to the questions earlier in the essay. Early questions had cut-and-dried answers. The answer to the question “What’s the standard notation for the quantum NOT gate?” is just: “XX X ” . But some of the questions above have less well-specified answers. They’re a little fluffy.

 This fluffiness may cause you difficulties as you decide how to respond. Your answer to the question “Why is it that systems which make good quantum wires are often hard to build quantum gates for?” may not quite match the answer given. If this is the case, don’t worry. You should mark yourself correct if you’re confident you’ve understood the point, even in terms different from my phrasing. And mark yourself incorrect if the point still needs reinforcement.

 A multi-gate quantum circuit

 Let’s take a look at a simple multiple-gate quantum circuit. It’s just a circuit with two XX X gates in a row:

 It’s worth pausing for a moment, and trying to guess what this circuit does to the input state. It’s worth doing this even if you usually find this kind of guessing frustrating. Even when you get stuck, building up strategies for dealing with stuckness is part of learning any difficult subject. So take a minute or so now.

 We’ll try two different ways of figuring out what’s going on. Here’s one approach, based on applying XX X twice to an arbitrary input state, α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ . It’s simple algebra, using the fact XX X interchanges the ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ states:

 X(X(α∣0⟩+β∣1⟩))=X(α∣1⟩+β∣0⟩)=α∣0⟩+β∣1⟩\begin{aligned} X(X(\alpha|0\rangle+\beta|1\rangle)) & = X(\alpha|1\rangle + \beta|0\rangle) \\ & = \alpha|0\rangle + \beta|1\rangle \end{aligned} X ( X ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) ) ​ = X ( α ∣ 1 ⟩ + β ∣ 0 ⟩ ) = α ∣ 0 ⟩ + β ∣ 1 ⟩ ​

 So the net effect is to recover the original quantum state, no matter what that state was. In other words, this circuit is equivalent to a quantum wire:

 A second way of seeing this is based on the matrix representation we found earlier for the XX X gate. Observe that if the input is some arbitrary quantum state ∣ψ⟩|\psi\rangle ∣ ψ ⟩ , then after the first gate the state is X∣ψ⟩X|\psi\rangle X ∣ ψ ⟩ , and after the second gate the state is XX∣ψ⟩X X |\psi\rangle X X ∣ ψ ⟩ . Then we observe that the product XXX X X X is

 XX=[0110][0110]=[1001].\begin{aligned} XX & = \left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right] \left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right] \\ & = \left[ \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right]. \end{aligned} X X ​ = [ 0 1 ​ 1 0 ​ ] [ 0 1 ​ 1 0 ​ ] = [ 1 0 ​ 0 1 ​ ] . ​

 That is, XXXX X X is the identity operation, and so the output XX∣ψ⟩XX|\psi\rangle X X ∣ ψ ⟩ is just the original input ∣ψ⟩|\psi\rangle ∣ ψ ⟩ . In other words, two XX X gates is the same as a quantum wire. And so we’ve arrived at the same conclusion in a different way, using matrix multiplication. Doing such matrix multiplications is a pretty common way of analyzing quantum circuits.

 Didn’t rememberRemembered

 The Hadamard gate

 We’ve seen our first quantum gate, the NOT or XX X gate. Of course, the XX X didn’t appear to do all that much beyond what is possible with a classical NOT gate. In this section I introduce a gate that clearly involves quantum effects, the Hadamard gate.

 As with the XX X gate, we’ll start by explaining how the Hadamard gate acts on computational basis states. Denoting the gate by HH H , here’s what it does:

 H∣0⟩=∣0⟩+∣1⟩2H|0\rangle = \frac{|0\rangle +|1\rangle}{\sqrt 2} H ∣ 0 ⟩ = 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​

 H∣1⟩=∣0⟩−∣1⟩2H|1\rangle = \frac{|0\rangle -|1\rangle}{\sqrt 2} H ∣ 1 ⟩ = 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​

 Of course, ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ aren’t the only quantum states. How does the Hadamard gate act on more general quantum states?

 It won’t surprise you to learn that it acts linearly, as did the quantum NOT gate. In particular, the Hadamard gate takes a superposition α∣0⟩+β∣1⟩\alpha|0\rangle + \beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ to the corresponding superposition of outputs:

 H(α∣0⟩+β∣1⟩)=α(∣0⟩+∣1⟩2)+β(∣0⟩−∣1⟩2).H(\alpha|0\rangle + \beta|1\rangle) = \alpha \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} \right) + \beta \left( \frac{|0\rangle-|1\rangle}{\sqrt 2} \right). H ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) = α ( 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ ) + β ( 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ ) .

 That’s a mess. We can make it less of a mess by combining the ∣0⟩|0\rangle ∣ 0 ⟩ terms together, and also the ∣1⟩|1\rangle ∣ 1 ⟩ terms together:

 H(α∣0⟩+β∣1⟩)=α+β2∣0⟩+α−β2∣1⟩.H(\alpha|0\rangle + \beta|1\rangle) = \frac{\alpha+\beta}{\sqrt 2} |0\rangle + \frac{\alpha-\beta}{\sqrt 2}|1\rangle. H ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) = 2 ​ α + β ​ ∣ 0 ⟩ + 2 ​ α − β ​ ∣ 1 ⟩ .

 That’s better, but still not pretty! Fortunately, we mostly won’t be dealing with such complex expressions. The only reason I’ve done it here is to be really explicit. Instead of dealing with such explicit expressions, we’ll mostly work with the HH H gate in its circuit and matrix representations (see below). Those let us focus at a more enlightening level of abstraction, rather than messing around with coefficients.

 Indeed, much work on quantum computing is about attempting to develop ways of moving from low levels of abstraction to higher, more conceptual levels. Up to now most of our work has been at a very low level, seeming more an exercise in linear algebra than a discussion of a new model of computing. That perhaps seems strange. After all, if you were explaining classical computers to someone, you wouldn’t start in the weeds, with AND and NOT gates and the like. You’d start with a well-designed high-level programming language, and then bounce back and forth between different layers of abstraction. Modern computers aren’t just about logic gates – they’re at least as much about beautiful higher-level ideas: say, lazy evaluation, or higher-order functions, or homoiconicity, and so on.

 I wish I could start with high-level abstractions for quantum computers. However, we’re still in the early days of quantum computing, and for the most part humanity hasn’t yet discovered such high-level abstractions. People are still scratching around, trying to find good ideas.

 That’s an exciting situation: it means almost all the big breakthroughs are ahead. There’s a sense in which we still understand very little about quantum computing. That might sound surprising: after all, there are great big fat textbooks on the subject. But you could have written a great big fat textbook about the ENIAC computer in the late 1940s. It was, after all, a very complex system. That textbook would have looked intimidating, but it wouldn’t have been the final word in computing. For the most part the way we understand quantum computing today is at an ENIAC-like level, looking at the nuts-and-bolts of qubits and logic gates and linear algebra, and wondering what the higher-level understanding may be. The situation can be thought of as much like programming language design before the breakthroughs that led to languages such as Lisp and Haskell and Prolog and Smalltalk. That makes it a remarkable creative opportunity, a challenge for the decades and centuries ahead.

 Speaking of nuts-and-bolts, let’s get back to the Hadamard gate. Here’s the circuit representation for the Hadamard gate. It looks just like the XX X gate in the circuit representation, except we change the gate label to HH H :

 Just like the XX X gate, HH H has a matrix representation:

 H=12[111−1].H = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right]. H = 2 ​ 1 ​ [ 1 1 ​ 1 − 1 ​ ] .

 To see that this matrix representation is correct, let’s check the action of the matrix on the ∣0⟩|0\rangle ∣ 0 ⟩ and the ∣1⟩|1\rangle ∣ 1 ⟩ states. Here we check for the ∣0⟩|0\rangle ∣ 0 ⟩ state:

 12[111−1]∣0⟩=12[111−1][10]=12[11]=∣0⟩+∣1⟩2.\begin{aligned} \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right] |0\rangle & = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right] \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \\ & = \frac{1}{\sqrt 2} \left[ \begin{array}{c} 1 \\ 1 \end{array} \right] \\ & = \frac{|0\rangle+|1\rangle}{\sqrt 2}. \end{aligned} 2 ​ 1 ​ [ 1 1 ​ 1 − 1 ​ ] ∣ 0 ⟩ ​ = 2 ​ 1 ​ [ 1 1 ​ 1 − 1 ​ ] [ 1 0 ​ ] = 2 ​ 1 ​ [ 1 1 ​ ] = 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ . ​

 That is, this matrix acts the same way as the Hadamard gate on the ∣0⟩|0\rangle ∣ 0 ⟩ state. Now let’s check on the ∣1⟩|1\rangle ∣ 1 ⟩ state:

 12[111−1]∣1⟩=12[111−1][01]=12[1−1]=∣0⟩−∣1⟩2.\begin{aligned} \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right] |1\rangle & = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right] \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] \\ & = \frac{1}{\sqrt 2} \left[ \begin{array}{c} 1 \\ -1 \end{array} \right] \\ & = \frac{|0\rangle-|1\rangle}{\sqrt 2}. \end{aligned} 2 ​ 1 ​ [ 1 1 ​ 1 − 1 ​ ] ∣ 1 ⟩ ​ = 2 ​ 1 ​ [ 1 1 ​ 1 − 1 ​ ] [ 0 1 ​ ] = 2 ​ 1 ​ [ 1 − 1 ​ ] = 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ . ​

 So the matrix acts the same way as the Hadamard gate on both the ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ states. By the linearity of matrix multiplication it follows that the matrix acts the same way as the Hadamard on all input states, and so they are the same operation.

 What makes the Hadamard gate interesting as a quantum gate? What can we use it to do?

 We don’t (quite) have enough background to give precise answers to these questions yet. But there is an analogy which gives insight.

 Imagine you are living in North Africa, thousands of years in the past, and decide for some reason that you want to get over to the Iberian peninsula. If you don’t yet have boats or some other reliable method of moving across large bodies of water, you need to go all the way across Africa, past the Arabian peninsula, up and around through Europe, back to the Iberian peninsula:

 Original photo source: Reto Stöckli, NASA Earth Observatory (2004).

 Suppose, however, that you invent a new device, the boat, which expands the range of locations you can traverse. Then you can take a much more direct route over to the Iberian peninsula, greatly cutting down the time required:

 What the Hadamard and similar gates do is expand the range of operations that it’s possible for a computer to perform. That expansion makes it possible for the computer to take shortcuts, as the computer “moves” in a way that’s not possible in a conventional classical computer. And, we hope, that may enable us to solve some computational problems faster.

 Another helpful analogy is to the game of chess. Imagine you’re playing chess and the rules are changed in your favor, enabling your rook an expanded range of moves. That extra flexibility might enable you to achieve checkmate much faster because you can get to new positions much more quickly.

 A similar thing is going on with the Hadamard gate. By expanding the range of states we can access (or, more precisely, the range of dynamical operations we can generate) beyond what’s possible on a classical computer, it becomes possible to take shortcuts in our computation.

 We’ll see explicit examples in subsequent essays.

 To get more familiar with the Hadamard gate, let’s analyze a simple circuit:

 What’s this circuit do?

 Before we compute, it’s worth pausing for a second to try guessing the result. The point of guessing isn’t to get it right – rather, it’s to challenge yourself to start coming up with heuristic mental models for thinking about what’s going on in quantum circuits. Those mental models likely won’t be very good at first, but that’s okay – if you keep doing this, they’ll get better.

 Here’s one heuristic you can use to think about this circuit: you can think of HH H as sort of mixing the ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ states together. So if you apply HH H twice to ∣0⟩|0\rangle ∣ 0 ⟩ , perhaps it would thoroughly mix the ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ up together. What sort of state do you think would result, according to this heuristic? Do you believe the result? Why or why not? Can you think of other heuristics that might help you guess an answer?

 Alright, let’s compute what actually happens. After we apply the first Hadamard to ∣0⟩|0\rangle ∣ 0 ⟩ we get

 ∣0⟩+∣1⟩2.\frac{|0\rangle+|1\rangle}{\sqrt{2}}. 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ .

 Then we apply a second Hadamard gate. This takes the ∣0⟩|0\rangle ∣ 0 ⟩ term above to ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ and the ∣1⟩|1\rangle ∣ 1 ⟩ term to ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ , so the output is:

 12(∣0⟩+∣1⟩2+∣0⟩−∣1⟩2).\frac{1}{\sqrt 2} \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} + \frac{|0\rangle-|1\rangle}{\sqrt 2} \right). 2 ​ 1 ​ ( 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ + 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ ) .

 If you look at the expression above, you’ll notice that the ∣1⟩|1\rangle ∣ 1 ⟩ terms cancel each other out, so you’re just left with the ∣0⟩|0\rangle ∣ 0 ⟩ terms. Collecting them up, we’re left with the ∣0⟩|0\rangle ∣ 0 ⟩ state, same as we started with:

 12(∣0⟩2+∣0⟩2)=∣0⟩.\frac{1}{\sqrt 2} \left(\frac{|0\rangle}{\sqrt 2}+ \frac{|0\rangle}{\sqrt 2} \right) = |0\rangle. 2 ​ 1 ​ ( 2 ​ ∣ 0 ⟩ ​ + 2 ​ ∣ 0 ⟩ ​ ) = ∣ 0 ⟩ .

 In a similar fashion, after we run the ∣1⟩|1\rangle ∣ 1 ⟩ state through the first Hadamard gate, we get:

 ∣0⟩−∣1⟩2.\frac{|0\rangle-|1\rangle}{\sqrt{2}}. 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ .

 Then we apply a second Hadamard gate to get:

 12(∣0⟩+∣1⟩2−∣0⟩−∣1⟩2).\frac{1}{\sqrt 2} \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} - \frac{|0\rangle-|1\rangle}{\sqrt 2} \right). 2 ​ 1 ​ ( 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ − 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ ) .

 This time it’s the ∣0⟩|0\rangle ∣ 0 ⟩ terms which cancel out, and the ∣1⟩|1\rangle ∣ 1 ⟩ terms reinforce. When we collect up these terms, we see that the output is just the ∣1⟩|1\rangle ∣ 1 ⟩ state, same as we started with. And so both the ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ states are left unchanged by this quantum circuit, and the net effect of the circuit is exactly the same as a quantum wire:

 There’s an alternate way of seeing this, which I’ll sketch out without working through in detail. It’s to note that if we input an arbitrary quantum state ∣ψ⟩|\psi\rangle ∣ ψ ⟩ to the circuit, then the output must be HH∣ψ⟩H H |\psi\rangle H H ∣ ψ ⟩ , i.e., the result of applying two HH H matrices to ∣ψ⟩|\psi\rangle ∣ ψ ⟩ . But if you just compute the matrix product HHH H H H it turns out to be the 2×22 \times 2 2 × 2 identity matrix, HH=IH H = I H H = I . And so the output from the circuit must be the same as the input, HH∣ψ⟩=I∣ψ⟩=∣ψ⟩HH|\psi\rangle = I |\psi\rangle = |\psi\rangle H H ∣ ψ ⟩ = I ∣ ψ ⟩ = ∣ ψ ⟩ , just as from a quantum wire.

 Of course, this result violates our intuitive guess, which was that two Hadamards would thoroughly mix up the ∣0⟩|0\rangle ∣ 0 ⟩ and the ∣1⟩|1\rangle ∣ 1 ⟩ . It’s interesting to ponder what went wrong with our intuition, say by looking through the calculation for HH H acting twice on ∣0⟩|0\rangle ∣ 0 ⟩ . You see that after the second gate the ∣1⟩|1\rangle ∣ 1 ⟩ terms exactly cancel one another out, while the ∣0⟩|0\rangle ∣ 0 ⟩ terms reinforce one another.

 This seems innocuous, almost like a mathematical accident. Still, I draw your attention to it because this type of cancellation or reinforcement is crucial in many algorithms for quantum computers. Without getting into details, the rough way many such algorithms work is to first use Hadamard gates to “spread out” in quantum states like ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ (or many-qubit analogs), i.e., in superpositions of multiple computational basis states. At the end of the algorithm they use clever patterns of cancellation and reinforcement to bring things back together again into one (or possibly a few, in the many-qubit case) computational basis state, containing the desired answer. That’s a somewhat vague and perhaps tantalizing description, but the point to take away is that the kind of cancellation-or-reinforcement we saw above is actually crucial in many quantum computations.

 I’ll now pose a few simple exercises related to the Hadamard gate. Unlike the spaced-repetition questions, the point of the exercises below isn’t as an aid to memory, and so you won’t see these exercises repeatedly. Rather, they’re here because (should you choose to work through them) they will help you better understand the material of the essay. But they’ll only incidentally help with memorization. We’ll follow them with some spaced-repetition questions. Note that even if you don't work through the exercises, it's worth at least reading through them, since some of the results will be tested in the spaced-repetition questions.

 Exercise: Verify that HH=IHH = I H H = I , where II I is the 2×22 \times 2 2 × 2 identity matrix, I=[1001]I = \left[ \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right] I = [ 1 0 ​ 0 1 ​ ] .

 Exercise: Suppose that instead of HH H we’d defined a matrix JJ J by:

 J:=12[1111]J := \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & 1 \end{array} \right] J : = 2 ​ 1 ​ [ 1 1 ​ 1 1 ​ ]

 At first, it might seem that JJ J would make an interesting quantum gate, along lines similar to HH H . For instance, J∣0⟩=∣0⟩+∣1⟩2J|0\rangle = \frac{|0\rangle+|1\rangle}{\sqrt 2} J ∣ 0 ⟩ = 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ , and J∣1⟩=∣0⟩+∣1⟩2J|1\rangle = \frac{|0\rangle+|1\rangle}{\sqrt 2} J ∣ 1 ⟩ = 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ . These are both good, normalized quantum states. But what happens if we apply JJ J to the quantum state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ ? Why does this make JJ J unsuitable for use as a quantum gate?

 Exercise: Consider the quantum circuit:

 Explain why the output from this circuit is XH∣ψ⟩XH|\psi\rangle X H ∣ ψ ⟩ , not HX∣ψ⟩HX|\psi\rangle H X ∣ ψ ⟩ , as you might naively assume if you wrote down gates in the order they occur in the circuit. This is a common gotcha to be aware of – it occurs because quantum gates compose left-to-right in the circuit representation, while matrix multiplications compose right-to-left.

 Didn’t rememberRemembered

 Measuring a qubit

 Suppose a (hypothetical!) quantum physicist named Alice prepares a qubit in her laboratory, in a quantum state α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ . Then she gives her qubit to another quantum physicist, Bob, but doesn’t tell him the values of α\alpha α and β\beta β . Is there some way Bob can figure out α\alpha α and β\beta β ? That is, is there some experiment Bob can do to figure out the identity of the quantum state?

 The surprising answer to this question turns out to be NO! There is, in fact, no way to figure out α\alpha α and β\beta β if they start out unknown. To put it a slightly different way, the quantum state of any system – whether it be a qubit or a some other system – is not directly observable.

 I say this is surprising, because it’s very different from our usual everyday way of thinking about how the world works. If there’s something wrong with your car, a mechanic can use diagnostic tools to learn about the internal state of the engine. The better the diagnostic tools, the more they can learn. Of course, there may be parts of the engine that would be impractical to access – maybe they’d have to break a part, or use a microscope, for instance. But you’d probably be rather suspicious if the mechanic told you the laws of physics prohibited them from figuring out the internal state of the engine.

 Similarly, when you first start learning about quantum circuits, it seems like we should be able to observe the amplitudes of a quantum state whenever we like. But that turns out to be prohibited by the laws of physics. Those amplitudes are better thought of as a kind of hidden information.

 So, what can we figure out from the quantum state? Rather than somehow measuring α\alpha α and β\beta β , there are other ways of getting useful information out of a qubit. Let me describe an especially important process called measurement in the computational basis. This is a fundamental primitive in quantum computing: it’s the way we typically extract information from our quantum computers. I’ll explain now how it works for a single qubit, and later generalize to multi-qubit systems.

 Suppose a qubit is in the state α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ . When you measure this qubit in the computational basis it gives you a classical bit of information: it gives you the outcome 00 0 with probability ∣α∣2|\alpha|^2 ∣ α ∣ 2 , and the outcome 11 1 with probability ∣β∣2|\beta|^2 ∣ β ∣ 2 .

 To think a little more concretely about this process, suppose your qubit is instantiated in some physical system. Perhaps it’s being stored in the state of an atom somehow. It doesn’t matter exactly what, but you have this qubit in your laboratory. And you have some measurement apparatus, probably something large and complicated, maybe involving lasers and microprocessors and a screen for readout of the measurement result. And this measurement apparatus interacts in some way with your qubit.

 After the measurement interaction, your measurement apparatus registers an outcome. For instance, it might be that you get the outcome 00 0 . Or maybe instead you get the outcome 11 1 . The crucial fact is that the outcome is ordinary classical information – the stuff you already know how to think about – which you can then use to do other things, and to control other processes.

 So the way a quantum computation works is that we manipulate a quantum state using a series of quantum gates, and then at the end of the computation (typically) we do a measurement to read out the result of the computation. If our quantum computer is just a single qubit, then that result will be a single classical bit. If, as is more usually the case, it’s multiple qubits, then the measurement result will be multiple classical bits.

 A fundamental fact about this measurement process is that it disturbs the state of the quantum system. In particular, it doesn’t just leave the quantum state alone. After the measurement, if you get the outcome 00 0 then the state of the qubit afterwards (the “posterior state”) is the computational basis state ∣0⟩|0\rangle ∣ 0 ⟩ . On the other hand, if you get the outcome 11 1 then the posterior state of the qubit is the computational basis state ∣1⟩|1\rangle ∣ 1 ⟩ .

 Summing all this up: if we measure a qubit with state α∣0⟩+β∣1⟩\alpha |0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ in the computational basis, then the outcome is a classical bit: either 00 0 , with probability ∣α∣2|\alpha|^2 ∣ α ∣ 2 , or 11 1 , with probability ∣β∣2|\beta|^2 ∣ β ∣ 2 . The corresponding state of the qubit after the measurement is ∣0⟩|0\rangle ∣ 0 ⟩ or ∣1⟩|1\rangle ∣ 1 ⟩ .

 A key point to note is that after the measurement, no matter what the outcome, α\alpha α and β\beta β are gone. No matter whether the posterior state is ∣0⟩|0\rangle ∣ 0 ⟩ or ∣1⟩|1\rangle ∣ 1 ⟩ , there is no trace of α\alpha α or β\beta β . And so you can’t get any more information about them. In that sense, α\alpha α and β\beta β are a kind of hidden information – the measurement doesn’t tell you what they were.

 One reason this is important is because it means you can’t store an infinite amount of classical information in a qubit. After all, α\alpha α is a complex number, and you could imagine storing lots of classical bits in the binary expansion of the real component of α\alpha α . If there was some experimental way you could measure the value of α\alpha α exactly, then you could extract that classical information. But without a way of measuring α\alpha α that’s not possible.

 I’ve been talking about measurement in the computational basis. In fact, there are other types of measurement you can do in quantum systems. But there’s a sense in which computational basis measurements turn out to be fundamental. The reason is that by combining computational basis measurements with quantum gates like the Hadamard and NOT (and other) gates, it’s possible to simulate arbitrary quantum measurements. So this is all you absolutely need to know about measurement, from an in-principle point of view.

 It’s useful to have a way of denoting measurements in the quantum circuit model. Here’s a simple example:

 It’s a single-qubit quantum circuit, with input the state ∣ψ⟩|\psi\rangle ∣ ψ ⟩ . A NOT gate is applied, followed by a Hadamard gate. The circuit finishes with a measurement in the computational basis, denoted by the slightly elongated semi-circle. The mm m is a classical bit denoting the measurement result – either 00 0 or 11 1 – and we use the double wire to indicate the classical bit mm m going off and being used to do something else.

 Of course, I said above that after measurement the qubit is in either the ∣0⟩|0\rangle ∣ 0 ⟩ or the ∣1⟩|1\rangle ∣ 1 ⟩ state. You might think we’d draw a corresponding quantum wire coming out the other side of the measurement. But often in quantum circuits the qubit is discarded after measurement, and that’s assumed by this notation.

 One final comment on measurement is that it’s connected to the normalization condition for quantum states that we discussed earlier. Suppose we have the quantum state:

 α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩

 Then the probability of the two possible measurement outcomes, 00 0 and 11 1 , must sum to 11 1 , and so we have:

 ∣α∣2+∣β∣2=1.|\alpha|^2+|\beta|^2 = 1. ∣ α ∣ 2 + ∣ β ∣ 2 = 1 .

 This is exactly the normalization condition for quantum states – i.e., the quantum state must have length 11 1 . The origin of that constraint is really just the fact that measurement probabilities must add up to 11 1 .

 Exercise: Suppose we’ve been given either the state ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ or the state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ , but not told which state we’ve been given. We’d like to figure out which state we’ve been given. If we just do a computational basis measurement, then for both states we get outcome 00 0 with probability 12\frac 12 2 1 ​ , and outcome 11 1 with probability 12\frac 12 2 1 ​ . So we can’t distinguish the states directly using a computational basis measurement. But suppose instead we put the state into the following circuit:

 Show that if the state ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ is input then the output is m=0m = 0 m = 0 with probability 11 1 , while if the state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2} 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ is input then the output is m=1m = 1 m = 1 with probability 11 1 . Thus while these two states are indistinguishable if just measured in the computational basis, they can be distinguished with the help of a simple quantum circuit.

 Didn’t rememberRemembered

 General single-qubit gates

 So far we’ve learned about two quantum gates, the NOT and the Hadamard gate, and also about the measurement process that can be used to extract classical information from our quantum circuits. In this section, I return to quantum gates, and take a look at the most general single-qubit gate. To do that it helps to recall the matrix representations of the NOT and Hadamard gates:

 X=[0110]; H=12[111−1]\begin{aligned} X = \left[ \begin{array}{cc} 0 & 1 \\ 1 & 0 \end{array} \right]; \,\,\,\, H = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right] \end{aligned} X = [ 0 1 ​ 1 0 ​ ] ; H = 2 ​ 1 ​ [ 1 1 ​ 1 − 1 ​ ] ​

 If the input to these gates is the quantum state ∣ψ⟩|\psi\rangle ∣ ψ ⟩ , then the output is X∣ψ⟩X|\psi\rangle X ∣ ψ ⟩ and H∣ψ⟩H|\psi\rangle H ∣ ψ ⟩ respectively.

 A general single-qubit gate works similarly. In particular, a general single-qubit gate can be represented as a 2×22 \times 2 2 × 2 unitary matrix, UU U . (If you’re rusty, I’ll remind you what it means for a matrix to be unitary in a moment, and you can just think of it as a matrix for now.) If the input to the gate is the state ∣ψ⟩|\psi\rangle ∣ ψ ⟩ then the output from the gate is U∣ψ⟩U|\psi\rangle U ∣ ψ ⟩ . And so the NOT and Hadamard gates correspond to the special cases where U=XU = X U = X and U=HU = H U = H , respectively.

 What does it mean for a matrix UU U to be unitary? It’s easiest to answer this question algebraically, where it simply means that U†U=IU^\dagger U = I U † U = I , that is, the adjoint of UU U , denoted U†U^\dagger U † , times UU U , is equal to the identity matrix. That adjoint is, recall, the complex transpose of UU U :

 U†:=(UT)∗.U^\dagger := (U^T)^*. U † : = ( U T ) ∗ .

 So for a 2×22 \times 2 2 × 2 matrix, the adjoint operation is just:

 [abcd]†=[a∗c∗b∗d∗].\left[ \begin{array}{cc} a & b \\ c & d \end{array} \right]^\dagger = \left[ \begin{array}{cc} a^* & c^* \\ b^* & d^* \end{array} \right]. [ a c ​ b d ​ ] † = [ a ∗ b ∗ ​ c ∗ d ∗ ​ ] .

 (Note that the †\dagger † is also sometimes called the dagger operation, or Hermitian conjugation, or just the conjugation operation. We’ll use all three terms on occasion.)

 There are a few basic questions you might ask: why are single-qubit gates described by unitary matrices? And how can we get an intuitive feel for what it means for a matrix to be unitary, anyway? While the equation U†U=IU^\dagger U = I U † U = I is easy to check algebraically, we’d like some intuition for what that equation means.

 Another natural question is whether the NOT gate and the Hadamard gate are unitary? Of course, we’ll see that they are – I wouldn’t have described them as quantum gates if not – but we should go to the trouble of checking.

 Yet another good question is whether there are useful examples of single-qubit gates that aren’t the NOT or Hadamard gates? The equation U†U=IU^\dagger U = I U † U = I is all very well, but it’d be nice to have more concrete examples than just an abstract equation.

 We’ll answer all these questions over the next few sections.

 Let’s start by checking the unitarity of the Hadamard gate. We start by computing the adjoint of HH H :

 H†=((12[111−1])T)∗.H^\dagger = \left( \left( \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 & 1 \\ 1 & -1 \end{array} \right]\right)^T\right)^*. H † = ( ( 2 ​ 1 ​ [ 1 1 ​ 1 − 1 ​ ] ) T ) ∗ .

 Note that taking the transpose doesn’t change the matrix, since it is already symmetric. And taking the complex conjugate doesn’t change anything, since all the entries are real. So we have H†=HH^\dagger = H H † = H , and thus H†H=HHH^\dagger H = HH H † H = H H . But we saw earlier in the essay that HH=IHH = I H H = I . So HH H is, indeed, unitary.

 Exercise: Show that XX X is unitary.

 Exercise: Show that the identity matrix II I is unitary.

 Exercise: Can you find an example of a 2×22 \times 2 2 × 2 matrix that is unitary, and is not II I , XX X , or HH H ?

 For flavor, let’s give a few more examples of single-qubit quantum gates. Earlier in the essay, I mentioned that the NOT gate XX X was introduced by the physicist Wolfgang Pauli in the early days of quantum mechanics. He introduced two other matrices, YY Y and ZZ Z , which are also useful quantum gates. The three gates, X,YX, Y X , Y , and ZZ Z are known collectively as the Pauli matrices. The YY Y and ZZ Z gates will be useful extra tools in our toolkit of quantum gates; in terms of the earlier analogy they expand the repertoire of moves we have available to us. They’re crucial, for example, in protocols such as quantum teleportation and quantum error correction.

 The YY Y gate is similar to the XX X gate, but instead of 11 1 s on the off-diagonal, it has ii i and −i-i − i , so it takes ∣0⟩|0\rangle ∣ 0 ⟩ to i∣1⟩i|1\rangle i ∣ 1 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ to −i∣0⟩-i|0\rangle − i ∣ 0 ⟩ :

 Y:=[0−ii0].Y := \left[ \begin{array}{cc} 0 & -i \\ i & 0 \end{array} \right]. Y : = [ 0 i ​ − i 0 ​ ] .

 The ZZ Z gate leaves ∣0⟩|0\rangle ∣ 0 ⟩ unchanged, and takes ∣1⟩|1\rangle ∣ 1 ⟩ to −∣1⟩-|1\rangle − ∣ 1 ⟩ :

 Z:=[100−1].Z := \left[ \begin{array}{cc} 1 & 0 \\ 0 & -1 \end{array} \right]. Z : = [ 1 0 ​ 0 − 1 ​ ] .

 Exercise: Show that the YY Y and ZZ Z matrices are unitary, and so legitimate quantum gates.

 Another good example of a quantum gate is a rotation, the kind of matrix you’ve most likely been seeing since high school. It’s just the ordinary rotation of the 22 2 - dimensional plane by an angle θ\theta θ :

 [cos⁡(θ)−sin⁡(θ)sin⁡(θ)cos⁡(θ)].\left[ \begin{array}{cc} \cos(\theta) & -\sin(\theta) \\ \sin(\theta) & \cos(\theta) \end{array} \right]. [ cos ( θ ) sin ( θ ) ​ − sin ( θ ) cos ( θ ) ​ ] .

 You can easily check that this is a unitary matrix, and so it’s valid quantum gate. And sometimes it’s a very useful quantum gate!

 That mostly wraps up our little library of single-qubit gates. In the next couple of sections we’ll build up some intuition about what unitarity means, but we won’t add any extra elements to our quantum computing model. In fact, at this point we know almost everything needed for quantum computation. There are just two extra elements needed: extending our description of single qubits to multiple qubits, and describing a simple two-qubit quantum gate. We’ll get to those things shortly – not surprisingly, they look much like what we’ve already seen.

 Didn’t rememberRemembered

 I am, by the way, somewhat uncomfortable with some of the questions just asked. My personal experience is that spaced-repetition learning works well when learning facts I have a lot of context for, and care a lot about. It’s a rare person who finds the detailed entries in a unitary matrix fascinating! That’s not to say they aren’t – actually, they are, but you need a lot more context than I’ve provided to see why (for instance) that −i-i − i in the YY Y is just so darn interesting.

 With that said, this essay is genuinely an experiment, and the questions above are included in that spirit. Maybe it will turn out that readers can use spaced-repetition to learn the entries of unitary matrices. And maybe they cannot. No matter which that’ll be a valuable thing to learn about the world, and to inform future experiments with spaced-repetition learning.

 What does it mean for a matrix to be unitary?

 Can we get an intuition for what it means for a matrix to be unitary? It turns out that unitary matrices preserve the length of their inputs. In other words, if we take any vector ∣ψ⟩|\psi\rangle ∣ ψ ⟩ and compute the length ∥U∣ψ⟩∥\| U|\psi\rangle \| ∥ U ∣ ψ ⟩ ∥ it’s always equal to the length ∥∣ψ⟩∥\||\psi\rangle\| ∥ ∣ ψ ⟩ ∥ of the original vector. In this, they’re much like rotations or reflections in ordinary (real) space, which also don’t change lengths. In a sense, the unitary matrices are a complex generalization of real rotations and reflections.

 Up to now we’ve been dealing mostly with vectors which are states of qubits, i.e., normalized 2-dimensional vectors. But in fact the statement of the last paragraph is true for d×dd \times d d × d unitary matrices, too, i.e., ∥U∣ψ⟩∥=∥∣ψ⟩∥\|U|\psi\rangle\| = \||\psi\rangle\| ∥ U ∣ ψ ⟩ ∥ = ∥ ∣ ψ ⟩ ∥ is true for any vector ∣ψ⟩|\psi\rangle ∣ ψ ⟩ in dd d dimensions.

 The proof is actually pretty simple – mostly, we just compute ∥U∣ψ⟩∥\|U|\psi\rangle \| ∥ U ∣ ψ ⟩ ∥ and use a little algebra to check that it’s equal to the length ∥∣ψ⟩∥\||\psi\rangle\| ∥ ∣ ψ ⟩ ∥ . But before we get to the proof, observe that this result is good news for quantum gates. The reason is that in a quantum gate the input state will be normalized (have length 11 1 ) , since that’s a requirement for a quantum state. And we’d expect the corresponding output state to also be normalized, otherwise it wouldn’t be a legitimate quantum state. Fortunately, the length-preserving property of unitary matrices ensures the output state is properly normalized.

 Recall also the larger story this is part of: not only are gates unitary, to ensure that states remain normalized; also, quantum states are normalized, since measurement probabilities must sum to 11 1 . It all fits together.

 In fact it turns out that unitary matrices are the only matrices which preserve length in this way. And so a good way of thinking about unitary matrices is that they’re exactly the class of matrices which preserve length. That’s the geometric interpretation (and intuitive meaning) of the algebraic condition U†U=IU^\dagger U = I U † U = I .

 Let’s prove now that unitary matrices really are length-preserving.

 The proof is straightforward. The main thing is to compute ∥U∣ψ⟩∥\|U|\psi\rangle\| ∥ U ∣ ψ ⟩ ∥ . Actually, it’s a little easier to compute the square of the length, ∥U∣ψ⟩∥2\|U|\psi\rangle\|^2 ∥ U ∣ ψ ⟩ ∥ 2 . This is just the sum of the squares of the absolute values of the components of the vector U∣ψ⟩U|\psi\rangle U ∣ ψ ⟩ :

 ∥U∣ψ⟩∥2=∑j(Uψ)j∗(Uψ)j\|U|\psi\rangle\|^2 = \sum_j (U\psi)_j^* (U\psi)_j ∥ U ∣ ψ ⟩ ∥ 2 = j ∑ ​ ( U ψ ) j ∗ ​ ( U ψ ) j ​

 Note that I’ve used (Uψ)j(U\psi)_j ( U ψ ) j ​ to denote the jj j t h component of U∣ψ⟩U|\psi\rangle U ∣ ψ ⟩ , dropping the full ket notation, and just using ψ\psi ψ alone. To proceed, we’ll expand the equation above out, and look for opportunities to apply the unitarity of UU U . In particular, the component (Uψ)j(U\psi)_j ( U ψ ) j ​ is given by ∑lUjlψl\sum_l U_{jl} \psi_l ∑ l ​ U j l ​ ψ l ​ and similarly for the complex conjugate term. So we can rewrite the above equation as:

 ∥U∣ψ⟩∥2=∑jklUjk∗ψk∗Ujlψl\|U|\psi\rangle\|^2 = \sum_{jkl} U_{jk}^*\psi_k^* U_{jl}\psi_l ∥ U ∣ ψ ⟩ ∥ 2 = j k l ∑ ​ U j k ∗ ​ ψ k ∗ ​ U j l ​ ψ l ​

 To make use of the unitarity of UU U we’ll move the UU U terms together, and rewrite in terms of U†U^\dagger U † . This gives

 ∥U∣ψ⟩∥2=∑jklUkj†Ujlψk∗ψl,\|U|\psi\rangle\|^2 = \sum_{jkl} U_{kj}^\dagger U_{jl} \psi_k^* \psi_l, ∥ U ∣ ψ ⟩ ∥ 2 = j k l ∑ ​ U k j † ​ U j l ​ ψ k ∗ ​ ψ l ​ ,

 where we interchanged the jkjk j k indices on the first UU U in order to rewrite it in terms of U†U^\dagger U † . The only place the jj j index appears anywhere in this equation is in the Ukj†UjlU_{kj}^\dagger U_{jl} U k j † ​ U j l ​ term. We can therefore perform the sum over jj j and those terms become (U†U)kl(U^\dagger U)_{kl} ( U † U ) k l ​ , which is just the klkl k l t h term in the identity matrix, since U†U=IU^\dagger U = I U † U = I . So the above equation becomes:

 ∥U∣ψ⟩∥2=∑klδklψk∗ψl.\|U|\psi\rangle\|^2 = \sum_{kl} \delta_{kl} \psi_k^* \psi_l. ∥ U ∣ ψ ⟩ ∥ 2 = k l ∑ ​ δ k l ​ ψ k ∗ ​ ψ l ​ .

 When we sum, the only time δkl\delta_{kl} δ k l ​ is not equal to zero is when k=lk=l k = l , in which case it’s 11 1 . And so we can get rid of one of the summation indices, and the equation simplifies to:

 ∥U∣ψ⟩∥2=∑kψk∗ψk.\|U|\psi\rangle\|^2 = \sum_{k} \psi_k^* \psi_k. ∥ U ∣ ψ ⟩ ∥ 2 = k ∑ ​ ψ k ∗ ​ ψ k ​ .

 The right-hand side is, of course, equal to the norm of ∣ψ⟩|\psi\rangle ∣ ψ ⟩ squared. And so we’ve shown ∥U∣ψ⟩∥2=∥∣ψ⟩∥2\|U|\psi\rangle\|^2 = \||\psi\rangle\|^2 ∥ U ∣ ψ ⟩ ∥ 2 = ∥ ∣ ψ ⟩ ∥ 2 , and therefore ∥U∣ψ⟩∥=∥∣ψ⟩∥\|U|\psi\rangle\| = \||\psi\rangle\| ∥ U ∣ ψ ⟩ ∥ = ∥ ∣ ψ ⟩ ∥ . That completes the proof that unitary matrices are length-preserving. QED

 In fact, as I mentioned earlier, it’s also possible to prove that unitary matrices are the only matrices which preserve lengths in this way. Let me state that a little more precisely:

 Theorem: Let MM M be a matrix. Then ∥M∣ψ⟩∥=∥∣ψ⟩∥\|M|\psi\rangle \| = \||\psi\rangle\| ∥ M ∣ ψ ⟩ ∥ = ∥ ∣ ψ ⟩ ∥ for all vectors ∣ψ⟩|\psi\rangle ∣ ψ ⟩ if and only if MM M is unitary.

 We’ve proved one half of this already; we’ll prove the other half in the next section. This theorem answers many of our questions from earlier: we see why quantum gates must be unitary, since they’re the only matrices which preserve normalization. Of course, it doesn’t completely answer the question, since it doesn’t tell us why quantum gates should be matrices (i.e., linear operations) in the first place. That fact we’re simply going to accept. In fact, it is possible to develop deeper levels of understanding of why that is true, but in this essay we’ll be satisfied with the partial explanation that unitary matrices are length-preserving.

 Didn’t rememberRemembered

 Why are unitaries the only matrices which preserve length?

 Alright, let’s prove the missing part from the last section: let’s show that unitaries are the only matrices which preserve length.

 The proof is a little messy. But it turns out to be a good way to get familiar with a few extra pieces of standard quantum mechanical terminology and notation. I’ll be frank: while these pieces of terminology are extremely useful in quantum computing, we don’t strictly need them elsewhere in this essay (though we will in later essays). If you want to skip the section, or skim it, that’s okay – this is the best section of the essay to skip. But at some point you should come back and work through the material. And there is, in any case, a certain beauty to the proof.

 We’ve been dealing with 2-dimensional vectors up to now, but what I’m about to say applies no matter how many dimensions we’re working in. So suppose we have a vector ∣ψ⟩|\psi\rangle ∣ ψ ⟩ which can be written in component form as:

 ∣ψ⟩=[ab⋮z].|\psi\rangle = \left[ \begin{array}{c} a \\ b \\ \vdots \\ z \end{array} \right]. ∣ ψ ⟩ = ⎣ ⎢ ⎢ ⎢ ⎡ ​ a b ⋮ z ​ ⎦ ⎥ ⎥ ⎥ ⎤ ​ .

 We’re going to define a new object, also labeled with a ψ\psi ψ , but now with a bracket in the other direction:

 ⟨ψ∣:=[a∗b∗…z∗].\langle \psi| := [a^* b^* \dots z^*]. ⟨ ψ ∣ : = [ a ∗ b ∗ … z ∗ ] .

 That is, ⟨ψ∣\langle\psi| ⟨ ψ ∣ is a row vector, whose entries are the same as ∣ψ⟩|\psi\rangle ∣ ψ ⟩ , but complex conjugated. The vector ∣ψ⟩|\psi\rangle ∣ ψ ⟩ was called a ket, and (you’re going to groan) ⟨ψ∣\langle \psi| ⟨ ψ ∣ is called a bra, making this the bra-ket, or bracket notation. Yes, theoretical physicists make dad jokes, too. These names were given by the theoretical physicist Paul Dirac in 1939, and it’s often called the Dirac bra-ket notation, or sometimes just the Dirac notation.

 A key fact about the bra ⟨ψ∣\langle \psi| ⟨ ψ ∣ is that it’s related to the ket ∣ψ⟩|\psi\rangle ∣ ψ ⟩ by the dagger operation:

 ∣ψ⟩†=⟨ψ∣.|\psi\rangle^\dagger = \langle \psi|. ∣ ψ ⟩ † = ⟨ ψ ∣ .

 It’s easy to see why this identity is true. Take the vector

 ∣ψ⟩=[ab⋮z],|\psi\rangle = \left[ \begin{array}{c} a \\ b \\ \vdots \\ z \end{array} \right], ∣ ψ ⟩ = ⎣ ⎢ ⎢ ⎢ ⎡ ​ a b ⋮ z ​ ⎦ ⎥ ⎥ ⎥ ⎤ ​ ,

 and apply the dagger operation, which means taking the transpose, turning it into a row vector with entries a,b,…,za, b, \ldots, z a , b , … , z , and then take the complex conjugate, giving us [a∗b∗…z∗][a^* b^* \ldots z^*] [ a ∗ b ∗ … z ∗ ] , which is just the definition of ⟨ψ∣\langle \psi| ⟨ ψ ∣ .

 In a similar way we see that ⟨ψ∣†=∣ψ⟩\langle \psi|^\dagger = |\psi\rangle ⟨ ψ ∣ † = ∣ ψ ⟩ .

 Another useful identity expresses the length of ∣ψ⟩|\psi\rangle ∣ ψ ⟩ in terms of the Dirac notation:

 ∥∣ψ⟩∥2=⟨ψ∣∣ψ⟩.\||\psi\rangle\|^2 = \langle \psi| |\psi\rangle. ∥ ∣ ψ ⟩ ∥ 2 = ⟨ ψ ∣ ∣ ψ ⟩ .

 That is, the length squared is just equal to the product of the row vector ⟨ψ∣\langle \psi| ⟨ ψ ∣ with the column vector ∣ψ⟩|\psi\rangle ∣ ψ ⟩ . To prove it just notice that the right-hand side is

 [a∗b∗…][ab⋮]=∣a∣2+∣b∣2+…[a^* b^* \ldots ] \left[ \begin{array}{c} a \\ b \\ \vdots \end{array} \right] = |a|^2 + |b|^2 + \ldots [ a ∗ b ∗ … ] ⎣ ⎢ ⎡ ​ a b ⋮ ​ ⎦ ⎥ ⎤ ​ = ∣ a ∣ 2 + ∣ b ∣ 2 + …

 And that, of course, is ∥∣ψ⟩∥2\||\psi\rangle\|^2 ∥ ∣ ψ ⟩ ∥ 2 , just as we wanted.

 Physicists using the Dirac notation don’t usually write ⟨ψ∣∣ψ⟩\langle \psi| |\psi\rangle ⟨ ψ ∣ ∣ ψ ⟩ . They simplify it slightly, omitting one of the vertical bars ∣| ∣ in the middle, and just write it as:

 ⟨ψ∣ψ⟩.\langle \psi| \psi \rangle. ⟨ ψ ∣ ψ ⟩ .

 It’s only a slight simplification, but this omission of the extra bar turns out to make life considerably easier, and is well worth it. I’ve shown it above just for the special case of ⟨ψ∣ψ⟩\langle \psi| \psi \rangle ⟨ ψ ∣ ψ ⟩ but the same omission of a vertical bar is done often in other contexts. In practice, it rarely causes confusion, although of course you do need to get used to it.

 Another useful identity is that if MM M is a matrix and ∣ψ⟩|\psi\rangle ∣ ψ ⟩ is a ket, then

 (M∣ψ⟩)†=⟨ψ∣M†.(M|\psi\rangle)^\dagger = \langle \psi|M^\dagger. ( M ∣ ψ ⟩ ) † = ⟨ ψ ∣ M † .

 If you think of ⟨ψ∣\langle \psi| ⟨ ψ ∣ as the dagger of ∣ψ⟩|\psi\rangle ∣ ψ ⟩ , then what this equation means is that taking the dagger of the product M∣ψ⟩M|\psi\rangle M ∣ ψ ⟩ is the same as taking the product of the dagger of MM M with the dagger ∣ψ⟩|\psi\rangle ∣ ψ ⟩ , but reversing the order. This is a useful little mnemonic for remembering the above identity.

 The identity is easy to prove. As a challenge to yourself you might want to stop right now and take a shot at proving it. Here’s the details if you get stuck.

 Proof: The way to prove the identity is to apply the definitions. We’re going to look at the jj j t h component of the left-hand side, (M∣ψ⟩)j†(M|\psi\rangle)^\dagger_j ( M ∣ ψ ⟩ ) j † ​ , and we’ll show it’s equal to the jj j t h component of the right-hand side. By definition, the jj j t h row component (M∣ψ⟩)j†(M|\psi\rangle)^\dagger_j ( M ∣ ψ ⟩ ) j † ​ is equal to the complex conjugate of the jj j t h column component of M∣ψ⟩M|\psi\rangle M ∣ ψ ⟩ , i.e., (M∣ψ⟩)j∗(M|\psi\rangle)^*_j ( M ∣ ψ ⟩ ) j ∗ ​ . That column component is ∑kMjk∗ψk∗\sum_k M_{jk}^* \psi_k^* ∑ k ​ M j k ∗ ​ ψ k ∗ ​ . We can move the ψ\psi ψ terms to the left, and swap the indices on the MM M term to convert the ∗* ∗ to a dagger, giving ∑kψk∗Mkj†\sum_k \psi_k^* M_{kj}^\dagger ∑ k ​ ψ k ∗ ​ M k j † ​ . That’s just the jj j t h component of the row vector ⟨ψ∣M†\langle \psi|M^\dagger ⟨ ψ ∣ M † , as we set out to show. QED

 With all these ideas in mind, here’s an exercise for you to work through, putting several of these ideas together:

 Exercise: Show that for any matrix MM M and vector ∣ψ⟩|\psi\rangle ∣ ψ ⟩ , the following identity holds, expressing the length of M∣ψ⟩M|\psi\rangle M ∣ ψ ⟩ :

 ∥M∣ψ⟩∥2=⟨ψ∣M†M∣ψ⟩.\|M|\psi\rangle\|^2 = \langle\psi|M^\dagger M |\psi\rangle. ∥ M ∣ ψ ⟩ ∥ 2 = ⟨ ψ ∣ M † M ∣ ψ ⟩ .

 You may be wondering why we care about all these identities? Of course, really I’m just frontloading them – they’re all identities we’re going to find useful in a moment in the proof. So in some sense they are a bit ad hoc in motivation. But an underlying theme is that they’re about relating lengths to matrix operations. And it’s not so surprising that’s of interest – we’re going to assume we have a length-preserving operation. It’s very convenient to be able to relate that property to familiar operations about matrix multiplication. That’s the essential source of the interest in the above identities.

 Alright, we’ve been working through some heavy, detailed material. We’ve got just a little more background to get through, but it’s easier going. I’m going to introduce a unit vector, denoted ∣ej⟩|e_j\rangle ∣ e j ​ ⟩ , meaning the vector with a 11 1 in the jj j t h component, and 00 0 s everywhere else. So, for instance, for a qubit:

 ∣e0⟩=[10]∣e1⟩=[01]\begin{aligned} |e_0\rangle & = \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \\ |e_1\rangle & = \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] \end{aligned} ∣ e 0 ​ ⟩ ∣ e 1 ​ ⟩ ​ = [ 1 0 ​ ] = [ 0 1 ​ ] ​

 From elementary linear algebra, if MM M is a matrix, then M∣ek⟩M|e_k\rangle M ∣ e k ​ ⟩ is just the kk k t h column of MM M . (If you don’t recall that from elementary linear algebra, I encourage you to stop and figure out why it’s true.) And from that you can deduce easily that ⟨ej∣M∣ek⟩\langle e_j|M|e_k\rangle ⟨ e j ​ ∣ M ∣ e k ​ ⟩ is the jkjk j k t h entry of MM M .

 Exercise: If you’re not familiar with the proof, show that M∣ek⟩M|e_k\rangle M ∣ e k ​ ⟩ is the kk k t h column of the matrix MM M , and that ⟨ej∣M∣ek⟩\langle e_j|M|e_k\rangle ⟨ e j ​ ∣ M ∣ e k ​ ⟩ is the jkjk j k t h entry of MM M .

 Alright, that’s more than enough notational background! Let’s get to the main event. In particular, let’s recall the statement of the theorem we want to complete the proof of. Also recall that we proved the reverse implication in the last section, so we just need to prove the forward implication:

 Theorem: Let MM M be a matrix. Then ∥M∣ψ⟩∥=∥∣ψ⟩∥\|M|\psi\rangle \| = \| |\psi\rangle\| ∥ M ∣ ψ ⟩ ∥ = ∥ ∣ ψ ⟩ ∥ for all vectors ∣ψ⟩|\psi\rangle ∣ ψ ⟩ if and only if MM M is unitary.

 Proof: We’ll assume MM M is length-preserving, and analyze the matrix M†MM^\dagger M M † M . Our goal is to show that this is the identity matrix, and thus MM M is unitary. To do this, we’re going to start by analyzing the diagonal elements (M†M)jj(M^\dagger M)_{jj} ( M † M ) j j ​ , and show that they’re all equal to 11 1 . Then we’ll turn our attention to the off-diagonal elements and show that they’re all equal to 00 0 .

 To understand the diagonal elements, we know from earlier that: (M†M)jj=⟨ej∣M†M∣ej⟩=∥M∣ej⟩∥2(M^\dagger M)_{jj} = \langle e_j|M^\dagger M|e_j\rangle = \|M|e_j\rangle\|^2 ( M † M ) j j ​ = ⟨ e j ​ ∣ M † M ∣ e j ​ ⟩ = ∥ M ∣ e j ​ ⟩ ∥ 2 . But since MM M is length-preserving, the latter is just ∥∣ej⟩∥2\||e_j\rangle\|^2 ∥ ∣ e j ​ ⟩ ∥ 2 , which is 11 1 . And so we conclude that all the diagonal elements are, indeed, 11 1 .

 What about the off-diagonal elements, i.e., (M†M)jk(M^\dagger M)_{jk} ( M † M ) j k ​ where j≠kj \neq k j  ​ = k ? Can we show that these are all equal to 00 0 ? Well, what we’d like to do is somehow to relate (M†M)jk(M^\dagger M)_{jk} ( M † M ) j k ​ to the length of some vector M∣ψ⟩M|\psi\rangle M ∣ ψ ⟩ , and then use the length-preserving property. One idea is to try using ∣ψ⟩=∣ej⟩+∣ek⟩|\psi\rangle = |e_j\rangle + |e_k\rangle ∣ ψ ⟩ = ∣ e j ​ ⟩ + ∣ e k ​ ⟩ , since that involves both the jj j t h and kk k t h directions. From the length-preserving property we have:

 ∥M∣ψ⟩∥2=∥∣ψ⟩∥2=12+12=2.\|M|\psi\rangle\|^2 = \| |\psi\rangle\|^2 = 1^2+1^2 = 2. ∥ M ∣ ψ ⟩ ∥ 2 = ∥ ∣ ψ ⟩ ∥ 2 = 1 2 + 1 2 = 2 .

 We also have:

 ∥M∣ψ⟩∥2=⟨ψ∣M†M∣ψ⟩=⟨ej∣M†M∣ej⟩+⟨ej∣M†M∣ek⟩==+⟨ek∣M†M∣ej⟩+⟨ek∣M†M∣ek⟩=1+⟨ej∣M†M∣ek⟩+⟨ek∣M†M∣ej⟩+1\begin{aligned} \|M|\psi\rangle\|^2 & = \langle \psi| M^\dagger M |\psi\rangle \\ & = \langle e_j|M^\dagger M|e_j\rangle + \langle e_j|M^\dagger M|e_k\rangle \\ & \hphantom{ == } + \langle e_k|M^\dagger M|e_j\rangle + \langle e_k|M^\dagger M |e_k\rangle \\ & = 1 + \langle e_j|M^\dagger M|e_k\rangle + \langle e_k|M^\dagger M|e_j\rangle + 1 \end{aligned} ∥ M ∣ ψ ⟩ ∥ 2 ​ = ⟨ ψ ∣ M † M ∣ ψ ⟩ = ⟨ e j ​ ∣ M † M ∣ e j ​ ⟩ + ⟨ e j ​ ∣ M † M ∣ e k ​ ⟩ = = + ⟨ e k ​ ∣ M † M ∣ e j ​ ⟩ + ⟨ e k ​ ∣ M † M ∣ e k ​ ⟩ = 1 + ⟨ e j ​ ∣ M † M ∣ e k ​ ⟩ + ⟨ e k ​ ∣ M † M ∣ e j ​ ⟩ + 1 ​

 Comparing the last two sets of equations, we have:

 ⟨ej∣M†M∣ek⟩+⟨ek∣M†M∣ej⟩=0.\langle e_j|M^\dagger M|e_k\rangle + \langle e_k|M^\dagger M|e_j\rangle = 0. ⟨ e j ​ ∣ M † M ∣ e k ​ ⟩ + ⟨ e k ​ ∣ M † M ∣ e j ​ ⟩ = 0 .

 This is close to what we want, but isn’t quite right. It tells us that (M†M)jk+(M†M)kj=0(M^\dagger M)_{jk} + (M^\dagger M)_{kj} = 0 ( M † M ) j k ​ + ( M † M ) k j ​ = 0 . Can we do better? It’s tempting to go back and fiddle around and try to find some way of eliminating one or the other of those terms. But there’s no direct way to do it – at least, no direct way that I know of.

 But what if we’d done something slightly different, and instead of using ∣ψ⟩=∣ej⟩+∣ek⟩|\psi\rangle = |e_j\rangle+|e_k\rangle ∣ ψ ⟩ = ∣ e j ​ ⟩ + ∣ e k ​ ⟩ we’d used ∣ψ⟩=∣ej⟩+i∣ek⟩|\psi\rangle = |e_j\rangle+i|e_k\rangle ∣ ψ ⟩ = ∣ e j ​ ⟩ + i ∣ e k ​ ⟩ ? It seems pretty plausible that following the same line of reasoning we’d get an equation involving (M†M)jk(M^\dagger M)_{jk} ( M † M ) j k ​ and (M†M)kj(M^\dagger M)_{kj} ( M † M ) k j ​ again. I won’t explicitly go through the steps – you can do that yourself – but if you do go through them you end up with the equation:

 (M†M)jk−(M†M)kj=0.(M^\dagger M)_{jk} - (M^\dagger M)_{kj} = 0. ( M † M ) j k ​ − ( M † M ) k j ​ = 0 .

 This is great! We can add it to the earlier equation to deduce that (M†M)jk=0(M^\dagger M)_{jk} = 0 ( M † M ) j k ​ = 0 whenever j≠kj \neq k j  ​ = k , and so we conclude that M†M=IM^\dagger M = I M † M = I , i.e., MM M is unitary. QED

 Didn’t rememberRemembered

 The controlled-NOT gate

 We’ve developed most of the ideas needed to do universal quantum computing. We understand qubits, quantum states, and have a repertoire of quantum gates. However, all our gates involve just a single qubit. To compute, we need some way for qubits to interact with one another. That is, we need quantum gates which involve two (or more) qubits.

 An example of such a gate is the controlled-NOT (or CNOT) gate. In the quantum circuit language we have two wires, representing two qubits, and the following notation to represent the CNOT gate:

 The wire with the small, filled dot on it (the top wire, in this example) is called the control qubit, for reasons which will become clear in a moment. And the wire with the larger, unfilled circle on it is called the target qubit.

 Up to now I haven’t said what the possible states of a two-qubit system are, but you can probably guess. We now have four computational basis states, corresponding to the four possible states of a two-bit system: ∣00⟩,∣01⟩,∣10⟩|00\rangle, |01\rangle, |10\rangle ∣ 0 0 ⟩ , ∣ 0 1 ⟩ , ∣ 1 0 ⟩ , and ∣11⟩|11\rangle ∣ 1 1 ⟩ . And, for a two-qubit system, not only can we have those four states, we can also have superpositions (i.e., linear combinations) of them:

 α∣00⟩+β∣01⟩+γ∣10⟩+δ∣11⟩\alpha|00\rangle+\beta|01\rangle+\gamma |10\rangle+\delta|11\rangle α ∣ 0 0 ⟩ + β ∣ 0 1 ⟩ + γ ∣ 1 0 ⟩ + δ ∣ 1 1 ⟩

 Here, the amplitudes α,β,γ,δ\alpha, \beta, \gamma, \delta α , β , γ , δ are just complex numbers, and the sum of the squares of the absolute values is 11 1 , i.e, ∣α∣2+∣β∣2+∣γ∣2+∣δ∣2=1|\alpha|^2+|\beta|^2+|\gamma|^2+|\delta|^2 = 1 ∣ α ∣ 2 + ∣ β ∣ 2 + ∣ γ ∣ 2 + ∣ δ ∣ 2 = 1 . This is the same kind of normalization condition as we had for a single qubit.

 Now, the CNOT gate is, much like the quantum NOT gate, inspired directly by a classical gate. What it does is very simple. If the control qubit is set to 11 1 , as in the states ∣10⟩|10\rangle ∣ 1 0 ⟩ and ∣11⟩|11\rangle ∣ 1 1 ⟩ , then it flips (i.e., NOTs) the target qubit. And otherwise it does nothing. Writing out the action on all four computational basis states we have:

 ∣00⟩→∣00⟩∣01⟩→∣01⟩∣10⟩→∣11⟩∣11⟩→∣10⟩\begin{aligned} |00\rangle & \rightarrow & |00\rangle \\ |01\rangle & \rightarrow & |01\rangle \\ |10\rangle & \rightarrow & |11\rangle \\ |11\rangle & \rightarrow & |10\rangle \end{aligned} ∣ 0 0 ⟩ ∣ 0 1 ⟩ ∣ 1 0 ⟩ ∣ 1 1 ⟩ ​ → → → → ​ ∣ 0 0 ⟩ ∣ 0 1 ⟩ ∣ 1 1 ⟩ ∣ 1 0 ⟩ ​

 If you’re familiar with classical programming languages, then you can think of the CNOT as a very simple kind of if-then statement: if the control qubit is set, then NOT the target qubit. But while simple, it can be used as a building block to build up other, more complex kinds of conditional behavior.

 There’s a way of summing up all four of the equations above in a single equation. Suppose xx x and yy y are classical bits, i.e., 00 0 or 11 1 . Then we can rewrite the equations above in a single equation as:

 ∣x,y⟩→∣x,y⊕x⟩.\begin{aligned} |x, y\rangle & \rightarrow & |x, y\oplus x\rangle. \end{aligned} ∣ x , y ⟩ ​ → ​ ∣ x , y ⊕ x ⟩ . ​

 Note the commas inserted to make this easier to read – this is pretty common in working with multi-qubit states.

 The above equation makes clear that the CNOT leaves the control qubit xx x alone, but flips the target qubit yy y if xx x is set to 11 1 . Note that ⊕\oplus ⊕ is addition modulo 22 2 , where 1⊕1=01 \oplus 1 = 0 1 ⊕ 1 = 0 , as we would expect from the fact that the CNOT takes ∣11⟩|11\rangle ∣ 1 1 ⟩ to ∣10⟩|10\rangle ∣ 1 0 ⟩ .

 That’s all there is to the CNOT. It’s really a very simple idea and quantum gate. Note that it of course acts linearly on superpositions of computational basis states, as we expect for a quantum gate. So:

 →α∣00⟩+β∣01⟩+γ∣10⟩+δ∣11⟩→α∣00⟩+β∣01⟩+γ∣11⟩+δ∣10⟩\begin{aligned} & \hphantom{ \rightarrow } \alpha|00\rangle+\beta|01\rangle+\gamma |10\rangle+\delta|11\rangle \\ & \rightarrow \alpha|00\rangle+\beta|01\rangle+\gamma |11\rangle+\delta|10\rangle \end{aligned} ​ → α ∣ 0 0 ⟩ + β ∣ 0 1 ⟩ + γ ∣ 1 0 ⟩ + δ ∣ 1 1 ⟩ → α ∣ 0 0 ⟩ + β ∣ 0 1 ⟩ + γ ∣ 1 1 ⟩ + δ ∣ 1 0 ⟩ ​

 And, though I won’t explicitly carry out the verification, the CNOT is unitary, and thus preserves the length of quantum states, as we expect.

 Of course, the CNOT doesn’t just appear in two-qubit computations. It also appears in computations involving more qubits. Let’s suppose we have three qubits, for instance, and computational basis states such as ∣000⟩,∣001⟩|000\rangle, |001\rangle ∣ 0 0 0 ⟩ , ∣ 0 0 1 ⟩ , and so on. Here’s a CNOT with the second qubit as the control qubit and the third qubit as the target:

 What goes on? Well, we can write out what happens on an arbitrary computational basis state, ∣x,y,z⟩|x, y, z\rangle ∣ x , y , z ⟩ , where x,yx, y x , y and zz z are all classical bits. Of course, the first bit xx x isn’t changed at all, since it’s not involved in the CNOT. The second bit yy y is the control bit, and so isn’t changed. But the third bit zz z is flipped if the control bit yy y is set to 11 1 . And so we can write the action of the CNOT as:

 ∣x,y,z⟩→∣x,y,z⊕y⟩|x,y,z\rangle \rightarrow |x,y, z\oplus y\rangle ∣ x , y , z ⟩ → ∣ x , y , z ⊕ y ⟩

 I’ve described the CNOT as a “classical” gate, but it can be combined with single-qubit gates to do non-classical things. Let me give you an explicit example. It’s another two-qubit computation. It starts with the ∣00⟩|00\rangle ∣ 0 0 ⟩ computational basis state, we apply a Hadamard gate to the first qubit, and then do a CNOT:

 Recall that for a single qubit the Hadamard gate takes ∣0⟩|0\rangle ∣ 0 ⟩ to an equal superposition (∣0⟩+∣1⟩)/2(|0\rangle+|1\rangle)/\sqrt{2} ( ∣ 0 ⟩ + ∣ 1 ⟩ ) / 2 ​ . For these two qubits it doesn’t affect the second qubit at all, and so it takes ∣00⟩|00\rangle ∣ 0 0 ⟩ to (∣00⟩+∣10⟩)/2(|00\rangle+|10\rangle)/\sqrt{2} ( ∣ 0 0 ⟩ + ∣ 1 0 ⟩ ) / 2 ​ .

 Next we apply the CNOT gate. This leaves the ∣00⟩|00\rangle ∣ 0 0 ⟩ state unchanged, since the control bit is 00 0 . And it takes ∣10⟩|10\rangle ∣ 1 0 ⟩ to ∣11⟩|11\rangle ∣ 1 1 ⟩ , since the control bit is 11 1 . And so the output from the circuit is:

 ∣00⟩+∣11⟩2.\frac{|00\rangle+|11\rangle}{\sqrt 2}. 2 ​ ∣ 0 0 ⟩ + ∣ 1 1 ⟩ ​ .

 This output state is a highly non-classical state – it’s actually a type of state called an entangled state. There’s no obvious interpretation of this state as a classical state, unlike say a computational basis state such as ∣00⟩|00\rangle ∣ 0 0 ⟩ . In fact, entangled states can be used to do all sorts of interesting information processing tasks, including quantum teleportation and fast quantum algorithms.

 A point I glossed over above, but worth mentioning: in the circuit I drew ∣0⟩|0\rangle ∣ 0 ⟩ and ∣0⟩|0\rangle ∣ 0 ⟩ separately as input qubits. It’s conventional to do that kind of thing to denote a combined input of ∣00⟩|00\rangle ∣ 0 0 ⟩ . More generally, people use ∣0⟩∣0⟩|0\rangle|0\rangle ∣ 0 ⟩ ∣ 0 ⟩ interchangeably with ∣00⟩|00\rangle ∣ 0 0 ⟩ , ∣0⟩∣1⟩|0\rangle|1\rangle ∣ 0 ⟩ ∣ 1 ⟩ interchangeably with ∣01⟩|01\rangle ∣ 0 1 ⟩ , and so on. Going back and forth takes a bit of getting used to, but everything works pretty much as you expect, and you just need a little practice before it seems quite natural.

 More generally, if we have single-qubit states α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle α ∣ 0 ⟩ + β ∣ 1 ⟩ and γ∣0⟩+δ∣1⟩\gamma|0\rangle+\delta|1\rangle γ ∣ 0 ⟩ + δ ∣ 1 ⟩ , then the combined state when the two qubits are put together is just:

 =(α∣0⟩+β∣1⟩)(γ∣0⟩+δ∣1⟩)=αγ∣00⟩+αδ∣01⟩+βγ∣10⟩+βδ∣11⟩.\begin{aligned} & \hphantom{ = } (\alpha|0\rangle+\beta|1\rangle)(\gamma|0\rangle+\delta|1\rangle) \\ & = \alpha\gamma|00\rangle+\alpha\delta |01\rangle+ \beta\gamma |10\rangle+ \beta\delta |11\rangle. \end{aligned} ​ = ( α ∣ 0 ⟩ + β ∣ 1 ⟩ ) ( γ ∣ 0 ⟩ + δ ∣ 1 ⟩ ) = α γ ∣ 0 0 ⟩ + α δ ∣ 0 1 ⟩ + β γ ∣ 1 0 ⟩ + β δ ∣ 1 1 ⟩ . ​

 I said that the CNOT leaves the control qubit alone, and modifies the target qubit. That’s true in the computational basis. In fact, it’s actually possible for the target qubit to affect the control qubit. It’s worth taking a minute or two to at least understand (and, if you’re feeling energetic, attempting to solve) the following exercise:

 Exercise: Can you find single-qubit states ∣a⟩|a\rangle ∣ a ⟩ and ∣b⟩|b\rangle ∣ b ⟩ so that applying a CNOT to the combined state ∣ab⟩|ab\rangle ∣ a b ⟩ changes the first qubit, i.e., the control qubit?

 Let me give you an example which solves the above exercise. Suppose we introduce single-qubit states ∣+⟩|+\rangle ∣ + ⟩ and ∣−⟩|-\rangle ∣ − ⟩ , defined by:

 ∣+⟩:=∣0⟩+∣1⟩2∣−⟩:=∣0⟩−∣1⟩2\begin{aligned} |+\rangle & := \frac{|0\rangle+|1\rangle}{\sqrt 2} \\ |-\rangle & := \frac{|0\rangle-|1\rangle}{\sqrt 2} \end{aligned} ∣ + ⟩ ∣ − ⟩ ​ : = 2 ​ ∣ 0 ⟩ + ∣ 1 ⟩ ​ : = 2 ​ ∣ 0 ⟩ − ∣ 1 ⟩ ​ ​

 A mnemonic for this notation is that these are both equal superpositions of ∣0⟩|0\rangle ∣ 0 ⟩ and ∣1⟩|1\rangle ∣ 1 ⟩ , but the “+” or “-” corresponds to the sign of the amplitude for the ∣1⟩|1\rangle ∣ 1 ⟩ state. The following circuit identity holds:

 That is, if we put ∣+−⟩|+-\rangle ∣ + − ⟩ in, then ∣−−⟩|--\rangle ∣ − − ⟩ comes out, i.e., the target qubit isn’t changed, but the control qubit is! The proof is just to follow the definitions and the algebra through. It’s honestly not terribly enlightening to follow the algebra through at this point – it’s a lot easier once certain other facts are known to you. But, again, if you’re feeling enthusiastic it’s a good exercise to work through to become familiar with how things work.

 It’s worth taking some caution from this example. It means that intuitions coming from the computational basis can sometimes be incomplete or misleading. The CNOT isn’t simply doing something to the target, conditional on the control. It’s also doing something to the control, conditional on the target.

 Exercise: Show that the inverse of the CNOT gate is just the CNOT gate.

 Didn’t rememberRemembered

 Part III: Universal quantum computing

 In natural science, Nature has given us a world and we’re just to discover its laws. In computers, we can stuff laws into it and create a world.

 — Alan Kay

 Let’s return to the question we began with: is there a single computing device that can efficiently simulate any other physical system? At the moment, the best candidate humanity has for such a computing device is a quantum computer. As you’ve probably guessed, you make such a device by combining all the elements we’ve been discussing. In Part III of this essay we’ll discuss what a quantum computer is, why they’re useful, and whether they can be used to efficiently simulate any other physical system.

 The quantum computing model

 The theory of computation has traditionally been studied almost entirely in the abstract, as a topic in pure mathematics. This is to miss the point of it. Computers are physical objects, and computations are physical processes. What computers can or cannot compute is determined by the laws of physics alone, and not by pure mathematics.

 — David Deutsch

 In a general quantum computation, you start out with many qubits – I’ll draw four here, but in general it might be many more (or less). You apply quantum gates of various kinds, in particular, single-qubit gates and CNOT gates. And at the end of the circuit you read out the result by measuring in the computational basis. Here’s what it all looks like:

 I haven’t labeled the single-qubit gates explicitly, but they might be various things – Hadamard gates, NOT gates, rotations, and perhaps others. Note also that while the computation starts in the computational basis state ∣0000⟩|0000\rangle ∣ 0 0 0 0 ⟩ , you can also start in some other computational basis state. I’ve just chosen ∣0000⟩|0000\rangle ∣ 0 0 0 0 ⟩ for definiteness.

 We can summarize the three steps in a quantum computation as follows:

 1. Start in a computational basis state.
 2. Apply a sequence of CNOT and single-qubit gates.
 3. To obtain the result, measure in the computational basis. The probability of any result, say 00…000\ldots 0 0 0 … 0 , is just the square of the absolute value of the corresponding amplitude.

 That’s all a general quantum computation is! If you understand this model, you know what a quantum computer is. It's pretty simple, really – enough so that I've sometimes heard people say “Is that all there is to it?” But while the model is simple, it contains remarkable depths, and exploring it could occupy many lifetimes.

 In practice, people sometimes introduce other ideas into the way they describe quantum computations. If you’re a programmer, you can think of this as like the way programming language designers introduce higher-level abstractions to help people design different kinds of programs. In principle, those abstractions can always be reduced down to the level of AND and NOT gates. And if you understand that level – AND and NOT, or the type of quantum circuit shown above – then you have a foundation for building an understanding of the other ideas.

 That may leave you wondering: does that mean you also need to master all the higher-level abstractions? The answer is no!

 There are several reasons for this. One reason is that, as we discussed earlier, humanity doesn’t yet know what the higher-level abstractions are. We’re still trying to figure them out. A second reason is that it seems likely that the list of higher-level abstractions is inexhaustible. My guess – and it’s just a guess – is that we will continue to discover beautiful new abstractions forever, in both classical and quantum computing.

 A related idea is that there are models of quantum computation different to the quantum circuit model. Some are merely small variations on the model I’ve described. For instance, instead of only using CNOT gates, we might allow any two-qubit unitary gate to be used in the circuit. Or perhaps instead of using qubits, we might use some other type of basic quantum system – say, the qutrit, which has three computational basis states, ∣0⟩,∣1⟩|0\rangle, |1\rangle ∣ 0 ⟩ , ∣ 1 ⟩ , and ∣2⟩|2\rangle ∣ 2 ⟩ . It probably won’t surprise you that the resulting models of computation are essentially equivalent to the quantum circuit model I’ve described. By this, I mean they can simulate the quantum circuit model (and vice versa) using roughly comparable numbers of gates and other physical resources.

 There are also much more exotic variations, ideas such as measurement-based quantum computation, topological quantum computation, and others. I won’t describe these in any detail here, but suffice to say that they appear superficially very different to the circuit model. Nonetheless, they’re all mathematically equivalent to one another, including to the quantum circuit model. Thus a quantum computation in any of those models can be translated into an equivalent in the quantum circuit model, with only a small overhead in the cost of computation. And vice versa.

 You may wonder why people bother thinking about other models, if they’re mathematically equivalent to the quantum circuit model. The reason is that just because two models are mathematically equivalent doesn’t mean they’re psychologically equivalent. Different models of computation stimulate different ways of thinking, and give rise to different ideas. And so it’s valuable to have other equivalent models.

 Exercise: We saw earlier that composition of quantum gates corresponds to matrix multiplication (in reverse order). Show that the product of two unitary matrices UU U and VV V is also unitary. As a consequence, the net effect of any quantum circuit (before measurement) is to effect a unitary operation on the state space of the system.

 Didn’t rememberRemembered

 Let me conclude this section with a brief comment about a particular class of quantum gates. These are gates which are multiples of the identity matrix, II I :

 [eiθ00eiθ]=eiθ[1001]=eiθI.\begin{aligned} \left[ \begin{array}{cc} e^{i\theta} & 0 \\ 0 & e^{i\theta} \end{array} \right] = e^{i\theta} \left[ \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right] = e^{i \theta} I. \end{aligned} [ e i θ 0 ​ 0 e i θ ​ ] = e i θ [ 1 0 ​ 0 1 ​ ] = e i θ I . ​

 When θ\theta θ is a real number this is a unitary matrix, and so a valid quantum gate. The effect of the gate is simply to multiply the state of the quantum computer by eiθe^{i\theta} e i θ . The number eiθe^{i\theta} e i θ is called a global phase factor. But even though the gate is valid, we rarely explicitly put such gates into quantum circuits. The reason is that such global phase factors have no impact on the results of the computation. To see why, imagine a quantum circuit which includes many such quantum gates, possibly for different values, θ1,θ2,…\theta_1, \theta_2, \ldots θ 1 ​ , θ 2 ​ , … . No matter where in the circuit the gates occur, the net effect is to multiply the state output from the circuit by an overall factor of eiθ1+iθ2+…e^{i \theta_1 + i\theta_2 + \ldots} e i θ 1 ​ + i θ 2 ​ + … . This doesn’t change the squared amplitudes of the computational basis states, and so has no impact on the measurement probabilities at the end of the computation. We could have left the gates out and it would make no difference.

 Quantum computing people tend to be rather blase about such global phase factors. They’ll do things like not bother to distinguish between unitary gates such as XX X and −X-X − X , saying these gates are “the same up to a global phase factor”. They simply mean the −X-X − X gate is the same as doing the XX X gate, followed by the −I-I − I gate. Since the latter gate makes no difference to the output from the computation, it can safely be omitted. We’ll see examples in the next essay, about the quantum search algorithm, where at a couple of places it makes sense to multiply the quantum state by a global phase factor of −1-1 − 1 .

 Didn’t rememberRemembered

 What are quantum computers good for?

 Now we know what a quantum computer is, what are they good for? Earlier, I suggested quantum computers expand the range of operations available when computing. This is similar to the way boats expand the range of ways we can traverse space, so instead of having to get from point A to point B by land,

 we can take a shortcut greatly cutting down the time required:

 In order for the analogous story to hold for quantum computers, they need to be at least as capable as classical computers. Fortunately, it’s possible to convert any classical circuit into a quantum circuit. This requires some care. The obvious thing to do is to imagine that your classical circuit is expressed in terms of some standard universal set – say, the AND and NOT gates – and then to convert those gates into equivalent quantum gates.

 This is easy to do with the NOT gate – we just turn it into an XX X gate. But what’s not so easy is the AND gate. You might wonder if there’s some quantum gate which takes two bits xx x and yy y as input, in the computational basis, ∣x,y⟩|x,y\rangle ∣ x , y ⟩ , and then outputs a single qubit ∣x∧y⟩|x \wedge y\rangle ∣ x ∧ y ⟩ , where x∧yx \wedge y x ∧ y is just the logical AND of the bits xx x and yy y .

 Unfortunately, that “quantum gate” makes no sense at all! Not only is it not unitary, it’s not even close: a unitary gate with two qubits as input necessarily has two qubits as output. The “gate” I described has just a single qubit as output, so there’s no way it can be unitary.

 You might wonder if instead there’s some way we can find a two-qubit quantum gate which has x∧yx \wedge y x ∧ y as one output, and something else as the other output. I won’t prove it, but it turns out that this is impossible. The proof actually isn’t all that hard – it’s a fun exercise to think through, if you want a challenge – but is more of a digression than I want to get into here.

 That’s all rather disappointing. But there is a solution. It’s to use a three-qubit quantum gate called the Toffoli gate. The Toffoli gate is much like the CNOT gate, but instead of having a single control qubit, it has two control qubits, xx x and yy y , and a single target qubit, zz z . If both controls qubits are set, then the target is flipped. Otherwise, the target is left alone:

 If the target starts out as z=0z = 0 z = 0 , then you can see that the target output is just x∧yx \wedge y x ∧ y , and so the Toffoli gate can be used to simulate a classical AND gate. So if we have any classical circuit of AND and NOT gates then there’s a corresponding quantum circuit involving the same number of XX X and Toffoli gates which computes the same function.

 Exercise: What’s a quantum circuit that can compute the NAND gate? Recall that the NAND of two bits xx x and yy y is just the NOT of x∧yx \wedge y x ∧ y .

 Exercise: Can you find a way of implementing a NAND gate using just a single Toffoli gate and no other quantum gates? Note that your answer here may be the same as your answer to the previous exercise, if you answered that exercise using just a single Toffoli gate and no other quantum gates.

 A wrinkle in all this is that the Toffoli gate isn’t in our standard set of basic quantum gates. However, it’s possible to build the Toffoli gate up out of CNOT and single-qubit unitary gates. One way of doing the breakdown is shown below:

 There are various slick ways of “explaining” why this circuit works, but I’ll let you in on a secret: much of the earliest work on this was done by pure brute force, people simply trying lots and lots of different ways of implementing the Toffoli gate (sometimes, using a computer to assist in doing the search). Frankly, I wouldn’t worry too much about why this circuit works, just take it for granted that it does. You can look it up if you ever need to, or dig down into why. Needing to know the circuit details actually isn’t all that common, so I wouldn’t suggest memorizing it – not until you have a good reason.

 Exercise: Show that the inverse of the Toffoli gate is just the Toffoli gate.

 Didn’t rememberRemembered

 No, really, what are quantum computers good for?

 It’s comforting that we can always simulate a classical circuit – it means quantum computers aren’t slower than classical computers – but doesn’t answer the question of the last section: what problems are quantum computers good for? Can we find shortcuts that make them systematically faster than classical computers? It turns out there’s no general way known to do that. But there are some interesting classes of computation where quantum computers outperform classical.

 Over the long term, I believe the most important use of quantum computers will be simulating other quantum systems. That may sound esoteric – why would anyone apart from a quantum physicist care about simulating quantum systems? But everybody in the future will (or, at least, will care about the consequences). The world is made up of quantum systems. Pharmaceutical companies employ thousands of chemists who synthesize molecules and characterize their properties. This is currently a very slow and painstaking process. In an ideal world they’d get the same information thousands or millions of times faster, by doing highly accurate computer simulations. And they’d get much more useful information, answering questions chemists can’t possibly hope to answer today. Unfortunately, classical computers are terrible at simulating quantum systems.

 The reason classical computers are bad at simulating quantum systems isn’t difficult to understand. Suppose we have a molecule containing nn n atoms – for a small molecule, nn n may be 11 1 - 1010 1 0 , for a complex molecule it may be hundreds or thousands or even more. And suppose we think of each atom as a qubit (not true, but go with it): to describe the system we’d need 2n2^n 2 n different amplitudes, one amplitude for each nn n - bit computational basis state, e.g., ∣010011…⟩|010011\ldots\rangle ∣ 0 1 0 0 1 1 … ⟩ .

 Of course, atoms aren’t qubits. They’re more complicated, and we need more amplitudes to describe them. Without getting into details, the rough scaling for an nn n - atom molecule is that we need knk^n k n amplitudes, where k≥2k \geq 2 k ≥ 2 . The value of kk k depends upon context – which aspects of the atom’s behavior are important. For generic quantum simulations kk k may be in the hundreds or more.

 That’s a lot of amplitudes! Even for comparatively simple atoms and small values of nn n , it means the number of amplitudes will be in the trillions. And it rises very rapidly, doubling or more for each extra atom. If k=100k=100 k = 1 0 0 , then even n=10n = 10 n = 1 0 atoms will require 100 million trillion amplitudes. That’s a lot of amplitudes for a pretty simple molecule.

 The result is that simulating such systems is incredibly hard. Just storing the amplitudes requires mindboggling amounts of computer memory. Simulating how they change in time is even more challenging, involving immensely complicated updates to all the amplitudes.

 Physicists and chemists have found some clever tricks for simplifying the situation. But even with those tricks simulating quantum systems on classical computers seems to be impractical, except for tiny molecules, or in special situations. The reason most educated people today don’t know simulating quantum systems is important is because classical computers are so bad at it that it’s never been practical to do. We’ve been living too early in history to understand how incredibly important quantum simulation really is.

 That’s going to change over the coming century. Many of these problems will become vastly easier when we have scalable quantum computers, since quantum computers turn out to be fantastically well suited to simulating quantum systems. Instead of each extra simulated atom requiring a doubling (or more) in classical computer memory, a quantum computer will need just a small (and constant) number of extra qubits. One way of thinking of this is as a loose quantum corollary to Moore’s law:

 The quantum corollary to Moore’s law: Assuming both quantum and classical computers double in capacity every few years, the size of the quantum system we can simulate scales linearly with time on the best available classical computers, and exponentially with time on the best available quantum computers.

 In the long run, quantum computers will win, and win easily.

 The punchline is that it’s reasonable to suspect that if we could simulate quantum systems easily, we could greatly speed up drug discovery, and the discovery of other new types of materials.

 I will risk the ire of my (understandably) hype-averse colleagues and say bluntly what I believe the likely impact of quantum simulation will be: there’s at least a 50 percent chance quantum simulation will result in one or more multi-trillion dollar industries. And there’s at least a 30 percent chance it will completely change human civilization. The catch: I don’t mean in 5 years, or 10 years, or even 20 years. I’m talking more over 100 years. And I could be wrong.

 What makes me suspect this may be so important?

 For most of history we humans understood almost nothing about what matter is. That’s changed over the past century or so, as we’ve built an amazingly detailed understanding of matter. But while that understanding has grown, our ability to control matter has lagged. Essentially, we’ve relied on what nature accidentally provided for us. We’ve gotten somewhat better at doing things like synthesizing new chemical elements and new molecules, but our control is still very primitive.

 We’re now in the early days of a transition where we go from having almost no control of matter to having almost complete control of matter. Matter will become programmable; it will be designable. This will be as big a transition in our understanding of matter as the move from mechanical computing devices to modern computers was for computing. What qualitatively new forms of matter will we create? I don’t know, but the ability to use quantum computers to simulate quantum systems will be an essential part of this burgeoning design science.

 Alright, enough speculation.

 Let me also briefly mention the sober-minded conventional answer given to the question “what are quantum computers good for?” That answer is to list various algorithmic problems that we have some evidence can be solved faster on a quantum computer than on a classical computer.

 The most famous example is Peter Shor’s beautiful quantum factoring algorithm. To find the prime factors of an nn n - bit integer seems to be a very difficult problem on a classical computer. The best existing algorithms are incredibly computationally expensive, with a cost that rises exponentially with nn n . Even numbers with just a few hundred digits aren’t currently feasible to factor on classical computers. By contrast, Shor’s quantum factoring algorithm would make factoring into a comparatively easy task, if large-scale quantum computers can be built.

 Factoring perhaps doesn’t seem like a very interesting application. But it turns out that the ability to factor lets you break some of the most widely-used encryption schemes, used by services such as Gmail and Amazon to keep your communications private. This ability to break encryption has made the world’s intelligence agencies very interested in factoring, and they’ve poured enormous sums of money into quantum computing research since the mid-1990s. Indeed, there’s a good (as yet unwritten) history book to be written about how the rise of quantum computing was caused by the interest of the world’s intelligence agencies in accessing humanity’s private thoughts.

 There’s been surprisingly little public reflection about this on the part of the quantum computing community. I occasionally meet quantum computing researchers who complain in private about what they perceive as privacy violations by governments, and the dangers of surveillance states. But then some of those same people will take money to help those governments in their plans for surveillance, usually with some transparently self-serving justification about how they’re not really helping. One exception to this lack of public reflection is a brief discussion in Ronald de Wolf’s thoughtful essay The Potential Impact of Quantum Computers on Society (2017).

 Didn’t rememberRemembered

 Are quantum computers really universal devices?

 The eternal mystery of the world is its comprehensibility… The fact that it is comprehensible is a miracle.

 — Albert Einstein

 At the beginning of this essay I asked whether there is any single universal computing device that can efficiently simulate any other physical system? We’ve learned that classical computers seem to have a lot of trouble efficiently simulating quantum systems.

 What about quantum computers? While they can certainly simulate many quantum systems, does that mean they can be used to efficiently simulate any physical system?

 This question is an open problem! We don’t yet know the answer.

 Part of the trouble in answering the question is that humanity hasn’t yet discovered the final fundamental laws of physics. Modern physics is based on two astonishingly effective theories: Einstein’s general theory of relativity, which describes how gravitation works; and the standard model of particle physics, which explains how pretty much everything else (electromagnetism, the strong and weak nuclear forces) work.

 Trouble is, we don’t yet have a good theory of quantum gravity which combines general relativity and the standard model. Without such a theory of quantum gravity we’re not able to answer the question of whether quantum computers can efficiently simulate any other physical system. Perhaps some future class of quantum gravitating computers, more powerful even than quantum computers, will be needed to simulate quantum gravity.

 Let’s ask a slightly less ambitious question, which is whether we can use quantum computers to efficiently simulate general relativity and the standard model?

 The standard model is an example of a particular type of quantum mechanical theory called a quantum field theory. John Preskill and his collaborators have written a series of papers For a review of progress see: John Preskill, Simulating quantum field theory with a quantum computer (2018). explaining how to use quantum computers to efficiently simulate quantum field theories. Those papers don’t yet simulate the full standard model, but they do make considerable progress. It remains an exciting open problem, albeit a problem where much encouraging progress has been made.

 In the case of general relativity, as far as I know the problem remains open. Indeed, even stating what the problem means is not trivial. General relativity supports the existence of closed timelike curves, which can be used in some sense to send information back in time. This has interesting consequences for computation: there’s a way in which the computer can know the results of future computations. Unsurprisingly, this changes what is possible! Another complication is that when you talk about an “efficient simulation” in computation you mean the time and space overhead isn’t too large. But in general relativity even the basic units of space and time aren’t so clear. It’s hard to say what efficiency means. Finally, near singularities time and space get distorted in strange ways, again making it challenging to say exactly what it means to do an efficient computation.

 There is, by the way, significant issue that I've been sweeping under the rug, and which may be bugging you: as I've explained it, a quantum computer isn't a single computing device at all, since there are many possible quantum circuits. This is okay, though, since there's a model known as the universal quantum Turing machine, which is a single computing device, and which can simulate any quantum circuit. So you should understand the discussion above as being implicitly about the universal quantum Turing machine. I won't explain the details of the universal quantum Turing machine in this essay, since in practice the quantum circuit model is far more commonly used. But if you're interested in the details, I recommend this paper by Bernstein and Vazirani.

 The existence of universal computers is easy to take for granted. But there’s no a priori logical reason there should be a single machine that can efficiently simulate every other physical system. It’s like being able to use your car also as a surfboard, a supermarket trolley, and a rainforest In fact, there’s a sense in which this is possible, within limits: if you could rearrange protons, neutrons, and electrons arbitrarily well, you could turn a car into a surfboard, a supermarket trolley, or a (small) part of a rainforest. So matter does have intriguing universality properties. This is also remarkable, of course. . Yet the evidence so far suggests our universe does allow such universal machines. It’s a good problem – and, so far as I know, largely unexplored – to think about sets of laws of physics in which such a universal machine is not possible. That might sound pointless – why imagine other possible universes? Yet exploring such radical counterfactuals is often an excellent strategy for better understanding our own universe.

 So there’s a very strange loop here. It’s that the laws of physics determine what kind of computations can be done. And yet the kind of computations which can be done seem to be powerful enough to describe the laws of physics. And that description can then be used to (efficiently!) simulate any physical system:

 The top part of the loop is almost tautological. The bottom half of the loop is extraordinary. There’s no a priori reason the laws of physics should enable the existence of machines which can simulate physical systems. You might argue on anthropic grounds – we humans are here in the universe, and doing physics pretty successfully, so conditioned on that, it must be true. But that’s not a very satisfactory explanation of why. It remains a mystery. Einstein was right: the fact that the world is comprehensible at all is a miracle.

 Didn’t rememberRemembered

 Final Reflections

 We’ve worked through all the basics of the quantum computing model, but we haven’t yet used it in a full-on application – the sort of application which make people excited about quantum computing. But there will soon be available two considerably shorter(!) followup essays, explaining the quantum search algorithm and quantum teleportation. Someone who understands all three essays will have a good understanding of elementary quantum computing.

 And what of the experimental mnemonic medium we’ve developed in this essay? Mastering new subjects requires internalizing the basic terminology and ideas of the subject. The mnemonic medium should radically speed up this memory step, converting it from a challenging obstruction into a routine step. Frankly, I believe it would accelerate human progress if all the deepest ideas of our civilization were available in a form like this. Perhaps some day.

 With that said, memory is only part of what it means to understand. Is it possible to build powerful environments which enable deeper forms of understanding? That enable people to take action in new ways, to grow their sense of agency and of ability to contribute? This requires many things beyond memory: the ability to problem solve and to problem find; to connect with opportunities that genuinely matter, and to find pathways for meaningful contribution. We, the team at “Quantum Computing for the Very Curious”, believe there are many powerful and under-exploited patterns available to achieve these goals. In future projects we will explore and develop these patterns. Some of this exploration will continue to be done in the context of quantum computing. But we also hope to launch projects discussing some of humanity’s other great challenges, including optimistic, detailed visions of problems such as space travel, climate change, longevity, and the development of new forms of matter.

 Thanks for reading this far. In a few days, you’ll receive a notification containing a link to your first review session. In that review session you’ll be retested on the material you’ve learned, helping you further commit it to memory. It should only take a few minutes. In subsequent days you’ll receive more notifications linking you to re-review, gradually working toward genuine long-term memory of all the core material in the essay.

 Thanks for reading this far. If you’d like to remember the core ideas of this essay durably, please sign in below to set up an account. We’ll track your review schedule and send you occasional reminders containing links that will take you to the review experience.

 Please sign in so we can save your progress and let you know the best times to review.
 Thank you! Your progress will be saved as you read.

 Acknowledgments

 Michael Nielsen is supported by Y Combinator Research. This essay is based in part on Michael’s earlier lecture series on Quantum Computing for the Determined.

 Citing this work

 In academic work, please cite this as:

 Andy Matuschak and Michael A. Nielsen, “Quantum Computing for the Very Curious”, https://quantum.country/qcvc, San Francisco (2019).

 Authors are listed in alphabetical order.

 License

 This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License. This means you’re free to copy, share, and build on this essay, but not to sell it. If you’re interested in commercial use, please contact us.

 Last updated

 March 18, 2019

 See our User Agreement and Privacy Policy.

If humanity ever makes contact with alien intelligences, will those aliens possess computers? In science fiction, alien computers are commonplace. If that's correct, it means there is some way aliens can discover computers independently of humans. After all, we’d be very surprised if aliens had independently invented Coca-Cola or Pokémon or the Harry Potter books. If aliens have computers, it’s because computers are the answer to a question that naturally occurs to both human and alien civilizations. Here on Earth, the principal originator of computers was the English mathematician Alan Turing. In his paper, published in 1936Alan M. Turing, On Computable Numbers, with an Application to the Entscheidungsproblem (1936)., Turing wasn’t trying to invent a clever gadget or to create an industry. Rather, he was attacking a problem about the nature of mathematics posed by the German mathematician David Hilbert in 1928. That sounds abstruse, but it’s worth understanding the gist of Hilbert and Turing’s thinking, since it illuminates where computers come from, and what computers will become in the future. Through his career, Hilbert was interested in the ultimate limits of mathematical knowledge: what can humans know about mathematics, in principle, and what (if any) parts of mathematics are forever unknowable by humans? Roughly speaking, Hilbert’s 1928 problem asked whether there exists a general algorithm a mathematician can follow which would let them figure out whether any given mathematical statement is provable. Hilbert’s hoped-for algorithm would be a little like the paper-and-pencil algorithm for multiplying two numbers. Except instead of starting with two numbers, you’d start with a mathematical conjecture, and after going through the steps of the algorithm you’d know whether that conjecture was provable. The algorithm might be too time-consuming to use in practice, but if such an algorithm existed, then there would be a sense in which mathematics was knowable, at least in principle. In 1928, the notion of an algorithm was pretty vague. Up to that point, algorithms were often carried out by human beings using paper and pencil, as in the multiplication algorithm just mentioned, or the long-division algorithm. Attacking Hilbert’s problem forced Turing to make precise exactly what was meant by an algorithm. To do this, Turing described what we now call a Turing machine: a single, universal programmable computing device that Turing argued could perform any algorithm whatsoever. Today we’re used to the idea that computers can be programmed to do many different things. In Turing’s day, however, the idea of a universal programmable computer was remarkable. Turing was arguing that a single, fixed device could imitate any algorithmic process whatsoever, provided the right program was supplied. It was an amazing leap of imagination, and the foundation of modern computing. In order to argue that his machine could imitate any algorithmic process, Turing considered what operations a human mathematician could perform when carrying out an algorithm. For each such operation, he had to argue that his machine could always do the same thing. His argument is too long to reproduce in full here, but it’s fun and instructive to see the style of Turing’s reasoning: Computing is normally done by writing certain symbols on paper. We may suppose this paper is divided into squares like a child’s arithmetic book. In elementary arithmetic the two-dimensional character of the paper is sometimes used. But such a use is always avoidable, and I think that it will be agreed that the two-dimensional character of paper is no essential of computation. I assume then that the computation is carried out on one-dimensional paper, i.e. on a tape divided into squares. … The behavior of the computer [Turing is referring to the person performing an algorithm, not the machine!] at any moment is determined by the symbols which he is observing, and his “state of mind” at that moment. We may suppose that there is a bound BB to the number of symbols or squares which the computer can observe at one moment. If he wishes to observe more, he must use successive observations. We will also suppose that the number of states of mind which need be taken into account is finite. Obviously, this was an informal and heuristic argument! Invoking a child’s arithmetic book, or someone’s mental state is not the stuff of a rigorous, bulletproof argument. But Turing’s argument was convincing enough that later mathematicians and scientists have for the most part been willing to accept it. Turing’s machine became the gold standard: an algorithm was what we could perform on a Turing machine. And since that time, computing has blossomed into an industry, and billions of computers based on Turing’s model have been sold. Still, there’s something discomforting about Turing’s analysis. Might he have missed something in his informal reasoning about what an algorithm is? In 1985, the English physicist David Deutsch suggested a deeper approach to the problem of defining what is meant by an algorithmDavid Deutsch, “Quantum theory, the Church-Turing principle and the universal quantum computer” (1985).. Deutsch pointed out that every algorithm is carried out by a physical system, whether it be a mathematician with paper-and-pencil, a mechanical system such as an abacus, or a modern computer. Deutsch then considered the following question (I've slightly rephrased to make it easier to read):  Is there a (single) universal computing device which can efficiently simulate any other physical system?  If there was such a device, you could use it to perform any algorithm whatsoever, because algorithms have to be performed on some kind of physical system. And so the device would be a truly universal computer. What’s more, Deutsch pointed out, you wouldn’t need to rely on informal, heuristic arguments to justify your notion of algorithm, as Turing had done. You could use the laws of physics to prove your device was universal. So let’s come back to our opening question: will aliens have computers? Deutsch’s question above is a simple, fundamental question about the nature of the universe. It’s the kind of question which alien counterparts to Deutsch could plausibly come to ponder. And the alien civilizations of which they are a part would then be led inexorably to invent computers. In this sense, computers aren’t just human inventions. They are a fundamental feature of the universe, the answer to a simple and profound question about how the universe works. And they have likely been discovered over and over again by many alien intelligences. There’s a wrinkle in this story. Deutsch is a physicist with a background in quantum mechanics. And in trying to answer his question, Deutsch observed that ordinary, everyday computers based on Turing’s model have a lot of trouble simulating quantum mechanical systemsResearchers such as Yu Manin and Richard Feynman had previously observed this, and as a result had speculated about computers based on quantum mechanics.. In particular, they seem to be extraordinarily slow and inefficient at doing such simulations. To answer his question affirmatively, Deutsch was forced to invent a new type of computing system, a quantum computer. Those quantum computers can do everything conventional computers can do, but are also capable of efficiently simulating quantum-mechanical processes. And so they are arguably a more natural computing model than conventional computers. If we ever meet aliens, my bet is that they’ll use quantum computers (or, perhaps, will have quantum computing brains). After all, it’s likely that aliens will be far more technologically advanced than current human civilization. And so they’ll use the computers natural for any technologically advanced society. This essay explains how quantum computers work. It’s not a survey essay, or a popularization based on hand-wavy analogies. We’re going to dig down deep so you understand the details of quantum computing. Along the way, we’ll also learn the basic principles of quantum mechanics, since those are required to understand quantum computation. Learning this material is challenging. Quantum computing and quantum mechanics are famously “hard” subjects, often presented as mysterious and forbidding. If this were a conventional essay, chances are that you’d rapidly forget the material. But the essay is also an experiment in the essay form. As I’ll explain in detail below the essay incorporates new user interface ideas to help you remember what you read. That may sound surprising, but uses a well-validated idea from cognitive science known as spaced-repetition testing. More detail on how it works below. The upshot is that anyone who is curious and determined can understand quantum computing deeply and for the long term. That said, you need some mathematical background to understand the essay. I’ll assume you’re comfortable with complex numbers and with linear algebra – vectors, matrices, and so on. I’ll also assume you’re comfortable with the logic gates used in conventional computers – gates such as AND, OR, NOT, and so on. If you don’t have that mathematical background, you’ll need to acquire it. How you do that depends on your prior experience and learning preferences – there’s no one-size-fits-all approach, you’ll need to figure it out for yourself. But two resources you may find helpful are: (1) 3Blue1Brown’s series of YouTube videos on linear algebra; and (2) the more in-depth linear algebra lectures by Gil Strang. Try them out, and if you find them helpful, keep going. If not, explore other resources. It may seem tempting to try to avoid this mathematics. If you look around the web, there are many flashy introductions to quantum computing that avoid mathematics. There are, for instance, many rather slick videos on YouTube. They can be fun to watch, and the better ones give you some analogies to help make sense of quantum computing. But there’s a hollowness to them. Bluntly, if they don’t explain the actual underlying mathematical model, then you could spend years watching and rewatching such videos, and you’d never really get it. It’s like hanging out with a group of basketball players and listening to them talk about basketball. You might enjoy it, and feel as though you’re learning about basketball. But unless you actually spend a lot of time playing, you’re never going to learn to play basketball. To understand quantum computing, you absolutely must become fluent in the mathematical model. Part I: The state of a qubit As you know, in ordinary, everyday computers the fundamental unit of information is the bit. It’s a familiar but astonishing fact that all the things those computers do can be broken down into patterns of 00s and 11s, and simple manipulations of 00s and 11s. For me, I feel this most strongly when playing video games. I’ll be enjoying playing a game, when I’ll suddenly be hit by a realization of the astounding complexity behind the imaginary world visible on my screen:    SourceCopyright Wildfire Games, used under a Creative Commons Attribution-Share Alike 3.0 license.. Underlying every such image is millions of pixels, described by tens of millions of bits. When I move the game controller, I am effectively conducting an orchestra, tens of millions strong, organized through many layers of intermediary ideas, in such a way as to create enjoyment and occasionally sheer delight. I’ve described a bit as an abstract entity, whose state is 00 or 11. But in the real world, not the world of mathematics, we must find some way of storing our bits in a physical system. That can be done in many different ways. In your computer’s memory chips, bits are most likely stored as tiny electric charges on nanometer-scale capacitors (i.e., little reservoirs of charge), just above the surface of the chip. Old-fashioned hard disks take a different approach, using tiny magnets to store bits. Furthermore, different types of memory use different types of capacitor; different types of hard disk use different approaches to magnetization. For the most part you don’t notice these differences when you use your computer. Computer designers work very, very hard to make the details of the physical instantiation of the bits invisible not just to the user, but also (often) invisible even to programmers. Many programmers never think about whether a bit is stored in fast on-microprocessor cache memory, in the dynamic RAM chips, or in some type of virtual memory (say, on a hard disk). There are exceptions – programmers working on high-performance programs sometimes do think about these things, to make their programs as fast as possible. But for many programmers it doesn’t much matter how bits are stored. Rather, they can think of the bit in purely abstract terms, as having a state which is either 00 or 11. In a manner similar to the way conventional computers are made up of bits, quantum computers are made up of quantum bits, or qubits. Just like a bit, a qubit has a state. But whereas the state of a bit is a number (00 or 11), the state of a qubit is a vector. More specifically, the state of a qubit is a vector in a two-dimensional vector space. This vector space is known as state space. For instance, here’s a possible state for a qubit: [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] That perhaps sounds strange! What does it mean that the state of a qubit is a two-dimensional vector? We’re going to unpack the answer slowly and gradually. You won’t have a single epiphany where you think “ahah, that’s what a qubit is!” Rather, you’ll gradually build up many details in your understanding, until you get to the point where you’re comfortable working with qubits, with quantum computations, and more generally with quantum mechanics. One way qubits are similar to bits: we’ve said absolutely nothing about what the qubit actually is, physically. Maybe the state of the qubit is being stored somehow on an electron, or a photon, or an atom. Or maybe it’s being stored in something stranger, perhaps inside some exotic particle or state of matter, even further removed from our everyday experience. For our purposes in this essay none of this matters, no more than you should worry about what type of capacitor is storing the bits inside your computer’s RAM. What you should take away is that: (a) qubits have a state; (b) much like a bit, that state is an abstract mathematical object; but (c) whereas a bit’s abstract state is a number, 00 or 11, the state of a qubit is a 22-dimensional vector; (d) we call the 22-dimensional vector space where states live state space. Alright, let’s review what we’ve learnt. Please indulge me by answering the questions just below. It’ll only take a few seconds – for each question, think about what you believe the answer to be, click to reveal the actual answer, and then mark whether you remembered or not. If you can recall, that’s great. If not, that’s also fine, just note the correct answer, and continue. A medium which makes memory a choice Perhaps you correctly recalled the answers to all three questions just now. Even if so, will you remember the answers in a week? In a year? Human memory is fallible. If your memory is like mine, you might vaguely remember the answers in a week: “what’s the state of a qubit, oh yes, it’s a vector!” But the chances you’ll remember in a month or a year are low. And if you forget such things, you won’t have any durable understanding of quantum computing. How can we ensure you don’t remember these answers for just a few minutes or a few hours, but well into the future, perhaps even permanently? One way is for you to be supremely virtuous, to keep coming back and re-reviewing the material until it’s firmly locked in your memory. If you are such a virtuous person, congratulations! But for the other 99 percent of us that’s not likely. What can we do? For more than a century, cognitive scientists have studied human memory. And they’ve figured out some simple strategies that ensure you’ll remember something permanently. The single most important idea is to re-test you on your knowledge, with expanding time intervals between tests.  As an example, consider the question above: “How many dimensions does the state space of a qubit have?” If you got it right, you’d ideally be tested again in a few weeks. And if you got it right again, you’d be tested again a few months after that. And so on, a gradually expanding schedule. If you get the question wrong on one of those tests, the schedule would contract, so you can relearn the answer. It turns out that such an expanding schedule is the optimal way to retain information. Each time you’re re-tested your brain consolidates the answer a little better into long-term memory, until eventually it’s permanent. Spaced-repetition testing is a simple idea, but has profound consequences. First, it doesn’t take much overall time. Because of the expanding test schedule, it typically only takes a few minutes of total review time to memorize the answer to a question for years or decades. I won’t go through the math showing that, but you can see it worked out elsewhere. Second, spaced-repetition testing gives you a guarantee you will remember the answer to the question. For the most part our memories work in a haphazard manner. We read or hear something interesting, and hope we remember it in future. Spaced-repetition testing makes memory into a choice. This sounds great, but also like you’ll need to be very disciplined in re-testing yourself. Fortunately, the computer can handle all the scheduling for you. And so this essay isn’t just a conventional essay, it’s also a new medium, a mnemonic medium which integrates spaced-repetition testing. The medium itself makes memory a choice.  This comes at some cost: you’re committing to future review. But consider what that buys you. This essay will likely take you an hour or two to read. In a conventional essay, you’d forget most of what you learned over the next few weeks, perhaps retaining a handful of ideas. But with spaced-repetition testing built into the medium, a small additional commitment of time means you will remember all the core material of the essay. Doing this won’t be difficult, it will be easier than the initial read. Furthermore, you’ll be able to read other material which builds on these ideas; it will open up an entire world. This spaced-repetition approach is why the questions only require a few seconds to read and answer. They’re not complex exercises, in the style of a textbook. Rather, the questions have a different point: the promise each question makes is that you will remember the answer forever. It’s to permanently change your thinking. So, I invite you to set up an account by signing in below. If you do so, your review schedule for each question in the essay will be tracked, and you’ll receive periodic reminders containing a link which takes you to an online review session. That review session isn’t this full essay – rather, it looks just like the question set you answered above, but contains instead all the questions which are due, so you can quickly run through them. The time commitment will usually be a few minutes per session – a little more early on, when questions need frequent re-testing, but rapidly dropping off. You can study on your phone while grabbing coffee, or standing in line, or going for a walk, or in transit. The return for that small time commitment is greatly improved fluency in basic quantum computing and quantum mechanics. And that understanding will be internalized, a part of who you are, retained for years instead of days. To keep this promise, we’re tracking your review schedule for each question, and sending you occasional reminders to check in, and to run through the questions which are due. You can review on your phone while grabbing coffee, or standing in line, or going for a walk, or on transit. The return for that commitment is greatly improved fluency in basic quantum computing and quantum mechanics. And that understanding will be internalized, a part of who you are, retained for years instead of weeks.   Please sign in so we can save your progress and let you know the best times to review.   Thank you! Your progress will be saved as you read.   Having extolled the virtues of spaced-repetition testing, let’s try another question: This question is similar to an earlier question: “How many dimensions does the state space of a qubit have?” It may seem inefficient to have such similar questions, but it helps build fluency with the material when you have the “same” information encoded into memory in multiple ways, triggering off different associations. And so many of the questions below have this nature, elaborating ideas in multiple ways. Connecting qubits to bits: the computational basis states Let’s get back to understanding qubits. I’ve described what the state of a qubit is, but given no hint about how (or whether) that’s connected to the state of a classical bit. (Henceforth we’ll use the phrase “classical bit” instead of “conventional bit”, after “classical physics”). In fact, there are two special quantum states which correspond to the 00 and 11 states of a classical bit. The quantum state corresponding to 00 is usually denoted ∣0⟩|0\rangle. That’s a fancy notation for the following vector: ∣0⟩:=[10].|0\rangle := \left[ \begin{array}{c} 1 \\ 0 \end{array} \right]. This special state ∣0⟩|0\rangle is called a computational basis state. It’s tempting to see the ∣0⟩|0\rangle notation and wonder what all the separate pieces mean – what, for instance, does the ∣| mean; what does the ⟩\rangle mean; and so on? In fact, it’s best to regard ∣0⟩|0\rangle as a single symbol, standing for a single mathematical object – that vector we just saw above, [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right]. The ∣| and ⟩\rangle don’t really have separate meanings except to signify this is a quantum state. In this, ∣0⟩|0\rangle is much like the symbol 00: both stand for a single mathematical entity. And, as we’ll gradually come to see, a quantum computer can manipulate ∣0⟩|0\rangle in ways very similar to how a conventional computer can manipulate 00. This notation with ∣| and ⟩\rangle is called the ket notation, and things like ∣0⟩|0\rangle are called kets. But don’t be thrown off by the unfamiliar terminology – a ket is just a vector, and when we say something is a ket, all we mean is that it’s a vector. That said, the term ket is most often used in connection with notations like ∣0⟩|0\rangle. That is, we wouldn’t usually refer to [10]\left[ \begin{array}{c} 1 \\ 0 \end{array} \right] as a ket; we’d call it a vector, instead. If you’re a fan of really sharp definitions and strict consistency, this may seem vague and wishy-washy, but in practice doesn’t cause confusion. It’s just a convention to be aware of! Alright, so ∣0⟩|0\rangle is a computational basis state for a qubit, and plays much the same role as 00 does for a classical bit. It won’t surprise you to learn that there is another computational basis state, denoted ∣1⟩|1\rangle, which plays the same role as 11 does for a bit. Like ∣0⟩|0\rangle, ∣1⟩|1\rangle is just a notation for a two-dimensional vector, in this case: ∣1⟩:=[01].|1\rangle := \left[ \begin{array}{c} 0 \\ 1 \end{array} \right]. Again, we’ll gradually come to see that ∣1⟩|1\rangle has all the properties we expect of the 11 state of a classical bit. Time for a few more questions. A reminder that these have a different purpose to conventional textbook exercises. Textbook exercises are about setting you challenges; the point of the questions below is instead to help you commit the answer to long-term memory. How to use (or not use!) the questions Mathematics is a process of staring hard enough with enough perseverance at the fog of muddle and confusion to eventually break through to improved clarity. I’m happy when I can admit, at least to myself, that my thinking is muddled, and I try to overcome the embarrassment that I might reveal ignorance or confusion. Over the years, this has helped me develop clarity in some things, but I remain muddled in many others.— William Thurston,Fields-medal winning mathematician  How should you think about it when you get one of these embedded questions wrong? Often in life testing means being judged, and being judged can be uncomfortable. If you don’t know the answer to a question you may feel like you’ve failed. But the purpose of these questions has nothing to do with external judgment. Rather, they have two quite different purposes. One purpose is, as explained earlier, to help strengthen your memory, so your new knowledge is consolidated in your long-term memory. The second purpose is to help you diagnose what you do and don’t know, and to help you fill the gaps as rapidly as possible. In this view, getting a question wrong is useful information. It pinpoints exactly what you need to understand, and puts the onus on you to figure it out. Honestly, the appropriate response to getting a question wrong is probably to throw your hands up in the air and shout “wonderful!”, since it’s at those points of what may appear to be “failure” that your learning rate will be at its highest. With that said, it’s a common canard in education that “it doesn’t matter if you get something right or wrong, so long as you’re learning”. Unfortunately, that statement is often bullshit. If getting something right or wrong is used to determine your grade, or to influence other people’s opinion of you, then it damn well does matter. For that reason, I suggest keeping your results private. They are for you alone, and their purpose should be solely to help you learn as rapidly as possible. If they’re not helping you – if they’re making you feel bad, for instance, or being used to judge you – then stop doing the questions. You’ve probably noticed the questions are self-assessed. If you want to mark yourself “correct” sometimes, even when you’re not, go for it! What impact do you think that will have on your learning? Do you enjoy the slightly transgressive feeling? I must admit that I do. Don’t be embarrassed, if so: this is supposed to be, above all else, fun. Or try marking yourself wrong when you’re correct, or skipping the questions entirely. What impact do these actions have on your learning? The point is to figure out how to engage with the questions to learn as rapidly as possible. And that means experimenting playfully with how you engage, to find what works for you. How to approach this essay? This essay is an unusual form. It’s certainly not a product in the conventional startup sense; it’s a research project, an experiment in developing a new and improved form of reading. A conventional product would aim to draw you in, and form a regular, long-term habit. There’d be tens (or hundreds) of millions of words of content for you to read, and lots of people on social media excitedly pointing you toward that content. You’d engage every day, learning more and more and more. That’s not what’s going on here. “Quantum Computing for the Very Curious” is, instead, like a video game or book or movie, a single one-off project for you to work through. So you commit to it for a while, and then the experience is over. (Also, like a video game, book, or movie, sequels are planned!) With that said, it’s different from those forms too. Many people consume games, books, and movies as binge activities, hungrily devouring them until complete. “Quantum Computing for the Very Curious” is, by contrast, intentionally an experience spread out over time. Yes, you probably binge at first, working your way quickly through the text over a couple of hours. But then you return occasionally for brief review sessions, prompted by our notifications. That form of spaced testing is the best way for you to remember what you read. Still, while it might be optimal from the point of view of memory formation, it means not using some of the techniques that games, books, and movies use to keep you interested. Nonetheless, I hope you’ll be willing to trust the team at “Quantum Computing for the Very Curious”, and to participate in the experiment. How can you get the most out of reading in this new mnemonic medium? The ideal is to do an initial read, followed by a few short review sessions over the coming weeks (prompted by our notifications) to help you internalize the ideas. Then (optionally) a followup read, where you can more deeply understand the material. And finally, some sessions of followup review to ensure you remember for the long term:   As you work through this process, we’ll track your overall progress toward completion (meaning: most questions reliably committed to memory), and each time you review we’ll show you that progress. This is a larger commitment than traditional reading. But for a small factor in effort, you will understand the material far more deeply, and remember it for more than 10x as long. What’s more, while the reading process above looks complex, you’ll be cued at each step by reminders that will help the review process become a habit. Trust the reminders, and this will all happen as a matter of course. You may find the essay particularly helpful if you’re taking an introductory class on quantum computing. If that’s your situation, I advise you to read the entire essay immediately at the beginning of semester (or even before), answering all the questions as you go. Then continue to follow the procedure described just above, taking a few minutes to complete each review session, prompted by the reminders you’ll be sent. This will make it far easier to understand the rest of the course you’re taking, and help you get much more out of it. General states of a qubit The computational basis states ∣0⟩|0\rangle and ∣1⟩|1\rangle are just two possible states for a qubit. Many more states are possible, and those extra states endow qubits with capabilities not available to ordinary classical bits. In general, remember, a quantum state is a two-dimensional vector. Here’s an example, with a graphical illustration emphasizing the vector nature of the state: In this example, the state 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle is just 0.60.6 times the ∣0⟩|0\rangle vector, plus 0.80.8 times the ∣1⟩|1\rangle vector. In the usual vector notation that means the state is: 0.6∣0⟩+0.8∣1⟩=0.6[10]+0.8[01]=[0.60.8].0.6|0\rangle + 0.8 |1\rangle = 0.6 \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] + 0.8 \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] = \left[ \begin{array}{c} 0.6 \\ 0.8 \end{array} \right]. I’ve been talking about quantum states as two-dimensional vectors. What I didn’t yet mention is that in general they’re complex vectors, that is, they can have complex numbers as entries. Of course, the example just shown has real entries, as do the computational basis states. But for a general quantum state the entries can be complex numbers. So, for instance, another quantum state is the vector 1+i2∣0⟩+i2∣1⟩,\frac{1+i}{2} |0\rangle + \frac{i}{\sqrt{2}} |1\rangle, which can be written in the conventional component vector representation as [1+i2i2].\left[ \begin{array}{c} \frac{1+i}{2} \\ \frac{i}{\sqrt{2}} \end{array} \right]. Because quantum states are in general vectors with complex entries, the illustration above shouldn’t be taken too literally – the plane is a real vector space, not a complex vector space. Still, visualizing it as a plane is sometimes a handy way of thinking. I’ve said what a quantum state is, as a mathematical object: it’s a two-dimensional vector in a complex vector space. But why is that true? What does it mean, physically, that it’s a vector? Why a complex vector space, and how should we think about the complex numbers? And what’s a quantum state good for, anyway? These are good questions. But they do take some time to answer. For context consider that the discovery of quantum mechanics wasn’t a single event, but occurred over 25 years of work, from 1900 to 1925. Many Nobel prizes were won for milestones along the way. That includes Albert Einstein’s Nobel Prize, won primarily for work related to quantum mechanics (not relativity, as people sometimes assume). When some of the brightest people in the world struggle for 25 years to develop a theory, it’s not an obvious theory! In fact, the idea of describing a simple quantum system using a complex vector in two dimensions summarizes much of what was learned over that 25 years. In that sense, it’s quite a simple and beautiful statement. But it’s not an obvious statement, and it’s not unreasonable that it might take a few hours to understand. That’s better than taking 25 years to understand! As part of that journey toward understanding, let’s get familiar with some more nomenclature commonly used for quantum states. One of the most common terms is superposition. People will say a state like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle is a superposition of ∣0⟩|0\rangle and ∣1⟩|1\rangle. All they mean is that the state is a linear combination of ∣0⟩|0\rangle and ∣1⟩|1\rangle. You may wonder why they don’t just say “linear combination” (and sometimes they do), but the reason is pretty much the same reason English-speakers say “hello” while Spanish-speakers say “hola” – the two terms come out of different cultures and different histories. Another common term is amplitude. An amplitude is the coefficient for a particular state in superposition. For instance, in the state 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle the amplitude for ∣0⟩|0\rangle is 0.60.6, and the amplitude for ∣1⟩|1\rangle is 0.80.8. We’ve learnt that a quantum state is a two-dimensional complex vector. Actually, it can’t be just any old vector, a fact you might have guessed from the very particular amplitudes in some of the examples above. There’s a constraint. The constraint is this: the sums of the squares of the amplitudes must be equal to 11. So, for example, for the state 0.6∣0⟩+0.8∣1⟩0.6 |0\rangle+0.8 |1\rangle the sum of the squares of the amplitudes is 0.62+0.820.6^2+0.8^2, which is 0.36+0.64=10.36+0.64 = 1, as we desired. For a more general quantum state, the amplitudes can be complex numbers, let’s denote them by α\alpha and β\beta so the state is α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. The constraint is now that the sum of the squares of the amplitudes is 11, i.e., ∣α∣2+∣β∣2=1|\alpha|^2+|\beta|^2 = 1. This is called the normalization constraint. It’s called that because if you think of ∣0⟩|0\rangle and ∣1⟩|1\rangle as orthonormal vectors, as I drew them earlier, then the normalization constraint is the requirement that the length of the state is equal to 11. So it’s a unit vector, or a normalized vector, and that’s why this is called a normalization constraint. Summing up all these ideas in one sentence: the quantum state of a qubit is a vector of unit length in a two-dimensional complex vector space known as state space.  We’ve gone through a few refinements of this sentence but that sentence is the final version – there’s no missing parts, or further refinement necessary! That’s what the quantum state of a qubit is. Of course, we will explore the definition further, deepening our understanding, but it will always come back to that basic fact. One common gotcha in thinking about qubits is to look at the ∣0⟩|0\rangle state and think it must be the zero vector in the vector space, often denoted 00. But that’s not right at all. The zero vector is at the origin, 0=[00]0 = \left[ \begin{array}{c} 0 \\ 0 \end{array} \right], while the ∣0⟩|0\rangle vector is quite different, ∣0⟩=[10]≠0|0\rangle = \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \neq 0. It’s just an unfortunate notational accident that ∣0⟩|0\rangle looks as though it should be the 00 vector. Fortunately, in practice this distinction is easy to get used to, and doesn’t cause confusion. But it’s worth noting. What does the quantum state mean? Why is it a vector in a complex vector space? My own conclusion is that today there is no interpretation of quantum mechanics that does not have serious flaws. This view is not universally shared. Indeed, many physicists are satisfied with their own interpretation of quantum mechanics. But different physicists are satisfied with different interpretations.— Steven Weinberg,Nobel Laureate in Physics  Let’s come back to the question of what the quantum state means, and why it’s a vector in a complex vector space. In the case of classical bits, it’s pretty easy to think about the state. You can think of the 00 or 11 states of a bit as corresponding to two very different (but stable) states of a physical system. For instance, a 00 or 11 can be indicated by the presence or absence of a hole at some location in a punch card. And so a single punch card can be used to store hundreds or thousands of bits:   Source: Gwern (2006). Most ways of storing classical bits are variations on this idea. For instance, the dynamic random access memory (RAM) inside your computer is based on the idea of having two tiny metal plates separated by a miniscule gap. Electric charge is stored on those plates, setting up an electric field between them. The 00 and 11 states of the bit correspond to two different configurations of charge on the plates. In practice, real dynamic RAM systems use slightly more elaborate ideas, but that’s the heart of it. This is harder to think about than punch cards – most of us don’t have so much experience thinking about moving electric charges around metal plates. But it’s still pretty concrete. So, how should we think about quantum states? The ∣0⟩|0\rangle and ∣1⟩|1\rangle states often aren’t difficult to think about, since they often correspond to very concrete physical states of the world, much like classical bits. Indeed, in some proposals they may correspond to different charge configurations, similar to dynamic RAM. Or perhaps a photon being in one of two different locations in space – again, a pretty simple, concrete notion, even if photons aren’t that familiar. There are also many more exotic proposals for the ∣0⟩|0\rangle and ∣1⟩|1\rangle states. But by and large you can think of the computational basis states as representing a physical system in one of two well-defined configurations. Of course, qubits have states which aren’t computational basis states, states like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle+0.8|1\rangle. How should we think about such superposition states? At least in popular media accounts, a very common description is that a state like 0.6∣0⟩+0.8∣1⟩0.6|0\rangle + 0.8|1\rangle is “simultaneously” in the ∣0⟩|0\rangle state and the ∣1⟩|1\rangle state. I must confess, I don’t understand what people mean by this. As far as I can tell, what they’re trying to do is explain the quantum state in terms of classical concepts they’re already familiar with. But I can’t make much sense of it – saying 0.6∣0⟩+0.8∣1⟩0.6|0\rangle + 0.8|1\rangle is simultaneously in the ∣0⟩|0\rangle state and the ∣1⟩|1\rangle state seems like word salad, and makes about as much sense to me as Lewis Carroll’s nonsense poem Jabberwocky: ’Twas brillig, and the slithy toves     Did gyre and gimble in the wabe:All mimsy were the borogoves,    And the mome raths outgrabe.… Of course, lacking any other interpretation it’s tempting to try to impose our classical prejudices on the quantum state. Or, even if you reject that, to get hung up worrying about what a quantum state is. But the trouble is that there is enormous disagreement amongst physicists themselves about how to think about the quantum state. Indeed, many active researchers are trying to understand what the correct way of thinking about the quantum state is, exploring multiple approaches in great depth. So we’re going to defer worrying too much about this until later. To understand why we’re deferring, suppose someone gives you a Rubik’s cube (or some other challenging puzzle or game) for the first time, all scrambled up. You start to theorize about the best ways of solving it, how to understand it, and so on. But you never actually play around with it, getting familiar with how it behaves. Often the best way to understand something is to first use it, to get comfortable, to play a lot, and to do lots of informal experiments. As you build familiarity you understand why things are the way they are. At that point, you can go back and better understand the meaning of the basics. Well, we can think of quantum computing and quantum mechanics as an especially complicated type of puzzle! So the strategy we’re taking is to start with the mathematics of quantum computing – we’ll keep getting familiar with qubits and the quantum state, and developing the consequences. Doing that is how we’ll build up intuition, and will give us the chops needed to come back and think harder about the meaning of the quantum state. Part II: Introducing quantum logic gates In Part I we learned about the state of a qubit. But in order to quantum compute, it’s not enough just to understand quantum states. We need to be able to do things with them! We do that using quantum logic gates. A quantum logic gate is simply a way of manipulating quantum information, that is, the quantum state of a qubit or a collection of qubits. They’re analogous to the classical logic gates used in ordinary, everyday computers – gates such as the AND, OR, and NOT gates. And, much like classical gates’ role in conventional computers, quantum gates are the basic building blocks of quantum computation. They’re also a convenient way of describing many other quantum information processing tasks, such as quantum teleportation. In Part II of this essay we’ll discuss several types of quantum logic gate. As we’ll see, the gates we discuss are sufficient to do any quantum computation. In particular, much as any classical computation can be built up using AND, OR, and NOT gates, the quantum gates we describe over the next few sections suffice to do any quantum computation. Many of the quantum gates we’ll learn about are based on familiar classical logic gates. But a few are different. Those differences appear innocuous, almost trivial. But in those differences lies the power of quantum computation, and the possibility for quantum computers to be vastly superior to classical computers. Part II is, frankly, a bit of a slog. Learning quantum gates is like learning basic vocabulary in a new language: there’s no getting round spending a fair bit of time working on it. Still, the spaced-repetition testing should make this basic memory work much easier than is ordinarily the case. And it will prepare you well for some of the more conceptual issues discussed in Part III, where we return to high-level questions about the ultimate nature of computation, and what quantum computers are good for. The quantum NOT gate Let’s take a look at our very first quantum logic gate, the quantum NOT gate. As you can no doubt surmise, the quantum NOT gate is a generalization of the classical NOT gate. On the computational basis states the quantum NOT gate does just what you’d expect, mimicking the classical NOT gate. That is, it takes the ∣0⟩|0\rangle state to ∣1⟩|1\rangle, and vice versa: NOT∣0⟩=∣1⟩NOT|0\rangle = |1\rangle NOT∣1⟩=∣0⟩NOT|1\rangle = |0\rangle But the computational basis states aren’t the only states possible for a qubit. What happens when we apply the NOT gate to a general superposition state, that is, α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle? In fact, it does pretty much the simplest possible thing: it acts linearly on the quantum state, interchanging the role of ∣0⟩|0\rangle and ∣1⟩|1\rangle: NOT(α∣0⟩+β∣1⟩)=α∣1⟩+β∣0⟩.NOT (\alpha|0\rangle +\beta|1\rangle) = \alpha|1\rangle+\beta |0\rangle. I’ve been using the notation NOT for the quantum NOT gate. But for historical reasons people working on quantum computing usually use a different notation, the notation XX. And so the above may be rewritten: X(α∣0⟩+β∣1⟩)=α∣1⟩+β∣0⟩.X (\alpha|0\rangle +\beta|1\rangle) = \alpha|1\rangle+\beta |0\rangle. I’ll use the terms XX gate and NOT gate interchangeably. Historically, the notation XX traces its origin to 1927, when the physicist Wolfgang Pauli introduced an operation sxs_x (often written σx\sigma_x in textbooks today) to help describe rotations of certain objects around the xx spatial axis. This operation later became of interest to people working on quantum computing. But by that point the ss (and the connection to rotation) was irrelevant, and so sxs_x just became XX. What we’ve seen so far are very algebraic ways of writing down the way the XX gate works. There’s an alternate representation, the quantum circuit representation. In a quantum circuit we depict an XX gate as follows: The line from left to right is what’s called a quantum wire. A quantum wire represents a single qubit. The term “wire” and the way it’s drawn looks like the qubit is moving through space. But it's often helpful to instead think of left-to-right as representing the passage of time. So the initial segment of wire is just the passage of time, with nothing happening to the qubit. Then the XX gate is applied. And then the quantum wire continues, leaving the desired output. Sometimes we’ll put the input and output states explicitly in the quantum circuit, so we have something like: So that’s the quantum circuit representation of the XX gate. It is, in fact, our first quantum computation. A simple computation, involving just a single qubit and a single gate, but a genuine quantum computation nonetheless! There’s a third representation for the XX gate that’s worth knowing about, a representation as a 2×22 \times 2 matrix: X=[0110].X = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right]. To understand in what sense this is a representation of the NOT gate, recall that α∣0⟩+β∣1⟩\alpha|0\rangle + \beta|1\rangle is just the vector [αβ]\left[ \begin{array}{c} \alpha \\ \beta \end{array} \right]. And so we have: [0110](α∣0⟩+β∣1⟩)=[0110][αβ]=[βα]=α∣1⟩+β∣0⟩=X(α∣0⟩+β∣1⟩).\begin{aligned} \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] (\alpha|0\rangle + \beta|1\rangle) &amp; = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] \left[ \begin{array}{c} \alpha \\ \beta \end{array} \right] \\ &amp; = \left[ \begin{array}{c} \beta \\ \alpha \end{array} \right] \\ &amp; = \alpha|1\rangle+\beta|0\rangle \\ &amp; = X (\alpha|0\rangle + \beta|1\rangle). \end{aligned} This tells us that XX and [0110]\left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] act in exactly the same way on all vectors, and thus are the same operation. In fact, as we’ll see later, it turns out that all quantum gates can be thought of as matrices, with the matrix entries specifying the exact details of the gate. By the way, regarding the XX gate as a matrix clarifies what may have been a confusing point earlier. I wrote the XX gate as having the action X∣0⟩=∣1⟩X|0\rangle = |1\rangle, X∣1⟩=∣0⟩X|1\rangle = |0\rangle. Implicitly – I never quite said this, though it’s true – the XX gate is a mathematical function, taking input states to output states. But when we write functions we usually use parentheses, so why didn’t I write X(∣0⟩)X(|0\rangle) and similarly for ∣1⟩|1\rangle? The reason is that for linear functions, i.e., matrices, it’s conventional to omit parentheses and just write X∣0⟩X|0\rangle – function application is just matrix multiplication. Quantum wires: why the simplest quantum circuit is often also the hardest to implement We’ve now seen a simple quantum circuit and quantum logic gate. But it’s not quite the simplest possible quantum circuit. The simplest possible quantum circuit does nothing at all. That is, it’s a single quantum wire: This circuit is just a single qubit being preserved in time. To be more explicit, if some arbitrary quantum state ∣ψ⟩|\psi\rangle is input to the circuit, then the exact same state ∣ψ⟩|\psi\rangle is output (it’s common practice to use the Greek letter ψ\psi to denote an arbitrary quantum state): Mathematically, this circuit is trivial. But physically it’s far from trivial. In many physical systems, the quantum wire is actually one of the hardest quantum computations to implement! The reason is that quantum states are often incredibly fragile. If your qubit is being stored in some tiny system – perhaps a single photon or a single atom – then it’s very, very easy to disturb that state. It really doesn’t take much to upset an atom or a photon. And so while quantum wires are mathematically trivial, they can be one of the hardest elements to build in real systems. That said, there are some systems where quantum wires are easy to implement. If you store your qubit in a neutrino then the state will actually be pretty well preserved. The reason is that neutrinos barely interact with other forms of matter at all – a neutrino can easily pass through a mile of lead without being disturbed. But while it’s intriguing that neutrinos are so stable, it doesn’t mean they make good qubits. The trouble is that since there’s no easy way of using ordinary matter to interact with them, we can’t manipulate their quantum state in a controlled fashion, and so can’t implement a quantum gate. There’s a tension here that applies to many proposals to do quantum information processing, not just neutrinos. If we want to store the quantum state, then it’s helpful if our qubits only interact very weakly with other systems, so those systems don’t disrupt them. But if the qubits only interact weakly with other systems then that also makes it hard to manipulate the qubits. Thus, systems which make good quantum wires are often hard to build quantum gates for. Much of the art of designing quantum computers is about finding ways to navigate this tension. Often, that means trying to design systems which interact weakly most of the time, but some of the time can be caused to interact strongly, and so serve as part of a quantum gate. You’ll note that some of the questions above have a different flavor to the questions earlier in the essay. Early questions had cut-and-dried answers. The answer to the question “What’s the standard notation for the quantum NOT gate?” is just: “XX”. But some of the questions above have less well-specified answers. They’re a little fluffy. This fluffiness may cause you difficulties as you decide how to respond. Your answer to the question “Why is it that systems which make good quantum wires are often hard to build quantum gates for?” may not quite match the answer given. If this is the case, don’t worry. You should mark yourself correct if you’re confident you’ve understood the point, even in terms different from my phrasing. And mark yourself incorrect if the point still needs reinforcement. A multi-gate quantum circuit Let’s take a look at a simple multiple-gate quantum circuit. It’s just a circuit with two XX gates in a row: It’s worth pausing for a moment, and trying to guess what this circuit does to the input state. It’s worth doing this even if you usually find this kind of guessing frustrating. Even when you get stuck, building up strategies for dealing with stuckness is part of learning any difficult subject. So take a minute or so now. We’ll try two different ways of figuring out what’s going on. Here’s one approach, based on applying XX twice to an arbitrary input state, α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. It’s simple algebra, using the fact XX interchanges the ∣0⟩|0\rangle and ∣1⟩|1\rangle states: X(X(α∣0⟩+β∣1⟩))=X(α∣1⟩+β∣0⟩)=α∣0⟩+β∣1⟩\begin{aligned} X(X(\alpha|0\rangle+\beta|1\rangle)) &amp; = X(\alpha|1\rangle + \beta|0\rangle) \\ &amp; = \alpha|0\rangle + \beta|1\rangle \end{aligned} So the net effect is to recover the original quantum state, no matter what that state was. In other words, this circuit is equivalent to a quantum wire: A second way of seeing this is based on the matrix representation we found earlier for the XX gate. Observe that if the input is some arbitrary quantum state ∣ψ⟩|\psi\rangle, then after the first gate the state is X∣ψ⟩X|\psi\rangle, and after the second gate the state is XX∣ψ⟩X X |\psi\rangle. Then we observe that the product XXX X is XX=[0110][0110]=[1001].\begin{aligned} XX &amp; = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right] \\ &amp; = \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; 1 \end{array} \right]. \end{aligned} That is, XXXX is the identity operation, and so the output XX∣ψ⟩XX|\psi\rangle is just the original input ∣ψ⟩|\psi\rangle. In other words, two XX gates is the same as a quantum wire. And so we’ve arrived at the same conclusion in a different way, using matrix multiplication. Doing such matrix multiplications is a pretty common way of analyzing quantum circuits. The Hadamard gate We’ve seen our first quantum gate, the NOT or XX gate. Of course, the XX didn’t appear to do all that much beyond what is possible with a classical NOT gate. In this section I introduce a gate that clearly involves quantum effects, the Hadamard gate. As with the XX gate, we’ll start by explaining how the Hadamard gate acts on computational basis states. Denoting the gate by HH, here’s what it does: H∣0⟩=∣0⟩+∣1⟩2H|0\rangle = \frac{|0\rangle +|1\rangle}{\sqrt 2} H∣1⟩=∣0⟩−∣1⟩2H|1\rangle = \frac{|0\rangle -|1\rangle}{\sqrt 2} Of course, ∣0⟩|0\rangle and ∣1⟩|1\rangle aren’t the only quantum states. How does the Hadamard gate act on more general quantum states? It won’t surprise you to learn that it acts linearly, as did the quantum NOT gate. In particular, the Hadamard gate takes a superposition α∣0⟩+β∣1⟩\alpha|0\rangle + \beta|1\rangle to the corresponding superposition of outputs: H(α∣0⟩+β∣1⟩)=α(∣0⟩+∣1⟩2)+β(∣0⟩−∣1⟩2).H(\alpha|0\rangle + \beta|1\rangle) = \alpha \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} \right) + \beta \left( \frac{|0\rangle-|1\rangle}{\sqrt 2} \right). That’s a mess. We can make it less of a mess by combining the ∣0⟩|0\rangle terms together, and also the ∣1⟩|1\rangle terms together: H(α∣0⟩+β∣1⟩)=α+β2∣0⟩+α−β2∣1⟩.H(\alpha|0\rangle + \beta|1\rangle) = \frac{\alpha+\beta}{\sqrt 2} |0\rangle + \frac{\alpha-\beta}{\sqrt 2}|1\rangle. That’s better, but still not pretty! Fortunately, we mostly won’t be dealing with such complex expressions. The only reason I’ve done it here is to be really explicit. Instead of dealing with such explicit expressions, we’ll mostly work with the HH gate in its circuit and matrix representations (see below). Those let us focus at a more enlightening level of abstraction, rather than messing around with coefficients. Indeed, much work on quantum computing is about attempting to develop ways of moving from low levels of abstraction to higher, more conceptual levels. Up to now most of our work has been at a very low level, seeming more an exercise in linear algebra than a discussion of a new model of computing. That perhaps seems strange. After all, if you were explaining classical computers to someone, you wouldn’t start in the weeds, with AND and NOT gates and the like. You’d start with a well-designed high-level programming language, and then bounce back and forth between different layers of abstraction. Modern computers aren’t just about logic gates – they’re at least as much about beautiful higher-level ideas: say, lazy evaluation, or higher-order functions, or homoiconicity, and so on. I wish I could start with high-level abstractions for quantum computers. However, we’re still in the early days of quantum computing, and for the most part humanity hasn’t yet discovered such high-level abstractions. People are still scratching around, trying to find good ideas. That’s an exciting situation: it means almost all the big breakthroughs are ahead. There’s a sense in which we still understand very little about quantum computing. That might sound surprising: after all, there are great big fat textbooks on the subject. But you could have written a great big fat textbook about the ENIAC computer in the late 1940s. It was, after all, a very complex system. That textbook would have looked intimidating, but it wouldn’t have been the final word in computing. For the most part the way we understand quantum computing today is at an ENIAC-like level, looking at the nuts-and-bolts of qubits and logic gates and linear algebra, and wondering what the higher-level understanding may be. The situation can be thought of as much like programming language design before the breakthroughs that led to languages such as Lisp and Haskell and Prolog and Smalltalk. That makes it a remarkable creative opportunity, a challenge for the decades and centuries ahead. Speaking of nuts-and-bolts, let’s get back to the Hadamard gate. Here’s the circuit representation for the Hadamard gate. It looks just like the XX gate in the circuit representation, except we change the gate label to HH: Just like the XX gate, HH has a matrix representation: H=12[111−1].H = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right]. To see that this matrix representation is correct, let’s check the action of the matrix on the ∣0⟩|0\rangle and the ∣1⟩|1\rangle states. Here we check for the ∣0⟩|0\rangle state: 12[111−1]∣0⟩=12[111−1][10]=12[11]=∣0⟩+∣1⟩2.\begin{aligned} \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] |0\rangle &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \\ &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{c} 1 \\ 1 \end{array} \right] \\ &amp; = \frac{|0\rangle+|1\rangle}{\sqrt 2}. \end{aligned} That is, this matrix acts the same way as the Hadamard gate on the ∣0⟩|0\rangle state. Now let’s check on the ∣1⟩|1\rangle state: 12[111−1]∣1⟩=12[111−1][01]=12[1−1]=∣0⟩−∣1⟩2.\begin{aligned} \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] |1\rangle &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] \\ &amp; = \frac{1}{\sqrt 2} \left[ \begin{array}{c} 1 \\ -1 \end{array} \right] \\ &amp; = \frac{|0\rangle-|1\rangle}{\sqrt 2}. \end{aligned} So the matrix acts the same way as the Hadamard gate on both the ∣0⟩|0\rangle and ∣1⟩|1\rangle states. By the linearity of matrix multiplication it follows that the matrix acts the same way as the Hadamard on all input states, and so they are the same operation. What makes the Hadamard gate interesting as a quantum gate? What can we use it to do? We don’t (quite) have enough background to give precise answers to these questions yet. But there is an analogy which gives insight. Imagine you are living in North Africa, thousands of years in the past, and decide for some reason that you want to get over to the Iberian peninsula. If you don’t yet have boats or some other reliable method of moving across large bodies of water, you need to go all the way across Africa, past the Arabian peninsula, up and around through Europe, back to the Iberian peninsula:   Original photo source: Reto Stöckli, NASA Earth Observatory (2004). Suppose, however, that you invent a new device, the boat, which expands the range of locations you can traverse. Then you can take a much more direct route over to the Iberian peninsula, greatly cutting down the time required:   What the Hadamard and similar gates do is expand the range of operations that it’s possible for a computer to perform. That expansion makes it possible for the computer to take shortcuts, as the computer “moves” in a way that’s not possible in a conventional classical computer. And, we hope, that may enable us to solve some computational problems faster. Another helpful analogy is to the game of chess. Imagine you’re playing chess and the rules are changed in your favor, enabling your rook an expanded range of moves. That extra flexibility might enable you to achieve checkmate much faster because you can get to new positions much more quickly. A similar thing is going on with the Hadamard gate. By expanding the range of states we can access (or, more precisely, the range of dynamical operations we can generate) beyond what’s possible on a classical computer, it becomes possible to take shortcuts in our computation. We’ll see explicit examples in subsequent essays. To get more familiar with the Hadamard gate, let’s analyze a simple circuit: What’s this circuit do? Before we compute, it’s worth pausing for a second to try guessing the result. The point of guessing isn’t to get it right – rather, it’s to challenge yourself to start coming up with heuristic mental models for thinking about what’s going on in quantum circuits. Those mental models likely won’t be very good at first, but that’s okay – if you keep doing this, they’ll get better. Here’s one heuristic you can use to think about this circuit: you can think of HH as sort of mixing the ∣0⟩|0\rangle and ∣1⟩|1\rangle states together. So if you apply HH twice to ∣0⟩|0\rangle, perhaps it would thoroughly mix the ∣0⟩|0\rangle and ∣1⟩|1\rangle up together. What sort of state do you think would result, according to this heuristic? Do you believe the result? Why or why not? Can you think of other heuristics that might help you guess an answer? Alright, let’s compute what actually happens. After we apply the first Hadamard to ∣0⟩|0\rangle we get ∣0⟩+∣1⟩2.\frac{|0\rangle+|1\rangle}{\sqrt{2}}. Then we apply a second Hadamard gate. This takes the ∣0⟩|0\rangle term above to ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} and the ∣1⟩|1\rangle term to ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2}, so the output is: 12(∣0⟩+∣1⟩2+∣0⟩−∣1⟩2).\frac{1}{\sqrt 2} \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} + \frac{|0\rangle-|1\rangle}{\sqrt 2} \right). If you look at the expression above, you’ll notice that the ∣1⟩|1\rangle terms cancel each other out, so you’re just left with the ∣0⟩|0\rangle terms. Collecting them up, we’re left with the ∣0⟩|0\rangle state, same as we started with: 12(∣0⟩2+∣0⟩2)=∣0⟩.\frac{1}{\sqrt 2} \left(\frac{|0\rangle}{\sqrt 2}+ \frac{|0\rangle}{\sqrt 2} \right) = |0\rangle. In a similar fashion, after we run the ∣1⟩|1\rangle state through the first Hadamard gate, we get: ∣0⟩−∣1⟩2.\frac{|0\rangle-|1\rangle}{\sqrt{2}}. Then we apply a second Hadamard gate to get: 12(∣0⟩+∣1⟩2−∣0⟩−∣1⟩2).\frac{1}{\sqrt 2} \left( \frac{|0\rangle+|1\rangle}{\sqrt 2} - \frac{|0\rangle-|1\rangle}{\sqrt 2} \right). This time it’s the ∣0⟩|0\rangle terms which cancel out, and the ∣1⟩|1\rangle terms reinforce. When we collect up these terms, we see that the output is just the ∣1⟩|1\rangle state, same as we started with. And so both the ∣0⟩|0\rangle and ∣1⟩|1\rangle states are left unchanged by this quantum circuit, and the net effect of the circuit is exactly the same as a quantum wire:   There’s an alternate way of seeing this, which I’ll sketch out without working through in detail. It’s to note that if we input an arbitrary quantum state ∣ψ⟩|\psi\rangle to the circuit, then the output must be HH∣ψ⟩H H |\psi\rangle, i.e., the result of applying two HH matrices to ∣ψ⟩|\psi\rangle. But if you just compute the matrix product HHH H it turns out to be the 2×22 \times 2 identity matrix, HH=IH H = I. And so the output from the circuit must be the same as the input, HH∣ψ⟩=I∣ψ⟩=∣ψ⟩HH|\psi\rangle = I |\psi\rangle = |\psi\rangle, just as from a quantum wire. Of course, this result violates our intuitive guess, which was that two Hadamards would thoroughly mix up the ∣0⟩|0\rangle and the ∣1⟩|1\rangle. It’s interesting to ponder what went wrong with our intuition, say by looking through the calculation for HH acting twice on ∣0⟩|0\rangle. You see that after the second gate the ∣1⟩|1\rangle terms exactly cancel one another out, while the ∣0⟩|0\rangle terms reinforce one another. This seems innocuous, almost like a mathematical accident. Still, I draw your attention to it because this type of cancellation or reinforcement is crucial in many algorithms for quantum computers. Without getting into details, the rough way many such algorithms work is to first use Hadamard gates to “spread out” in quantum states like ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} (or many-qubit analogs), i.e., in superpositions of multiple computational basis states. At the end of the algorithm they use clever patterns of cancellation and reinforcement to bring things back together again into one (or possibly a few, in the many-qubit case) computational basis state, containing the desired answer. That’s a somewhat vague and perhaps tantalizing description, but the point to take away is that the kind of cancellation-or-reinforcement we saw above is actually crucial in many quantum computations.  I’ll now pose a few simple exercises related to the Hadamard gate. Unlike the spaced-repetition questions, the point of the exercises below isn’t as an aid to memory, and so you won’t see these exercises repeatedly. Rather, they’re here because (should you choose to work through them) they will help you better understand the material of the essay. But they’ll only incidentally help with memorization. We’ll follow them with some spaced-repetition questions. Note that even if you don't work through the exercises, it's worth at least reading through them, since some of the results will be tested in the spaced-repetition questions.  Exercise: Verify that HH=IHH = I, where II is the 2×22 \times 2 identity matrix, I=[1001]I = \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; 1 \end{array} \right].  Exercise: Suppose that instead of HH we’d defined a matrix JJ by: J:=12[1111]J := \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; 1 \end{array} \right] At first, it might seem that JJ would make an interesting quantum gate, along lines similar to HH. For instance, J∣0⟩=∣0⟩+∣1⟩2J|0\rangle = \frac{|0\rangle+|1\rangle}{\sqrt 2}, and J∣1⟩=∣0⟩+∣1⟩2J|1\rangle = \frac{|0\rangle+|1\rangle}{\sqrt 2}. These are both good, normalized quantum states. But what happens if we apply JJ to the quantum state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2}? Why does this make JJ unsuitable for use as a quantum gate?  Exercise: Consider the quantum circuit:   Explain why the output from this circuit is XH∣ψ⟩XH|\psi\rangle, not HX∣ψ⟩HX|\psi\rangle, as you might naively assume if you wrote down gates in the order they occur in the circuit. This is a common gotcha to be aware of – it occurs because quantum gates compose left-to-right in the circuit representation, while matrix multiplications compose right-to-left.  Measuring a qubit Suppose a (hypothetical!) quantum physicist named Alice prepares a qubit in her laboratory, in a quantum state α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. Then she gives her qubit to another quantum physicist, Bob, but doesn’t tell him the values of α\alpha and β\beta. Is there some way Bob can figure out α\alpha and β\beta? That is, is there some experiment Bob can do to figure out the identity of the quantum state? The surprising answer to this question turns out to be NO! There is, in fact, no way to figure out α\alpha and β\beta if they start out unknown. To put it a slightly different way, the quantum state of any system – whether it be a qubit or a some other system – is not directly observable. I say this is surprising, because it’s very different from our usual everyday way of thinking about how the world works. If there’s something wrong with your car, a mechanic can use diagnostic tools to learn about the internal state of the engine. The better the diagnostic tools, the more they can learn. Of course, there may be parts of the engine that would be impractical to access – maybe they’d have to break a part, or use a microscope, for instance. But you’d probably be rather suspicious if the mechanic told you the laws of physics prohibited them from figuring out the internal state of the engine. Similarly, when you first start learning about quantum circuits, it seems like we should be able to observe the amplitudes of a quantum state whenever we like. But that turns out to be prohibited by the laws of physics. Those amplitudes are better thought of as a kind of hidden information. So, what can we figure out from the quantum state? Rather than somehow measuring α\alpha and β\beta, there are other ways of getting useful information out of a qubit. Let me describe an especially important process called measurement in the computational basis. This is a fundamental primitive in quantum computing: it’s the way we typically extract information from our quantum computers. I’ll explain now how it works for a single qubit, and later generalize to multi-qubit systems. Suppose a qubit is in the state α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle. When you measure this qubit in the computational basis it gives you a classical bit of information: it gives you the outcome 00 with probability ∣α∣2|\alpha|^2, and the outcome 11 with probability ∣β∣2|\beta|^2. To think a little more concretely about this process, suppose your qubit is instantiated in some physical system. Perhaps it’s being stored in the state of an atom somehow. It doesn’t matter exactly what, but you have this qubit in your laboratory. And you have some measurement apparatus, probably something large and complicated, maybe involving lasers and microprocessors and a screen for readout of the measurement result. And this measurement apparatus interacts in some way with your qubit. After the measurement interaction, your measurement apparatus registers an outcome. For instance, it might be that you get the outcome 00. Or maybe instead you get the outcome 11. The crucial fact is that the outcome is ordinary classical information – the stuff you already know how to think about – which you can then use to do other things, and to control other processes. So the way a quantum computation works is that we manipulate a quantum state using a series of quantum gates, and then at the end of the computation (typically) we do a measurement to read out the result of the computation. If our quantum computer is just a single qubit, then that result will be a single classical bit. If, as is more usually the case, it’s multiple qubits, then the measurement result will be multiple classical bits. A fundamental fact about this measurement process is that it disturbs the state of the quantum system. In particular, it doesn’t just leave the quantum state alone. After the measurement, if you get the outcome 00 then the state of the qubit afterwards (the “posterior state”) is the computational basis state ∣0⟩|0\rangle. On the other hand, if you get the outcome 11 then the posterior state of the qubit is the computational basis state ∣1⟩|1\rangle. Summing all this up: if we measure a qubit with state α∣0⟩+β∣1⟩\alpha |0\rangle+\beta|1\rangle in the computational basis, then the outcome is a classical bit: either 00, with probability ∣α∣2|\alpha|^2, or 11, with probability ∣β∣2|\beta|^2. The corresponding state of the qubit after the measurement is ∣0⟩|0\rangle or ∣1⟩|1\rangle. A key point to note is that after the measurement, no matter what the outcome, α\alpha and β\beta are gone. No matter whether the posterior state is ∣0⟩|0\rangle or ∣1⟩|1\rangle, there is no trace of α\alpha or β\beta. And so you can’t get any more information about them. In that sense, α\alpha and β\beta are a kind of hidden information – the measurement doesn’t tell you what they were. One reason this is important is because it means you can’t store an infinite amount of classical information in a qubit. After all, α\alpha is a complex number, and you could imagine storing lots of classical bits in the binary expansion of the real component of α\alpha. If there was some experimental way you could measure the value of α\alpha exactly, then you could extract that classical information. But without a way of measuring α\alpha that’s not possible. I’ve been talking about measurement in the computational basis. In fact, there are other types of measurement you can do in quantum systems. But there’s a sense in which computational basis measurements turn out to be fundamental. The reason is that by combining computational basis measurements with quantum gates like the Hadamard and NOT (and other) gates, it’s possible to simulate arbitrary quantum measurements. So this is all you absolutely need to know about measurement, from an in-principle point of view. It’s useful to have a way of denoting measurements in the quantum circuit model. Here’s a simple example:   It’s a single-qubit quantum circuit, with input the state ∣ψ⟩|\psi\rangle. A NOT gate is applied, followed by a Hadamard gate. The circuit finishes with a measurement in the computational basis, denoted by the slightly elongated semi-circle. The mm is a classical bit denoting the measurement result – either 00 or 11 – and we use the double wire to indicate the classical bit mm going off and being used to do something else. Of course, I said above that after measurement the qubit is in either the ∣0⟩|0\rangle or the ∣1⟩|1\rangle state. You might think we’d draw a corresponding quantum wire coming out the other side of the measurement. But often in quantum circuits the qubit is discarded after measurement, and that’s assumed by this notation. One final comment on measurement is that it’s connected to the normalization condition for quantum states that we discussed earlier. Suppose we have the quantum state: α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle Then the probability of the two possible measurement outcomes, 00 and 11, must sum to 11, and so we have: ∣α∣2+∣β∣2=1.|\alpha|^2+|\beta|^2 = 1. This is exactly the normalization condition for quantum states – i.e., the quantum state must have length 11. The origin of that constraint is really just the fact that measurement probabilities must add up to 11.   Exercise: Suppose we’ve been given either the state ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} or the state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2}, but not told which state we’ve been given. We’d like to figure out which state we’ve been given. If we just do a computational basis measurement, then for both states we get outcome 00 with probability 12\frac 12, and outcome 11 with probability 12\frac 12. So we can’t distinguish the states directly using a computational basis measurement. But suppose instead we put the state into the following circuit:   Show that if the state ∣0⟩+∣1⟩2\frac{|0\rangle+|1\rangle}{\sqrt 2} is input then the output is m=0m = 0 with probability 11, while if the state ∣0⟩−∣1⟩2\frac{|0\rangle-|1\rangle}{\sqrt 2} is input then the output is m=1m = 1 with probability 11. Thus while these two states are indistinguishable if just measured in the computational basis, they can be distinguished with the help of a simple quantum circuit.  General single-qubit gates So far we’ve learned about two quantum gates, the NOT and the Hadamard gate, and also about the measurement process that can be used to extract classical information from our quantum circuits. In this section, I return to quantum gates, and take a look at the most general single-qubit gate. To do that it helps to recall the matrix representations of the NOT and Hadamard gates: X=[0110];    H=12[111−1]\begin{aligned} X = \left[ \begin{array}{cc} 0 &amp; 1 \\ 1 &amp; 0 \end{array} \right]; \,\,\,\, H = \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right] \end{aligned} If the input to these gates is the quantum state ∣ψ⟩|\psi\rangle, then the output is X∣ψ⟩X|\psi\rangle and H∣ψ⟩H|\psi\rangle respectively. A general single-qubit gate works similarly. In particular, a general single-qubit gate can be represented as a 2×22 \times 2 unitary matrix, UU. (If you’re rusty, I’ll remind you what it means for a matrix to be unitary in a moment, and you can just think of it as a matrix for now.) If the input to the gate is the state ∣ψ⟩|\psi\rangle then the output from the gate is U∣ψ⟩U|\psi\rangle. And so the NOT and Hadamard gates correspond to the special cases where U=XU = X and U=HU = H, respectively. What does it mean for a matrix UU to be unitary? It’s easiest to answer this question algebraically, where it simply means that U†U=IU^\dagger U = I, that is, the adjoint of UU, denoted U†U^\dagger, times UU, is equal to the identity matrix. That adjoint is, recall, the complex transpose of UU: U†:=(UT)∗.U^\dagger := (U^T)^*. So for a 2×22 \times 2 matrix, the adjoint operation is just: [abcd]†=[a∗c∗b∗d∗].\left[ \begin{array}{cc} a &amp; b \\ c &amp; d \end{array} \right]^\dagger = \left[ \begin{array}{cc} a^* &amp; c^* \\ b^* &amp; d^* \end{array} \right]. (Note that the †\dagger is also sometimes called the dagger operation, or Hermitian conjugation, or just the conjugation operation. We’ll use all three terms on occasion.) There are a few basic questions you might ask: why are single-qubit gates described by unitary matrices? And how can we get an intuitive feel for what it means for a matrix to be unitary, anyway? While the equation U†U=IU^\dagger U = I is easy to check algebraically, we’d like some intuition for what that equation means. Another natural question is whether the NOT gate and the Hadamard gate are unitary? Of course, we’ll see that they are – I wouldn’t have described them as quantum gates if not – but we should go to the trouble of checking. Yet another good question is whether there are useful examples of single-qubit gates that aren’t the NOT or Hadamard gates? The equation U†U=IU^\dagger U = I is all very well, but it’d be nice to have more concrete examples than just an abstract equation. We’ll answer all these questions over the next few sections. Let’s start by checking the unitarity of the Hadamard gate. We start by computing the adjoint of HH: H†=((12[111−1])T)∗.H^\dagger = \left( \left( \frac{1}{\sqrt 2} \left[ \begin{array}{cc} 1 &amp; 1 \\ 1 &amp; -1 \end{array} \right]\right)^T\right)^*. Note that taking the transpose doesn’t change the matrix, since it is already symmetric. And taking the complex conjugate doesn’t change anything, since all the entries are real. So we have H†=HH^\dagger = H, and thus H†H=HHH^\dagger H = HH. But we saw earlier in the essay that HH=IHH = I. So HH is, indeed, unitary.   Exercise: Show that XX is unitary.  Exercise: Show that the identity matrix II is unitary.  Exercise: Can you find an example of a 2×22 \times 2 matrix that is unitary, and is not II, XX, or HH?  For flavor, let’s give a few more examples of single-qubit quantum gates. Earlier in the essay, I mentioned that the NOT gate XX was introduced by the physicist Wolfgang Pauli in the early days of quantum mechanics. He introduced two other matrices, YY and ZZ, which are also useful quantum gates. The three gates, X,YX, Y, and ZZ are known collectively as the Pauli matrices. The YY and ZZ gates will be useful extra tools in our toolkit of quantum gates; in terms of the earlier analogy they expand the repertoire of moves we have available to us. They’re crucial, for example, in protocols such as quantum teleportation and quantum error correction. The YY gate is similar to the XX gate, but instead of 11s on the off-diagonal, it has ii and −i-i, so it takes ∣0⟩|0\rangle to i∣1⟩i|1\rangle and ∣1⟩|1\rangle to −i∣0⟩-i|0\rangle: Y:=[0−ii0].Y := \left[ \begin{array}{cc} 0 &amp; -i \\ i &amp; 0 \end{array} \right]. The ZZ gate leaves ∣0⟩|0\rangle unchanged, and takes ∣1⟩|1\rangle to −∣1⟩-|1\rangle: Z:=[100−1].Z := \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; -1 \end{array} \right].  Exercise: Show that the YY and ZZ matrices are unitary, and so legitimate quantum gates. Another good example of a quantum gate is a rotation, the kind of matrix you’ve most likely been seeing since high school. It’s just the ordinary rotation of the 22-dimensional plane by an angle θ\theta: [cos⁡(θ)−sin⁡(θ)sin⁡(θ)cos⁡(θ)].\left[ \begin{array}{cc} \cos(\theta) &amp; -\sin(\theta) \\ \sin(\theta) &amp; \cos(\theta) \end{array} \right]. You can easily check that this is a unitary matrix, and so it’s valid quantum gate. And sometimes it’s a very useful quantum gate! That mostly wraps up our little library of single-qubit gates. In the next couple of sections we’ll build up some intuition about what unitarity means, but we won’t add any extra elements to our quantum computing model. In fact, at this point we know almost everything needed for quantum computation. There are just two extra elements needed: extending our description of single qubits to multiple qubits, and describing a simple two-qubit quantum gate. We’ll get to those things shortly – not surprisingly, they look much like what we’ve already seen. I am, by the way, somewhat uncomfortable with some of the questions just asked. My personal experience is that spaced-repetition learning works well when learning facts I have a lot of context for, and care a lot about. It’s a rare person who finds the detailed entries in a unitary matrix fascinating! That’s not to say they aren’t – actually, they are, but you need a lot more context than I’ve provided to see why (for instance) that −i-i in the YY is just so darn interesting. With that said, this essay is genuinely an experiment, and the questions above are included in that spirit. Maybe it will turn out that readers can use spaced-repetition to learn the entries of unitary matrices. And maybe they cannot. No matter which that’ll be a valuable thing to learn about the world, and to inform future experiments with spaced-repetition learning. What does it mean for a matrix to be unitary? Can we get an intuition for what it means for a matrix to be unitary? It turns out that unitary matrices preserve the length of their inputs. In other words, if we take any vector ∣ψ⟩|\psi\rangle and compute the length ∥U∣ψ⟩∥\| U|\psi\rangle \| it’s always equal to the length ∥∣ψ⟩∥\||\psi\rangle\| of the original vector. In this, they’re much like rotations or reflections in ordinary (real) space, which also don’t change lengths. In a sense, the unitary matrices are a complex generalization of real rotations and reflections. Up to now we’ve been dealing mostly with vectors which are states of qubits, i.e., normalized 2-dimensional vectors. But in fact the statement of the last paragraph is true for d×dd \times d unitary matrices, too, i.e., ∥U∣ψ⟩∥=∥∣ψ⟩∥\|U|\psi\rangle\| = \||\psi\rangle\| is true for any vector ∣ψ⟩|\psi\rangle in dd dimensions. The proof is actually pretty simple – mostly, we just compute ∥U∣ψ⟩∥\|U|\psi\rangle \| and use a little algebra to check that it’s equal to the length ∥∣ψ⟩∥\||\psi\rangle\|. But before we get to the proof, observe that this result is good news for quantum gates. The reason is that in a quantum gate the input state will be normalized (have length 11), since that’s a requirement for a quantum state. And we’d expect the corresponding output state to also be normalized, otherwise it wouldn’t be a legitimate quantum state. Fortunately, the length-preserving property of unitary matrices ensures the output state is properly normalized. Recall also the larger story this is part of: not only are gates unitary, to ensure that states remain normalized; also, quantum states are normalized, since measurement probabilities must sum to 11. It all fits together. In fact it turns out that unitary matrices are the only matrices which preserve length in this way. And so a good way of thinking about unitary matrices is that they’re exactly the class of matrices which preserve length. That’s the geometric interpretation (and intuitive meaning) of the algebraic condition U†U=IU^\dagger U = I. Let’s prove now that unitary matrices really are length-preserving. The proof is straightforward. The main thing is to compute ∥U∣ψ⟩∥\|U|\psi\rangle\|. Actually, it’s a little easier to compute the square of the length, ∥U∣ψ⟩∥2\|U|\psi\rangle\|^2. This is just the sum of the squares of the absolute values of the components of the vector U∣ψ⟩U|\psi\rangle: ∥U∣ψ⟩∥2=∑j(Uψ)j∗(Uψ)j\|U|\psi\rangle\|^2 = \sum_j (U\psi)_j^* (U\psi)_j Note that I’ve used (Uψ)j(U\psi)_j to denote the jjth component of U∣ψ⟩U|\psi\rangle, dropping the full ket notation, and just using ψ\psi alone. To proceed, we’ll expand the equation above out, and look for opportunities to apply the unitarity of UU. In particular, the component (Uψ)j(U\psi)_j is given by ∑lUjlψl\sum_l U_{jl} \psi_l and similarly for the complex conjugate term. So we can rewrite the above equation as: ∥U∣ψ⟩∥2=∑jklUjk∗ψk∗Ujlψl\|U|\psi\rangle\|^2 = \sum_{jkl} U_{jk}^*\psi_k^* U_{jl}\psi_l To make use of the unitarity of UU we’ll move the UU terms together, and rewrite in terms of U†U^\dagger. This gives ∥U∣ψ⟩∥2=∑jklUkj†Ujlψk∗ψl,\|U|\psi\rangle\|^2 = \sum_{jkl} U_{kj}^\dagger U_{jl} \psi_k^* \psi_l, where we interchanged the jkjk indices on the first UU in order to rewrite it in terms of U†U^\dagger. The only place the jj index appears anywhere in this equation is in the Ukj†UjlU_{kj}^\dagger U_{jl} term. We can therefore perform the sum over jj and those terms become (U†U)kl(U^\dagger U)_{kl}, which is just the klklth term in the identity matrix, since U†U=IU^\dagger U = I. So the above equation becomes: ∥U∣ψ⟩∥2=∑klδklψk∗ψl.\|U|\psi\rangle\|^2 = \sum_{kl} \delta_{kl} \psi_k^* \psi_l. When we sum, the only time δkl\delta_{kl} is not equal to zero is when k=lk=l, in which case it’s 11. And so we can get rid of one of the summation indices, and the equation simplifies to: ∥U∣ψ⟩∥2=∑kψk∗ψk.\|U|\psi\rangle\|^2 = \sum_{k} \psi_k^* \psi_k. The right-hand side is, of course, equal to the norm of ∣ψ⟩|\psi\rangle squared. And so we’ve shown ∥U∣ψ⟩∥2=∥∣ψ⟩∥2\|U|\psi\rangle\|^2 = \||\psi\rangle\|^2, and therefore ∥U∣ψ⟩∥=∥∣ψ⟩∥\|U|\psi\rangle\| = \||\psi\rangle\|. That completes the proof that unitary matrices are length-preserving. QED  In fact, as I mentioned earlier, it’s also possible to prove that unitary matrices are the only matrices which preserve lengths in this way. Let me state that a little more precisely:  Theorem: Let MM be a matrix. Then ∥M∣ψ⟩∥=∥∣ψ⟩∥\|M|\psi\rangle \| = \||\psi\rangle\| for all vectors ∣ψ⟩|\psi\rangle if and only if MM is unitary. We’ve proved one half of this already; we’ll prove the other half in the next section. This theorem answers many of our questions from earlier: we see why quantum gates must be unitary, since they’re the only matrices which preserve normalization. Of course, it doesn’t completely answer the question, since it doesn’t tell us why quantum gates should be matrices (i.e., linear operations) in the first place. That fact we’re simply going to accept. In fact, it is possible to develop deeper levels of understanding of why that is true, but in this essay we’ll be satisfied with the partial explanation that unitary matrices are length-preserving. Why are unitaries the only matrices which preserve length? Alright, let’s prove the missing part from the last section: let’s show that unitaries are the only matrices which preserve length. The proof is a little messy. But it turns out to be a good way to get familiar with a few extra pieces of standard quantum mechanical terminology and notation. I’ll be frank: while these pieces of terminology are extremely useful in quantum computing, we don’t strictly need them elsewhere in this essay (though we will in later essays). If you want to skip the section, or skim it, that’s okay – this is the best section of the essay to skip. But at some point you should come back and work through the material. And there is, in any case, a certain beauty to the proof. We’ve been dealing with 2-dimensional vectors up to now, but what I’m about to say applies no matter how many dimensions we’re working in. So suppose we have a vector ∣ψ⟩|\psi\rangle which can be written in component form as: ∣ψ⟩=[ab⋮z].|\psi\rangle = \left[ \begin{array}{c} a \\ b \\ \vdots \\ z \end{array} \right]. We’re going to define a new object, also labeled with a ψ\psi, but now with a bracket in the other direction: ⟨ψ∣:=[a∗b∗…z∗].\langle \psi| := [a^* b^* \dots z^*]. That is, ⟨ψ∣\langle\psi| is a row vector, whose entries are the same as ∣ψ⟩|\psi\rangle, but complex conjugated. The vector ∣ψ⟩|\psi\rangle was called a ket, and (you’re going to groan) ⟨ψ∣\langle \psi| is called a bra, making this the bra-ket, or bracket notation. Yes, theoretical physicists make dad jokes, too. These names were given by the theoretical physicist Paul Dirac in 1939, and it’s often called the Dirac bra-ket notation, or sometimes just the Dirac notation. A key fact about the bra ⟨ψ∣\langle \psi| is that it’s related to the ket ∣ψ⟩|\psi\rangle by the dagger operation: ∣ψ⟩†=⟨ψ∣.|\psi\rangle^\dagger = \langle \psi|. It’s easy to see why this identity is true. Take the vector ∣ψ⟩=[ab⋮z],|\psi\rangle = \left[ \begin{array}{c} a \\ b \\ \vdots \\ z \end{array} \right], and apply the dagger operation, which means taking the transpose, turning it into a row vector with entries a,b,…,za, b, \ldots, z, and then take the complex conjugate, giving us [a∗b∗…z∗][a^* b^* \ldots z^*], which is just the definition of ⟨ψ∣\langle \psi|. In a similar way we see that ⟨ψ∣†=∣ψ⟩\langle \psi|^\dagger = |\psi\rangle. Another useful identity expresses the length of ∣ψ⟩|\psi\rangle in terms of the Dirac notation: ∥∣ψ⟩∥2=⟨ψ∣∣ψ⟩.\||\psi\rangle\|^2 = \langle \psi| |\psi\rangle. That is, the length squared is just equal to the product of the row vector ⟨ψ∣\langle \psi| with the column vector ∣ψ⟩|\psi\rangle. To prove it just notice that the right-hand side is [a∗b∗…][ab⋮]=∣a∣2+∣b∣2+…[a^* b^* \ldots ] \left[ \begin{array}{c} a \\ b \\ \vdots \end{array} \right] = |a|^2 + |b|^2 + \ldots And that, of course, is ∥∣ψ⟩∥2\||\psi\rangle\|^2, just as we wanted. Physicists using the Dirac notation don’t usually write ⟨ψ∣∣ψ⟩\langle \psi| |\psi\rangle. They simplify it slightly, omitting one of the vertical bars ∣| in the middle, and just write it as: ⟨ψ∣ψ⟩.\langle \psi| \psi \rangle. It’s only a slight simplification, but this omission of the extra bar turns out to make life considerably easier, and is well worth it. I’ve shown it above just for the special case of ⟨ψ∣ψ⟩\langle \psi| \psi \rangle but the same omission of a vertical bar is done often in other contexts. In practice, it rarely causes confusion, although of course you do need to get used to it. Another useful identity is that if MM is a matrix and ∣ψ⟩|\psi\rangle is a ket, then (M∣ψ⟩)†=⟨ψ∣M†.(M|\psi\rangle)^\dagger = \langle \psi|M^\dagger. If you think of ⟨ψ∣\langle \psi| as the dagger of ∣ψ⟩|\psi\rangle, then what this equation means is that taking the dagger of the product M∣ψ⟩M|\psi\rangle is the same as taking the product of the dagger of MM with the dagger ∣ψ⟩|\psi\rangle, but reversing the order. This is a useful little mnemonic for remembering the above identity. The identity is easy to prove. As a challenge to yourself you might want to stop right now and take a shot at proving it. Here’s the details if you get stuck.  Proof: The way to prove the identity is to apply the definitions. We’re going to look at the jjth component of the left-hand side, (M∣ψ⟩)j†(M|\psi\rangle)^\dagger_j, and we’ll show it’s equal to the jjth component of the right-hand side. By definition, the jjth row component (M∣ψ⟩)j†(M|\psi\rangle)^\dagger_j is equal to the complex conjugate of the jjth column component of M∣ψ⟩M|\psi\rangle, i.e., (M∣ψ⟩)j∗(M|\psi\rangle)^*_j. That column component is ∑kMjk∗ψk∗\sum_k M_{jk}^* \psi_k^*. We can move the ψ\psi terms to the left, and swap the indices on the MM term to convert the ∗* to a dagger, giving ∑kψk∗Mkj†\sum_k \psi_k^* M_{kj}^\dagger. That’s just the jjth component of the row vector ⟨ψ∣M†\langle \psi|M^\dagger, as we set out to show. QED   With all these ideas in mind, here’s an exercise for you to work through, putting several of these ideas together:  Exercise: Show that for any matrix MM and vector ∣ψ⟩|\psi\rangle, the following identity holds, expressing the length of M∣ψ⟩M|\psi\rangle: ∥M∣ψ⟩∥2=⟨ψ∣M†M∣ψ⟩.\|M|\psi\rangle\|^2 = \langle\psi|M^\dagger M |\psi\rangle.  You may be wondering why we care about all these identities? Of course, really I’m just frontloading them – they’re all identities we’re going to find useful in a moment in the proof. So in some sense they are a bit ad hoc in motivation. But an underlying theme is that they’re about relating lengths to matrix operations. And it’s not so surprising that’s of interest – we’re going to assume we have a length-preserving operation. It’s very convenient to be able to relate that property to familiar operations about matrix multiplication. That’s the essential source of the interest in the above identities. Alright, we’ve been working through some heavy, detailed material. We’ve got just a little more background to get through, but it’s easier going. I’m going to introduce a unit vector, denoted ∣ej⟩|e_j\rangle, meaning the vector with a 11 in the jjth component, and 00s everywhere else. So, for instance, for a qubit: ∣e0⟩=[10]∣e1⟩=[01]\begin{aligned} |e_0\rangle &amp; = \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] \\ |e_1\rangle &amp; = \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] \end{aligned} From elementary linear algebra, if MM is a matrix, then M∣ek⟩M|e_k\rangle is just the kkth column of MM. (If you don’t recall that from elementary linear algebra, I encourage you to stop and figure out why it’s true.) And from that you can deduce easily that ⟨ej∣M∣ek⟩\langle e_j|M|e_k\rangle is the jkjkth entry of MM.  Exercise: If you’re not familiar with the proof, show that M∣ek⟩M|e_k\rangle is the kkth column of the matrix MM, and that ⟨ej∣M∣ek⟩\langle e_j|M|e_k\rangle is the jkjkth entry of MM. Alright, that’s more than enough notational background! Let’s get to the main event. In particular, let’s recall the statement of the theorem we want to complete the proof of. Also recall that we proved the reverse implication in the last section, so we just need to prove the forward implication:  Theorem: Let MM be a matrix. Then ∥M∣ψ⟩∥=∥∣ψ⟩∥\|M|\psi\rangle \| = \| |\psi\rangle\| for all vectors ∣ψ⟩|\psi\rangle if and only if MM is unitary.  Proof: We’ll assume MM is length-preserving, and analyze the matrix M†MM^\dagger M. Our goal is to show that this is the identity matrix, and thus MM is unitary. To do this, we’re going to start by analyzing the diagonal elements (M†M)jj(M^\dagger M)_{jj}, and show that they’re all equal to 11. Then we’ll turn our attention to the off-diagonal elements and show that they’re all equal to 00. To understand the diagonal elements, we know from earlier that: (M†M)jj=⟨ej∣M†M∣ej⟩=∥M∣ej⟩∥2(M^\dagger M)_{jj} = \langle e_j|M^\dagger M|e_j\rangle = \|M|e_j\rangle\|^2. But since MM is length-preserving, the latter is just ∥∣ej⟩∥2\||e_j\rangle\|^2, which is 11. And so we conclude that all the diagonal elements are, indeed, 11. What about the off-diagonal elements, i.e., (M†M)jk(M^\dagger M)_{jk} where j≠kj \neq k? Can we show that these are all equal to 00? Well, what we’d like to do is somehow to relate (M†M)jk(M^\dagger M)_{jk} to the length of some vector M∣ψ⟩M|\psi\rangle, and then use the length-preserving property. One idea is to try using ∣ψ⟩=∣ej⟩+∣ek⟩|\psi\rangle = |e_j\rangle + |e_k\rangle, since that involves both the jjth and kkth directions. From the length-preserving property we have: ∥M∣ψ⟩∥2=∥∣ψ⟩∥2=12+12=2.\|M|\psi\rangle\|^2 = \| |\psi\rangle\|^2 = 1^2+1^2 = 2. We also have: ∥M∣ψ⟩∥2=⟨ψ∣M†M∣ψ⟩=⟨ej∣M†M∣ej⟩+⟨ej∣M†M∣ek⟩==+⟨ek∣M†M∣ej⟩+⟨ek∣M†M∣ek⟩=1+⟨ej∣M†M∣ek⟩+⟨ek∣M†M∣ej⟩+1\begin{aligned} \|M|\psi\rangle\|^2 &amp; = \langle \psi| M^\dagger M |\psi\rangle \\ &amp; = \langle e_j|M^\dagger M|e_j\rangle + \langle e_j|M^\dagger M|e_k\rangle \\ &amp; \hphantom{ == } + \langle e_k|M^\dagger M|e_j\rangle + \langle e_k|M^\dagger M |e_k\rangle \\ &amp; = 1 + \langle e_j|M^\dagger M|e_k\rangle + \langle e_k|M^\dagger M|e_j\rangle + 1 \end{aligned} Comparing the last two sets of equations, we have: ⟨ej∣M†M∣ek⟩+⟨ek∣M†M∣ej⟩=0.\langle e_j|M^\dagger M|e_k\rangle + \langle e_k|M^\dagger M|e_j\rangle = 0. This is close to what we want, but isn’t quite right. It tells us that (M†M)jk+(M†M)kj=0(M^\dagger M)_{jk} + (M^\dagger M)_{kj} = 0. Can we do better? It’s tempting to go back and fiddle around and try to find some way of eliminating one or the other of those terms. But there’s no direct way to do it – at least, no direct way that I know of. But what if we’d done something slightly different, and instead of using ∣ψ⟩=∣ej⟩+∣ek⟩|\psi\rangle = |e_j\rangle+|e_k\rangle we’d used ∣ψ⟩=∣ej⟩+i∣ek⟩|\psi\rangle = |e_j\rangle+i|e_k\rangle? It seems pretty plausible that following the same line of reasoning we’d get an equation involving (M†M)jk(M^\dagger M)_{jk} and (M†M)kj(M^\dagger M)_{kj} again. I won’t explicitly go through the steps – you can do that yourself – but if you do go through them you end up with the equation: (M†M)jk−(M†M)kj=0.(M^\dagger M)_{jk} - (M^\dagger M)_{kj} = 0. This is great! We can add it to the earlier equation to deduce that (M†M)jk=0(M^\dagger M)_{jk} = 0 whenever j≠kj \neq k, and so we conclude that M†M=IM^\dagger M = I, i.e., MM is unitary. QED  The controlled-NOT gate We’ve developed most of the ideas needed to do universal quantum computing. We understand qubits, quantum states, and have a repertoire of quantum gates. However, all our gates involve just a single qubit. To compute, we need some way for qubits to interact with one another. That is, we need quantum gates which involve two (or more) qubits. An example of such a gate is the controlled-NOT (or CNOT) gate. In the quantum circuit language we have two wires, representing two qubits, and the following notation to represent the CNOT gate:   The wire with the small, filled dot on it (the top wire, in this example) is called the control qubit, for reasons which will become clear in a moment. And the wire with the larger, unfilled circle on it is called the target qubit. Up to now I haven’t said what the possible states of a two-qubit system are, but you can probably guess. We now have four computational basis states, corresponding to the four possible states of a two-bit system: ∣00⟩,∣01⟩,∣10⟩|00\rangle, |01\rangle, |10\rangle, and ∣11⟩|11\rangle. And, for a two-qubit system, not only can we have those four states, we can also have superpositions (i.e., linear combinations) of them: α∣00⟩+β∣01⟩+γ∣10⟩+δ∣11⟩\alpha|00\rangle+\beta|01\rangle+\gamma |10\rangle+\delta|11\rangle Here, the amplitudes α,β,γ,δ\alpha, \beta, \gamma, \delta are just complex numbers, and the sum of the squares of the absolute values is 11, i.e, ∣α∣2+∣β∣2+∣γ∣2+∣δ∣2=1|\alpha|^2+|\beta|^2+|\gamma|^2+|\delta|^2 = 1. This is the same kind of normalization condition as we had for a single qubit. Now, the CNOT gate is, much like the quantum NOT gate, inspired directly by a classical gate. What it does is very simple. If the control qubit is set to 11, as in the states ∣10⟩|10\rangle and ∣11⟩|11\rangle, then it flips (i.e., NOTs) the target qubit. And otherwise it does nothing. Writing out the action on all four computational basis states we have: ∣00⟩→∣00⟩∣01⟩→∣01⟩∣10⟩→∣11⟩∣11⟩→∣10⟩\begin{aligned} |00\rangle &amp; \rightarrow &amp; |00\rangle \\ |01\rangle &amp; \rightarrow &amp; |01\rangle \\ |10\rangle &amp; \rightarrow &amp; |11\rangle \\ |11\rangle &amp; \rightarrow &amp; |10\rangle \end{aligned} If you’re familiar with classical programming languages, then you can think of the CNOT as a very simple kind of if-then statement: if the control qubit is set, then NOT the target qubit. But while simple, it can be used as a building block to build up other, more complex kinds of conditional behavior. There’s a way of summing up all four of the equations above in a single equation. Suppose xx and yy are classical bits, i.e., 00 or 11. Then we can rewrite the equations above in a single equation as: ∣x,y⟩→∣x,y⊕x⟩.\begin{aligned} |x, y\rangle &amp; \rightarrow &amp; |x, y\oplus x\rangle. \end{aligned} Note the commas inserted to make this easier to read – this is pretty common in working with multi-qubit states. The above equation makes clear that the CNOT leaves the control qubit xx alone, but flips the target qubit yy if xx is set to 11. Note that ⊕\oplus is addition modulo 22, where 1⊕1=01 \oplus 1 = 0, as we would expect from the fact that the CNOT takes ∣11⟩|11\rangle to ∣10⟩|10\rangle. That’s all there is to the CNOT. It’s really a very simple idea and quantum gate. Note that it of course acts linearly on superpositions of computational basis states, as we expect for a quantum gate. So: →α∣00⟩+β∣01⟩+γ∣10⟩+δ∣11⟩→α∣00⟩+β∣01⟩+γ∣11⟩+δ∣10⟩\begin{aligned} &amp; \hphantom{ \rightarrow } \alpha|00\rangle+\beta|01\rangle+\gamma |10\rangle+\delta|11\rangle \\ &amp; \rightarrow \alpha|00\rangle+\beta|01\rangle+\gamma |11\rangle+\delta|10\rangle \end{aligned} And, though I won’t explicitly carry out the verification, the CNOT is unitary, and thus preserves the length of quantum states, as we expect. Of course, the CNOT doesn’t just appear in two-qubit computations. It also appears in computations involving more qubits. Let’s suppose we have three qubits, for instance, and computational basis states such as ∣000⟩,∣001⟩|000\rangle, |001\rangle, and so on. Here’s a CNOT with the second qubit as the control qubit and the third qubit as the target:   What goes on? Well, we can write out what happens on an arbitrary computational basis state, ∣x,y,z⟩|x, y, z\rangle, where x,yx, y and zz are all classical bits. Of course, the first bit xx isn’t changed at all, since it’s not involved in the CNOT. The second bit yy is the control bit, and so isn’t changed. But the third bit zz is flipped if the control bit yy is set to 11. And so we can write the action of the CNOT as: ∣x,y,z⟩→∣x,y,z⊕y⟩|x,y,z\rangle \rightarrow |x,y, z\oplus y\rangle I’ve described the CNOT as a “classical” gate, but it can be combined with single-qubit gates to do non-classical things. Let me give you an explicit example. It’s another two-qubit computation. It starts with the ∣00⟩|00\rangle computational basis state, we apply a Hadamard gate to the first qubit, and then do a CNOT:   Recall that for a single qubit the Hadamard gate takes ∣0⟩|0\rangle to an equal superposition (∣0⟩+∣1⟩)/2(|0\rangle+|1\rangle)/\sqrt{2}. For these two qubits it doesn’t affect the second qubit at all, and so it takes ∣00⟩|00\rangle to (∣00⟩+∣10⟩)/2(|00\rangle+|10\rangle)/\sqrt{2}. Next we apply the CNOT gate. This leaves the ∣00⟩|00\rangle state unchanged, since the control bit is 00. And it takes ∣10⟩|10\rangle to ∣11⟩|11\rangle, since the control bit is 11. And so the output from the circuit is: ∣00⟩+∣11⟩2.\frac{|00\rangle+|11\rangle}{\sqrt 2}. This output state is a highly non-classical state – it’s actually a type of state called an entangled state. There’s no obvious interpretation of this state as a classical state, unlike say a computational basis state such as ∣00⟩|00\rangle. In fact, entangled states can be used to do all sorts of interesting information processing tasks, including quantum teleportation and fast quantum algorithms. A point I glossed over above, but worth mentioning: in the circuit I drew ∣0⟩|0\rangle and ∣0⟩|0\rangle separately as input qubits. It’s conventional to do that kind of thing to denote a combined input of ∣00⟩|00\rangle. More generally, people use ∣0⟩∣0⟩|0\rangle|0\rangle interchangeably with ∣00⟩|00\rangle, ∣0⟩∣1⟩|0\rangle|1\rangle interchangeably with ∣01⟩|01\rangle, and so on. Going back and forth takes a bit of getting used to, but everything works pretty much as you expect, and you just need a little practice before it seems quite natural. More generally, if we have single-qubit states α∣0⟩+β∣1⟩\alpha|0\rangle+\beta|1\rangle and γ∣0⟩+δ∣1⟩\gamma|0\rangle+\delta|1\rangle, then the combined state when the two qubits are put together is just: =(α∣0⟩+β∣1⟩)(γ∣0⟩+δ∣1⟩)=αγ∣00⟩+αδ∣01⟩+βγ∣10⟩+βδ∣11⟩.\begin{aligned} &amp; \hphantom{ = } (\alpha|0\rangle+\beta|1\rangle)(\gamma|0\rangle+\delta|1\rangle) \\ &amp; = \alpha\gamma|00\rangle+\alpha\delta |01\rangle+ \beta\gamma |10\rangle+ \beta\delta |11\rangle. \end{aligned} I said that the CNOT leaves the control qubit alone, and modifies the target qubit. That’s true in the computational basis. In fact, it’s actually possible for the target qubit to affect the control qubit. It’s worth taking a minute or two to at least understand (and, if you’re feeling energetic, attempting to solve) the following exercise:  Exercise: Can you find single-qubit states ∣a⟩|a\rangle and ∣b⟩|b\rangle so that applying a CNOT to the combined state ∣ab⟩|ab\rangle changes the first qubit, i.e., the control qubit? Let me give you an example which solves the above exercise. Suppose we introduce single-qubit states ∣+⟩|+\rangle and ∣−⟩|-\rangle, defined by: ∣+⟩:=∣0⟩+∣1⟩2∣−⟩:=∣0⟩−∣1⟩2\begin{aligned} |+\rangle &amp; := \frac{|0\rangle+|1\rangle}{\sqrt 2} \\ |-\rangle &amp; := \frac{|0\rangle-|1\rangle}{\sqrt 2} \end{aligned} A mnemonic for this notation is that these are both equal superpositions of ∣0⟩|0\rangle and ∣1⟩|1\rangle, but the “+” or “-” corresponds to the sign of the amplitude for the ∣1⟩|1\rangle state. The following circuit identity holds:   That is, if we put ∣+−⟩|+-\rangle in, then ∣−−⟩|--\rangle comes out, i.e., the target qubit isn’t changed, but the control qubit is! The proof is just to follow the definitions and the algebra through. It’s honestly not terribly enlightening to follow the algebra through at this point – it’s a lot easier once certain other facts are known to you. But, again, if you’re feeling enthusiastic it’s a good exercise to work through to become familiar with how things work. It’s worth taking some caution from this example. It means that intuitions coming from the computational basis can sometimes be incomplete or misleading. The CNOT isn’t simply doing something to the target, conditional on the control. It’s also doing something to the control, conditional on the target.   Exercise: Show that the inverse of the CNOT gate is just the CNOT gate.  Part III: Universal quantum computing In natural science, Nature has given us a world and we’re just to discover its laws. In computers, we can stuff laws into it and create a world.— Alan Kay  Let’s return to the question we began with: is there a single computing device that can efficiently simulate any other physical system? At the moment, the best candidate humanity has for such a computing device is a quantum computer. As you’ve probably guessed, you make such a device by combining all the elements we’ve been discussing. In Part III of this essay we’ll discuss what a quantum computer is, why they’re useful, and whether they can be used to efficiently simulate any other physical system. The quantum computing model The theory of computation has traditionally been studied almost entirely in the abstract, as a topic in pure mathematics. This is to miss the point of it. Computers are physical objects, and computations are physical processes. What computers can or cannot compute is determined by the laws of physics alone, and not by pure mathematics.— David Deutsch  In a general quantum computation, you start out with many qubits – I’ll draw four here, but in general it might be many more (or less). You apply quantum gates of various kinds, in particular, single-qubit gates and CNOT gates. And at the end of the circuit you read out the result by measuring in the computational basis. Here’s what it all looks like:   I haven’t labeled the single-qubit gates explicitly, but they might be various things – Hadamard gates, NOT gates, rotations, and perhaps others. Note also that while the computation starts in the computational basis state ∣0000⟩|0000\rangle, you can also start in some other computational basis state. I’ve just chosen ∣0000⟩|0000\rangle for definiteness. We can summarize the three steps in a quantum computation as follows:  Start in a computational basis state. Apply a sequence of CNOT and single-qubit gates. To obtain the result, measure in the computational basis. The probability of any result, say 00…000\ldots 0, is just the square of the absolute value of the corresponding amplitude.  That’s all a general quantum computation is! If you understand this model, you know what a quantum computer is. It's pretty simple, really – enough so that I've sometimes heard people say “Is that all there is to it?” But while the model is simple, it contains remarkable depths, and exploring it could occupy many lifetimes. In practice, people sometimes introduce other ideas into the way they describe quantum computations. If you’re a programmer, you can think of this as like the way programming language designers introduce higher-level abstractions to help people design different kinds of programs. In principle, those abstractions can always be reduced down to the level of AND and NOT gates. And if you understand that level – AND and NOT, or the type of quantum circuit shown above – then you have a foundation for building an understanding of the other ideas. That may leave you wondering: does that mean you also need to master all the higher-level abstractions? The answer is no! There are several reasons for this. One reason is that, as we discussed earlier, humanity doesn’t yet know what the higher-level abstractions are. We’re still trying to figure them out. A second reason is that it seems likely that the list of higher-level abstractions is inexhaustible. My guess – and it’s just a guess – is that we will continue to discover beautiful new abstractions forever, in both classical and quantum computing. A related idea is that there are models of quantum computation different to the quantum circuit model. Some are merely small variations on the model I’ve described. For instance, instead of only using CNOT gates, we might allow any two-qubit unitary gate to be used in the circuit. Or perhaps instead of using qubits, we might use some other type of basic quantum system – say, the qutrit, which has three computational basis states, ∣0⟩,∣1⟩|0\rangle, |1\rangle, and ∣2⟩|2\rangle. It probably won’t surprise you that the resulting models of computation are essentially equivalent to the quantum circuit model I’ve described. By this, I mean they can simulate the quantum circuit model (and vice versa) using roughly comparable numbers of gates and other physical resources. There are also much more exotic variations, ideas such as measurement-based quantum computation, topological quantum computation, and others. I won’t describe these in any detail here, but suffice to say that they appear superficially very different to the circuit model. Nonetheless, they’re all mathematically equivalent to one another, including to the quantum circuit model. Thus a quantum computation in any of those models can be translated into an equivalent in the quantum circuit model, with only a small overhead in the cost of computation. And vice versa. You may wonder why people bother thinking about other models, if they’re mathematically equivalent to the quantum circuit model. The reason is that just because two models are mathematically equivalent doesn’t mean they’re psychologically equivalent. Different models of computation stimulate different ways of thinking, and give rise to different ideas. And so it’s valuable to have other equivalent models.   Exercise: We saw earlier that composition of quantum gates corresponds to matrix multiplication (in reverse order). Show that the product of two unitary matrices UU and VV is also unitary. As a consequence, the net effect of any quantum circuit (before measurement) is to effect a unitary operation on the state space of the system.  Let me conclude this section with a brief comment about a particular class of quantum gates. These are gates which are multiples of the identity matrix, II: [eiθ00eiθ]=eiθ[1001]=eiθI.\begin{aligned} \left[ \begin{array}{cc} e^{i\theta} &amp; 0 \\ 0 &amp; e^{i\theta} \end{array} \right] = e^{i\theta} \left[ \begin{array}{cc} 1 &amp; 0 \\ 0 &amp; 1 \end{array} \right] = e^{i \theta} I. \end{aligned} When θ\theta is a real number this is a unitary matrix, and so a valid quantum gate. The effect of the gate is simply to multiply the state of the quantum computer by eiθe^{i\theta}. The number eiθe^{i\theta} is called a global phase factor. But even though the gate is valid, we rarely explicitly put such gates into quantum circuits. The reason is that such global phase factors have no impact on the results of the computation. To see why, imagine a quantum circuit which includes many such quantum gates, possibly for different values, θ1,θ2,…\theta_1, \theta_2, \ldots. No matter where in the circuit the gates occur, the net effect is to multiply the state output from the circuit by an overall factor of eiθ1+iθ2+…e^{i \theta_1 + i\theta_2 + \ldots}. This doesn’t change the squared amplitudes of the computational basis states, and so has no impact on the measurement probabilities at the end of the computation. We could have left the gates out and it would make no difference. Quantum computing people tend to be rather blase about such global phase factors. They’ll do things like not bother to distinguish between unitary gates such as XX and −X-X, saying these gates are “the same up to a global phase factor”. They simply mean the −X-X gate is the same as doing the XX gate, followed by the −I-I gate. Since the latter gate makes no difference to the output from the computation, it can safely be omitted. We’ll see examples in the next essay, about the quantum search algorithm, where at a couple of places it makes sense to multiply the quantum state by a global phase factor of −1-1. What are quantum computers good for? Now we know what a quantum computer is, what are they good for? Earlier, I suggested quantum computers expand the range of operations available when computing. This is similar to the way boats expand the range of ways we can traverse space, so instead of having to get from point A to point B by land,   we can take a shortcut greatly cutting down the time required:   In order for the analogous story to hold for quantum computers, they need to be at least as capable as classical computers. Fortunately, it’s possible to convert any classical circuit into a quantum circuit. This requires some care. The obvious thing to do is to imagine that your classical circuit is expressed in terms of some standard universal set – say, the AND and NOT gates – and then to convert those gates into equivalent quantum gates. This is easy to do with the NOT gate – we just turn it into an XX gate. But what’s not so easy is the AND gate. You might wonder if there’s some quantum gate which takes two bits xx and yy as input, in the computational basis, ∣x,y⟩|x,y\rangle, and then outputs a single qubit ∣x∧y⟩|x \wedge y\rangle, where x∧yx \wedge y is just the logical AND of the bits xx and yy. Unfortunately, that “quantum gate” makes no sense at all! Not only is it not unitary, it’s not even close: a unitary gate with two qubits as input necessarily has two qubits as output. The “gate” I described has just a single qubit as output, so there’s no way it can be unitary. You might wonder if instead there’s some way we can find a two-qubit quantum gate which has x∧yx \wedge y as one output, and something else as the other output. I won’t prove it, but it turns out that this is impossible. The proof actually isn’t all that hard – it’s a fun exercise to think through, if you want a challenge – but is more of a digression than I want to get into here. That’s all rather disappointing. But there is a solution. It’s to use a three-qubit quantum gate called the Toffoli gate. The Toffoli gate is much like the CNOT gate, but instead of having a single control qubit, it has two control qubits, xx and yy, and a single target qubit, zz. If both controls qubits are set, then the target is flipped. Otherwise, the target is left alone:   If the target starts out as z=0z = 0, then you can see that the target output is just x∧yx \wedge y, and so the Toffoli gate can be used to simulate a classical AND gate. So if we have any classical circuit of AND and NOT gates then there’s a corresponding quantum circuit involving the same number of XX and Toffoli gates which computes the same function.   Exercise: What’s a quantum circuit that can compute the NAND gate? Recall that the NAND of two bits xx and yy is just the NOT of x∧yx \wedge y.  Exercise: Can you find a way of implementing a NAND gate using just a single Toffoli gate and no other quantum gates? Note that your answer here may be the same as your answer to the previous exercise, if you answered that exercise using just a single Toffoli gate and no other quantum gates.  A wrinkle in all this is that the Toffoli gate isn’t in our standard set of basic quantum gates. However, it’s possible to build the Toffoli gate up out of CNOT and single-qubit unitary gates. One way of doing the breakdown is shown below:   There are various slick ways of “explaining” why this circuit works, but I’ll let you in on a secret: much of the earliest work on this was done by pure brute force, people simply trying lots and lots of different ways of implementing the Toffoli gate (sometimes, using a computer to assist in doing the search). Frankly, I wouldn’t worry too much about why this circuit works, just take it for granted that it does. You can look it up if you ever need to, or dig down into why. Needing to know the circuit details actually isn’t all that common, so I wouldn’t suggest memorizing it – not until you have a good reason.   Exercise: Show that the inverse of the Toffoli gate is just the Toffoli gate.  No, really, what are quantum computers good for? It’s comforting that we can always simulate a classical circuit – it means quantum computers aren’t slower than classical computers – but doesn’t answer the question of the last section: what problems are quantum computers good for? Can we find shortcuts that make them systematically faster than classical computers? It turns out there’s no general way known to do that. But there are some interesting classes of computation where quantum computers outperform classical. Over the long term, I believe the most important use of quantum computers will be simulating other quantum systems. That may sound esoteric – why would anyone apart from a quantum physicist care about simulating quantum systems? But everybody in the future will (or, at least, will care about the consequences). The world is made up of quantum systems. Pharmaceutical companies employ thousands of chemists who synthesize molecules and characterize their properties. This is currently a very slow and painstaking process. In an ideal world they’d get the same information thousands or millions of times faster, by doing highly accurate computer simulations. And they’d get much more useful information, answering questions chemists can’t possibly hope to answer today. Unfortunately, classical computers are terrible at simulating quantum systems. The reason classical computers are bad at simulating quantum systems isn’t difficult to understand. Suppose we have a molecule containing nn atoms – for a small molecule, nn may be 11-1010, for a complex molecule it may be hundreds or thousands or even more. And suppose we think of each atom as a qubit (not true, but go with it): to describe the system we’d need 2n2^n different amplitudes, one amplitude for each nn-bit computational basis state, e.g., ∣010011…⟩|010011\ldots\rangle. Of course, atoms aren’t qubits. They’re more complicated, and we need more amplitudes to describe them. Without getting into details, the rough scaling for an nn-atom molecule is that we need knk^n amplitudes, where k≥2k \geq 2. The value of kk depends upon context – which aspects of the atom’s behavior are important. For generic quantum simulations kk may be in the hundreds or more. That’s a lot of amplitudes! Even for comparatively simple atoms and small values of nn, it means the number of amplitudes will be in the trillions. And it rises very rapidly, doubling or more for each extra atom. If k=100k=100, then even n=10n = 10 atoms will require 100 million trillion amplitudes. That’s a lot of amplitudes for a pretty simple molecule. The result is that simulating such systems is incredibly hard. Just storing the amplitudes requires mindboggling amounts of computer memory. Simulating how they change in time is even more challenging, involving immensely complicated updates to all the amplitudes. Physicists and chemists have found some clever tricks for simplifying the situation. But even with those tricks simulating quantum systems on classical computers seems to be impractical, except for tiny molecules, or in special situations. The reason most educated people today don’t know simulating quantum systems is important is because classical computers are so bad at it that it’s never been practical to do. We’ve been living too early in history to understand how incredibly important quantum simulation really is. That’s going to change over the coming century. Many of these problems will become vastly easier when we have scalable quantum computers, since quantum computers turn out to be fantastically well suited to simulating quantum systems. Instead of each extra simulated atom requiring a doubling (or more) in classical computer memory, a quantum computer will need just a small (and constant) number of extra qubits. One way of thinking of this is as a loose quantum corollary to Moore’s law:  The quantum corollary to Moore’s law: Assuming both quantum and classical computers double in capacity every few years, the size of the quantum system we can simulate scales linearly with time on the best available classical computers, and exponentially with time on the best available quantum computers. In the long run, quantum computers will win, and win easily. The punchline is that it’s reasonable to suspect that if we could simulate quantum systems easily, we could greatly speed up drug discovery, and the discovery of other new types of materials. I will risk the ire of my (understandably) hype-averse colleagues and say bluntly what I believe the likely impact of quantum simulation will be: there’s at least a 50 percent chance quantum simulation will result in one or more multi-trillion dollar industries. And there’s at least a 30 percent chance it will completely change human civilization. The catch: I don’t mean in 5 years, or 10 years, or even 20 years. I’m talking more over 100 years. And I could be wrong. What makes me suspect this may be so important? For most of history we humans understood almost nothing about what matter is. That’s changed over the past century or so, as we’ve built an amazingly detailed understanding of matter. But while that understanding has grown, our ability to control matter has lagged. Essentially, we’ve relied on what nature accidentally provided for us. We’ve gotten somewhat better at doing things like synthesizing new chemical elements and new molecules, but our control is still very primitive. We’re now in the early days of a transition where we go from having almost no control of matter to having almost complete control of matter. Matter will become programmable; it will be designable. This will be as big a transition in our understanding of matter as the move from mechanical computing devices to modern computers was for computing. What qualitatively new forms of matter will we create? I don’t know, but the ability to use quantum computers to simulate quantum systems will be an essential part of this burgeoning design science. Alright, enough speculation. Let me also briefly mention the sober-minded conventional answer given to the question “what are quantum computers good for?” That answer is to list various algorithmic problems that we have some evidence can be solved faster on a quantum computer than on a classical computer. The most famous example is Peter Shor’s beautiful quantum factoring algorithm. To find the prime factors of an nn-bit integer seems to be a very difficult problem on a classical computer. The best existing algorithms are incredibly computationally expensive, with a cost that rises exponentially with nn. Even numbers with just a few hundred digits aren’t currently feasible to factor on classical computers. By contrast, Shor’s quantum factoring algorithm would make factoring into a comparatively easy task, if large-scale quantum computers can be built. Factoring perhaps doesn’t seem like a very interesting application. But it turns out that the ability to factor lets you break some of the most widely-used encryption schemes, used by services such as Gmail and Amazon to keep your communications private. This ability to break encryption has made the world’s intelligence agencies very interested in factoring, and they’ve poured enormous sums of money into quantum computing research since the mid-1990s. Indeed, there’s a good (as yet unwritten) history book to be written about how the rise of quantum computing was caused by the interest of the world’s intelligence agencies in accessing humanity’s private thoughts. There’s been surprisingly little public reflection about this on the part of the quantum computing community. I occasionally meet quantum computing researchers who complain in private about what they perceive as privacy violations by governments, and the dangers of surveillance states. But then some of those same people will take money to help those governments in their plans for surveillance, usually with some transparently self-serving justification about how they’re not really helping. One exception to this lack of public reflection is a brief discussion in Ronald de Wolf’s thoughtful essay The Potential Impact of Quantum Computers on Society (2017). Are quantum computers really universal devices? The eternal mystery of the world is its comprehensibility… The fact that it is comprehensible is a miracle.— Albert Einstein  At the beginning of this essay I asked whether there is any single universal computing device that can efficiently simulate any other physical system? We’ve learned that classical computers seem to have a lot of trouble efficiently simulating quantum systems. What about quantum computers? While they can certainly simulate many quantum systems, does that mean they can be used to efficiently simulate any physical system? This question is an open problem! We don’t yet know the answer. Part of the trouble in answering the question is that humanity hasn’t yet discovered the final fundamental laws of physics. Modern physics is based on two astonishingly effective theories: Einstein’s general theory of relativity, which describes how gravitation works; and the standard model of particle physics, which explains how pretty much everything else (electromagnetism, the strong and weak nuclear forces) work. Trouble is, we don’t yet have a good theory of quantum gravity which combines general relativity and the standard model. Without such a theory of quantum gravity we’re not able to answer the question of whether quantum computers can efficiently simulate any other physical system. Perhaps some future class of quantum gravitating computers, more powerful even than quantum computers, will be needed to simulate quantum gravity. Let’s ask a slightly less ambitious question, which is whether we can use quantum computers to efficiently simulate general relativity and the standard model? The standard model is an example of a particular type of quantum mechanical theory called a quantum field theory. John Preskill and his collaborators have written a series of papersFor a review of progress see: John Preskill, Simulating quantum field theory with a quantum computer (2018). explaining how to use quantum computers to efficiently simulate quantum field theories. Those papers don’t yet simulate the full standard model, but they do make considerable progress. It remains an exciting open problem, albeit a problem where much encouraging progress has been made. In the case of general relativity, as far as I know the problem remains open. Indeed, even stating what the problem means is not trivial. General relativity supports the existence of closed timelike curves, which can be used in some sense to send information back in time. This has interesting consequences for computation: there’s a way in which the computer can know the results of future computations. Unsurprisingly, this changes what is possible! Another complication is that when you talk about an “efficient simulation” in computation you mean the time and space overhead isn’t too large. But in general relativity even the basic units of space and time aren’t so clear. It’s hard to say what efficiency means. Finally, near singularities time and space get distorted in strange ways, again making it challenging to say exactly what it means to do an efficient computation. There is, by the way, significant issue that I've been sweeping under the rug, and which may be bugging you: as I've explained it, a quantum computer isn't a single computing device at all, since there are many possible quantum circuits. This is okay, though, since there's a model known as the universal quantum Turing machine, which is a single computing device, and which can simulate any quantum circuit. So you should understand the discussion above as being implicitly about the universal quantum Turing machine. I won't explain the details of the universal quantum Turing machine in this essay, since in practice the quantum circuit model is far more commonly used. But if you're interested in the details, I recommend this paper by Bernstein and Vazirani. The existence of universal computers is easy to take for granted. But there’s no a priori logical reason there should be a single machine that can efficiently simulate every other physical system. It’s like being able to use your car also as a surfboard, a supermarket trolley, and a rainforestIn fact, there’s a sense in which this is possible, within limits: if you could rearrange protons, neutrons, and electrons arbitrarily well, you could turn a car into a surfboard, a supermarket trolley, or a (small) part of a rainforest. So matter does have intriguing universality properties. This is also remarkable, of course.. Yet the evidence so far suggests our universe does allow such universal machines. It’s a good problem – and, so far as I know, largely unexplored – to think about sets of laws of physics in which such a universal machine is not possible. That might sound pointless – why imagine other possible universes? Yet exploring such radical counterfactuals is often an excellent strategy for better understanding our own universe. So there’s a very strange loop here. It’s that the laws of physics determine what kind of computations can be done. And yet the kind of computations which can be done seem to be powerful enough to describe the laws of physics. And that description can then be used to (efficiently!) simulate any physical system:   The top part of the loop is almost tautological. The bottom half of the loop is extraordinary. There’s no a priori reason the laws of physics should enable the existence of machines which can simulate physical systems. You might argue on anthropic grounds – we humans are here in the universe, and doing physics pretty successfully, so conditioned on that, it must be true. But that’s not a very satisfactory explanation of why. It remains a mystery. Einstein was right: the fact that the world is comprehensible at all is a miracle. Final Reflections We’ve worked through all the basics of the quantum computing model, but we haven’t yet used it in a full-on application – the sort of application which make people excited about quantum computing. But there will soon be available two considerably shorter(!) followup essays, explaining the quantum search algorithm and quantum teleportation. Someone who understands all three essays will have a good understanding of elementary quantum computing. And what of the experimental mnemonic medium we’ve developed in this essay? Mastering new subjects requires internalizing the basic terminology and ideas of the subject. The mnemonic medium should radically speed up this memory step, converting it from a challenging obstruction into a routine step. Frankly, I believe it would accelerate human progress if all the deepest ideas of our civilization were available in a form like this. Perhaps some day. With that said, memory is only part of what it means to understand. Is it possible to build powerful environments which enable deeper forms of understanding? That enable people to take action in new ways, to grow their sense of agency and of ability to contribute? This requires many things beyond memory: the ability to problem solve and to problem find; to connect with opportunities that genuinely matter, and to find pathways for meaningful contribution. We, the team at “Quantum Computing for the Very Curious”, believe there are many powerful and under-exploited patterns available to achieve these goals. In future projects we will explore and develop these patterns. Some of this exploration will continue to be done in the context of quantum computing. But we also hope to launch projects discussing some of humanity’s other great challenges, including optimistic, detailed visions of problems such as space travel, climate change, longevity, and the development of new forms of matter. Thanks for reading this far. In a few days, you’ll receive a notification containing a link to your first review session. In that review session you’ll be retested on the material you’ve learned, helping you further commit it to memory. It should only take a few minutes. In subsequent days you’ll receive more notifications linking you to re-review, gradually working toward genuine long-term memory of all the core material in the essay. Thanks for reading this far. If you’d like to remember the core ideas of this essay durably, please sign in below to set up an account. We’ll track your review schedule and send you occasional reminders containing links that will take you to the review experience.   Please sign in so we can save your progress and let you know the best times to review.   Thank you! Your progress will be saved as you read.
Quantum computing for the very curious
https://quantum.country/qcvc#part-III
https://www.ibm.com/topics/quantum-computing
What is Quantum Computing? | IBM
2024-01-01T22:01:00Z

<html><body><div><div>
 <p>An IBM Quantum processor is a wafer not much bigger than the one found in a laptop. And a quantum hardware system is about the size of a car, made up mostly of cooling systems to keep the superconducting processor at its ultra-cold operational temperature.</p>
<p>A classical processor uses classical bits to perform its operations. A quantum computer uses qubits (CUE-bits) to run multidimensional quantum algorithms.</p>
<p><strong>Superconductors</strong></p>
<p>Your desktop computer likely uses a fan to get cold enough to work. Our quantum processors need to be very cold–about a hundredth of a degree above absolute zero—to avoid “decoherence,” or retain their quantum states. To achieve this, we use super-cooled superfluids. At these ultra-low temperatures certain materials exhibit an important quantum mechanical effect: electrons move through them without resistance. This makes them &#34;superconductors.&#34;  </p>
<p>When electrons pass through superconductors they match up, forming &#34;Cooper pairs.&#34; These pairs can carry a charge across barriers, or insulators, through a process known as quantum tunneling. Two superconductors placed on either side of an insulator form a Josephson junction.</p>
<p><strong>Control</strong></p>
<p>Our quantum computers use Josephson junctions as superconducting qubits. By firing microwave photons at these qubits, we can control their behavior and get them to hold, change and read out individual units of quantum information.</p>
<p><strong>Superposition</strong></p>
<p>A qubit itself isn&#39;t very useful. But it can perform an important trick: placing the quantum information it holds into a state of superposition, which represents a combination of all possible configurations of the qubit. Groups of qubits in superposition can create complex, multidimensional computational spaces. Complex problems can be represented in new ways in these spaces.</p>
<p><strong>Entanglement</strong></p>
<p>Quantum entanglement is an effect that correlates the behavior of two separate things. Physicists have found that when two qubits are entangled, changes to one qubit directly impact the other.</p>
<p><strong>Interference</strong></p>
<p>In an environment of entanged qubits placed into a state of superposition, there are waves of probabilities. These are the probabilities of the outcomes of a measurement of the system. These waves can build on each other when many of them peak at a particular outcome, or cancel each other out when peaks and troughs interact. These are both forms of interference.</p>
<p>A computation on a quantum computer works by preparing a superposition of all possibile computational states. A quantum circuit, prepared by the user, uses interference selectively on the components of the superposition according to an algorithm. Many possible outcomes are cancelled out through interference, while others are amplified. The amplified outcomes are the solutions to the computation.</p>
 
 
 
 
 
</div></div></body></html>
An IBM Quantum processor is a wafer not much bigger than the one found in a laptop. And a quantum hardware system is about the size of a car, made up mostly of cooling systems to keep the superconducting processor at its ultra-cold operational temperature.
A classical processor uses classical bits to perform its operations. A quantum computer uses qubits (CUE-bits) to run multidimensional quantum algorithms.
 Superconductors 
Your desktop computer likely uses a fan to get cold enough to work. Our quantum processors need to be very cold–about a hundredth of a degree above absolute zero—to avoid “decoherence,” or retain their quantum states. To achieve this, we use super-cooled superfluids. At these ultra-low temperatures certain materials exhibit an important quantum mechanical effect: electrons move through them without resistance. This makes them &#34;superconductors.&#34;  
When electrons pass through superconductors they match up, forming &#34;Cooper pairs.&#34; These pairs can carry a charge across barriers, or insulators, through a process known as quantum tunneling. Two superconductors placed on either side of an insulator form a Josephson junction.
 Control 
Our quantum computers use Josephson junctions as superconducting qubits. By firing microwave photons at these qubits, we can control their behavior and get them to hold, change and read out individual units of quantum information.
 Superposition 
A qubit itself isn&#39;t very useful. But it can perform an important trick: placing the quantum information it holds into a state of superposition, which represents a combination of all possible configurations of the qubit. Groups of qubits in superposition can create complex, multidimensional computational spaces. Complex problems can be represented in new ways in these spaces.
 Entanglement 
Quantum entanglement is an effect that correlates the behavior of two separate things. Physicists have found that when two qubits are entangled, changes to one qubit directly impact the other.
 Interference 
In an environment of entanged qubits placed into a state of superposition, there are waves of probabilities. These are the probabilities of the outcomes of a measurement of the system. These waves can build on each other when many of them peak at a particular outcome, or cancel each other out when peaks and troughs interact. These are both forms of interference.
A computation on a quantum computer works by preparing a superposition of all possibile computational states. A quantum circuit, prepared by the user, uses interference selectively on the components of the superposition according to an algorithm. Many possible outcomes are cancelled out through interference, while others are amplified. The amplified outcomes are the solutions to the computation.
What is Quantum Computing? | IBM
https://www.ibm.com/quantum-computing/what-is-quantum-computing/
https://www.youngwonks.com/blog/What-is-Quantum-Computing
What is quantum computing, how does it work and how is it different from regular computing?
2021-06-24
None
<div><div>
<p>    By Team YoungWonks
 *
 </p>
<p>In one of our earlier blogs, we dissected the subject of supercomputing (<a href="https://www.youngwonks.com/blog/What-is-a-Supercomputer-and-What-are-its-Types--Uses-and-Applications">https://www.youngwonks.com/blog/What-is-a-Supercomputer-and-What-are-its-Types--Uses-and-Applications</a>). Another buzzword in the modern tech world is quantum computing. Before we delve into this rather complex topic, let us look at what the term quantum means. </p>
<p>Outside of the sciences - be it quantum physics, quantum encryption and quantum computing - we keep hearing the phrase ‘quantum leap’. So what does quantum mean here? Does it denote a huge leap? The word quantum has its roots in the Latin word quantus or quantity. In physics, it refers to a ‘discrete quantity of energy proportional in magnitude to the frequency of the radiation it represents.’ Discrete here means non continuous or distinct. In that sense, quantum refers to distinct or significant quantities. </p>
<h2><strong>Quantum Computing Explained</strong></h2>
<p>In a nutshell, quantum computing is where certain algebraic methods - typically the same methods or those parallel to the ones applied in quantum mechanics are used to develop algorithms for computations. Quantum mechanics in turn refers to a fundamental theory in physics that delves into the description of the physical properties of nature at the scale of atoms and subatomic particles. A quantum computer then is a conceptual computer that can implement such algorithms. So quantum computers are essentially based on quantum bits, also known as qubits, which can be made from a single electron.</p>
<p>Let us try to understand quantum computing better by looking at regular computing. </p>
<h2><strong>Quantum Computing versus Regular Computing </strong></h2>
<p>A regular computer chip uses bits, which are essentially like switches in that they can either be on or off. The off position is represented by a 0 while the on position is denoted by a 1. Be it apps or websites, they are made up of millions of bits - all of which are combinations of 1s and 0s. What is interesting to note then is the fact that not everything in life can be captured in ones and zeroes; often there’s room for several uncertainties which are ‘discrete’ (aka distinct from each other) as well. This is where quantum computing comes in. Quantum computing follows the principles of quantum mechanics, a set of rules governing at a really small scale of atoms and subatomic particles.</p>
<h3><em><strong>Superposition</strong></em></h3>
<p>Instead of bits, quantum computers use qubits. And unlike bits which have to be on or off (aka 1 or 0), qubits can be both on and off at the same time or even between the two. In quantum computing parlance, this phenomenon is called superposition.  </p>
<p>A common example used to understand this is that of a spinning coin. We know that a coin that has been flipped will land either on heads or tails. But what about a coin that’s spinning? Before such a coin comes to a stop, it has chances of both - landing on heads and of landing on tails. Superposition then is like this spinning coin, which means it factors in uncertainty as well, something that ordinary computing does not do. </p>
<p>So with quantum computers having the advantage of using ones, zeros and “superpositions” of ones and zeroes, they will be able to carry out a huge number of calculations at the same time. Thus, certain difficult tasks that have long been considered impossible to crack by conventional computers are now within the reach of quantum computers. </p>
<p>Another obviously distinguishing factor is speed; quantum computing is way faster than ordinary computing. Indeed, by deploying superpositions, quantum computers can solve problems simultaneously and much faster. </p>
<div><p>Take for instance, a problem such as figuring the way out of a maze. While a regular computer will explore each route one by one in order to zero in on the correct one, a quantum computer will be able to go down all these paths at the same time, thus enabling it to arrive at the solution - the way out - much faster. </p></div>
<h3><em><strong>Entanglement</strong></em> </h3>
<p>Another key concept that forms the foundation of quantum computing is entanglement. In physics, quantum entanglement refers to a very strong correlation between quantum particles. This correlation is so strong that the two or more quantum particles can be said to be inextricably linked despite great distances. </p>
<p>To understand this better with a simple analogy that lies outside the contexts of physics and computing, let’s go back to the coin example. Now imagine if there were not one but two coins being tossed. Typically, whether one coin lands on heads or tails has no impact on the result of the other coin toss. But in case of entanglement, both elements - no matter if they are physically distinct from each other - are connected or entangled. So in such a scenario, if one coin is landing on heads, the other one will also show heads and vice versa. </p>
<p>In other words, thanks to the quantum states of superposition and entanglement, quantum computing allows for multiple and interconnected (hence, predictable) outcomes. This means that quantum computers have a shot at solving complex problems in a timeframe much shorter than our best computers are currently pegged to take up. Quantum computing is thus essentially about harnessing the laws of quantum mechanics to process information.</p>
<p>A quantum algorithm then is an algorithm running on a realistic model of quantum computation. Essentially, it refers to a step-by-step process, where each step is carried out on a quantum computer. Particularly useful are the quantum optimization algorithms which are, as their name suggests, quantum algorithms used to solve optimization problems. Mathematical optimization is when the best solution to a problem is being found from a set of possible solutions. In this context, a classical algorithm is a non-quantum one, referring to a sequence of steps performed on a classical computer.</p>
<h2><strong>Applications of Quantum Computing </strong></h2>
<p>Armed with speed and efficiency, quantum computers show a lot of promise and in several areas. </p>
<p>It is being said that quantum computers can speedtrack the <strong><em>development of Artificial Intelligence</em></strong>; Google is already using quantum computing to hone their autonomous driving software. </p>
<p><strong><em>Modelling chemical reactions</em></strong> is another area expected to benefit greatly from quantum computing. As of now, supercomputers are in the process of analysing the most basic molecules. But quantum computers are expected to be able to deal with the most complicated reactions.</p>
<p>Increased efficiency in <strong><em>solving complex equations</em></strong> is in turn supposed to pave the way for a slew of efficient products - be it better solar panels or increased capacity of batteries in electric cars.</p>
<p>It is also being said that quantum computing can be used in the field of medicine to <strong><em>spur the production of cheaper medicines </em></strong>and <strong><em>even find cures for diseases such as Alzheimer’s</em></strong>. Additionally, since quantum computers are very good at simulating systems with greater accuracy and in a shorter period of time, they have even been said to have helped in the administration of COVID-19 especially with regards to dealing with the spread, search for potential vaccines, and the advancement of therapeutics.</p>
<p>Since quantum computers will typically be of use in areas where large, uncertain complicated systems need to be simulated, industries such as <strong><em>financial markets</em></strong> and <strong><em>weather forecasts</em></strong>. </p>
<p><strong><em>Cryptography</em> </strong>also stands to be affected by quantum computing. Bear in mind that currently, encryption systems work because decryption by breaking down large numbers into prime numbers is a rather tedious, expensive and impractical affair for your regular computer. But with quantum computers being able to solve such problems easily using quantum cryptography (aka the science of using quantum mechanical properties to do cryptographic tasks), our passwords - and as a result, our password-protected data - become vulnerable. In the event that quantum computers get around to decrypting this data, we would have to resort to staying afloat with - what else but - quantum encryption.</p>
<p>Many believe that <strong><em>quantum simulations</em> </strong>will be among the key applications of quantum computing. Quantum simulations are what make possible the study of quantum systems since they are difficult to study in a lab and impossible to model with a supercomputer. So quantum simulators are special purpose devices created to offer insight into certain physics problems. A popular example of a universal quantum simulator is a quantum computer proposed by Yuri Manin in 1980 and Richard Feynman in 1982.</p>
<p>It is important to mention quantum information here. It is an interdisciplinary field involving quantum mechanics, computer science, information theory, philosophy and cryptography among others, and its main focus is extracting information from matter at the microscopic scale. The study of this field is also relevant to areas such as <strong><em>cognitive science</em></strong>, <strong><em>psychology</em> </strong>and <em><strong>neuroscience</strong></em>.</p>
<h2><strong>Quantum Computers in Day to Day Lives</strong></h2>
<p>As mentioned above, these quantum machines hold within them a lot of potential, to say the least. IBM is already offering a quantum experience where users can sign and use a quantum computer; in fact, one can even play a card game with it.</p>
<p>The above applications notwithstanding, there are many situations where quantum computers are likely to be outdone by their classical counterparts. For starters, quantum computers are highly sensitive; this means that heat, electromagnetic and magnetic fields and collisions with air molecules can make a qubit lose its quantum properties. This process, known as quantum decoherence, can in turn crash the quantum system.</p>
<p>Being highly vulnerable to interference, especially electrical interference, these quantum computers will have to be stored in highly cold and sterile environments. This in turn means that quantum computers will - in all likelihood be used only remotely by industries such as banks, businesses and academia. And there is also a possibility that the computers of the future could be combination of both the classical and quantum varieties.</p>
<h2><strong>Quantum Supremacy and The Road Ahead</strong></h2>
<p>US theoretical physicist John Preskill has introduced the term quantum supremacy in order to refer to the hypothetical speedup advantage that quantum computing will offer as compared to classical computing in a certain field. Some practical quantum technologies are already coming up; be it highly effective sensors or actuators. And these devices will only help scientists navigate the nano-scale world with remarkable precision and sensitivity.</p>
<p>In October 2019, Google claimed that it had achieved quantum supremacy – the point at which a quantum computer can outperform a ordinary computer. A Sycamore processor created with Google AI Quantum is said to have done calculations more than 3,000,000 times as fast as those of Summit, considered to be the world's fastest computer.  This claim may have been disputed by rivals such as IBM but it goes to show that a lot of work is being done in the field of quantum computing research.</p>
<div><p>In December 2020, a group from University of Science and Technology of China (USTC) developed Jiuzhang, the first photonic quantum computer to attain quantum supremacy. They did so by successfully implementing a restricted model of non-universal quantum computation on 76 photons. The USTC team claims that a classical contemporary supercomputer will need a computational time of 600 million years to produce the number of samples their quantum processor can generate in a mere 20 seconds.</p></div>
<p>And yet, quantum computers are not going to pervade our day-to-day lives anytime soon. They are far from hitting the consumer market and this is because the number of qubits that the best quantum computers have right now is around 50. While that does make them quite powerful - each qubit added translates into an exponential increase in processing capacity, so it is without a doubt a lot of computing power -  these quantum computers also have really high error rates. So they’re powerful and yet not reliable, which is a far from ideal combination.</p>
<h2>Exploring Quantum Computing with YoungWonks</h2>
<p>Quantum computing represents a breakthrough in technology that promises to revolutionize various fields, from material science to cryptography. For future innovators interested in being at the forefront of this transformation, starting with a strong foundation in coding is crucial. YoungWonks offers <a href="https://www.youngwonks.com/">Coding Classes for Kids</a> that introduce young learners to the basics of programming, setting the stage for more advanced topics. Our <a href="https://www.youngwonks.com/python-programming">Python Coding Classes for Kids</a> are particularly beneficial for those keen on understanding quantum algorithms, as Python is widely used in the quantum computing community. Furthermore, for students fascinated by the hardware side of tech innovations, our <a href="https://www.youngwonks.com/arduino-raspberry-pi-coding">Raspberry Pi, Arduino and Game Development Coding Classes</a> provide hands-on experience, making complex concepts like quantum computing more tangible.</p>
<p>*Contributors: Written by Vidya Prabhu; Lead image by: Abhishek Aggarwal
 </p>
</div><div>
<blockquote>
<p>This blog is presented to you by YoungWonks. The leading coding program for
 kids and teens.</p>
<b>YoungWonks offers instructor led one-on-one online classes and in-person classes with 4:1
 student teacher ratio.
 <p> by filling out the form below:</p>
</b>
</blockquote>
<main>
<div>
<p><strong>By clicking the "Submit" button above, you agree to the <a href="https://www.youngwonks.com/privacy">privacy policy</a></strong><br/>
</p>
</div>
</main>
</div></div>||||I|||| YoungWonks menu
 * Why
 * Admission
 * Tuition
 * Instructors
 * Blog
 * Events
 * Videos
 * Store
 * Login
 * Free Trial Class
 * Why
 * Admission
 * Tuition
 * Instructors
 * Blog
 * Events
 * Videos
 * Store
 * Login
 * Free Trial Class
 Loading...

 What is Quantum Computing

 What is quantum computing, how does it work and how is it different from regular computing?

 An introduction to quantum computing, its scope and uses

 Jun 24, 2021 By Team YoungWonks *

 In one of our earlier blogs, we dissected the subject of supercomputing (https://www.youngwonks.com/blog/What-is-a-Supercomputer-and-What-are-its-Types--Uses-and-Applications). Another buzzword in the modern tech world is quantum computing. Before we delve into this rather complex topic, let us look at what the term quantum means.

 Outside of the sciences - be it quantum physics, quantum encryption and quantum computing - we keep hearing the phrase ‘quantum leap’. So what does quantum mean here? Does it denote a huge leap? The word quantum has its roots in the Latin word quantus or quantity. In physics, it refers to a ‘discrete quantity of energy proportional in magnitude to the frequency of the radiation it represents.’ Discrete here means non continuous or distinct. In that sense, quantum refers to distinct or significant quantities.

 Quantum Computing Explained

 In a nutshell, quantum computing is where certain algebraic methods - typically the same methods or those parallel to the ones applied in quantum mechanics are used to develop algorithms for computations. Quantum mechanics in turn refers to a fundamental theory in physics that delves into the description of the physical properties of nature at the scale of atoms and subatomic particles. A quantum computer then is a conceptual computer that can implement such algorithms. So quantum computers are essentially based on quantum bits, also known as qubits, which can be made from a single electron.

 Let us try to understand quantum computing better by looking at regular computing.

 Quantum Computing versus Regular Computing

 A regular computer chip uses bits, which are essentially like switches in that they can either be on or off. The off position is represented by a 0 while the on position is denoted by a 1. Be it apps or websites, they are made up of millions of bits - all of which are combinations of 1s and 0s. What is interesting to note then is the fact that not everything in life can be captured in ones and zeroes; often there’s room for several uncertainties which are ‘discrete’ (aka distinct from each other) as well. This is where quantum computing comes in. Quantum computing follows the principles of quantum mechanics, a set of rules governing at a really small scale of atoms and subatomic particles.

 Superposition

 Instead of bits, quantum computers use qubits. And unlike bits which have to be on or off (aka 1 or 0), qubits can be both on and off at the same time or even between the two. In quantum computing parlance, this phenomenon is called superposition.

 A common example used to understand this is that of a spinning coin. We know that a coin that has been flipped will land either on heads or tails. But what about a coin that’s spinning? Before such a coin comes to a stop, it has chances of both - landing on heads and of landing on tails. Superposition then is like this spinning coin, which means it factors in uncertainty as well, something that ordinary computing does not do.

 So with quantum computers having the advantage of using ones, zeros and “superpositions” of ones and zeroes, they will be able to carry out a huge number of calculations at the same time. Thus, certain difficult tasks that have long been considered impossible to crack by conventional computers are now within the reach of quantum computers.

 Another obviously distinguishing factor is speed; quantum computing is way faster than ordinary computing. Indeed, by deploying superpositions, quantum computers can solve problems simultaneously and much faster.

 Take for instance, a problem such as figuring the way out of a maze. While a regular computer will explore each route one by one in order to zero in on the correct one, a quantum computer will be able to go down all these paths at the same time, thus enabling it to arrive at the solution - the way out - much faster.


 Entanglement

 Another key concept that forms the foundation of quantum computing is entanglement. In physics, quantum entanglement refers to a very strong correlation between quantum particles. This correlation is so strong that the two or more quantum particles can be said to be inextricably linked despite great distances.

 To understand this better with a simple analogy that lies outside the contexts of physics and computing, let’s go back to the coin example. Now imagine if there were not one but two coins being tossed. Typically, whether one coin lands on heads or tails has no impact on the result of the other coin toss. But in case of entanglement, both elements - no matter if they are physically distinct from each other - are connected or entangled. So in such a scenario, if one coin is landing on heads, the other one will also show heads and vice versa.

 In other words, thanks to the quantum states of superposition and entanglement, quantum computing allows for multiple and interconnected (hence, predictable) outcomes. This means that quantum computers have a shot at solving complex problems in a timeframe much shorter than our best computers are currently pegged to take up. Quantum computing is thus essentially about harnessing the laws of quantum mechanics to process information.

 A quantum algorithm then is an algorithm running on a realistic model of quantum computation. Essentially, it refers to a step-by-step process, where each step is carried out on a quantum computer. Particularly useful are the quantum optimization algorithms which are, as their name suggests, quantum algorithms used to solve optimization problems. Mathematical optimization is when the best solution to a problem is being found from a set of possible solutions. In this context, a classical algorithm is a non-quantum one, referring to a sequence of steps performed on a classical computer.

 Applications of Quantum Computing

 Armed with speed and efficiency, quantum computers show a lot of promise and in several areas.

 It is being said that quantum computers can speedtrack the development of Artificial Intelligence; Google is already using quantum computing to hone their autonomous driving software.

 Modelling chemical reactions is another area expected to benefit greatly from quantum computing. As of now, supercomputers are in the process of analysing the most basic molecules. But quantum computers are expected to be able to deal with the most complicated reactions.

 Increased efficiency in solving complex equations is in turn supposed to pave the way for a slew of efficient products - be it better solar panels or increased capacity of batteries in electric cars.

 It is also being said that quantum computing can be used in the field of medicine to spur the production of cheaper medicines and even find cures for diseases such as Alzheimer’s. Additionally, since quantum computers are very good at simulating systems with greater accuracy and in a shorter period of time, they have even been said to have helped in the administration of COVID-19 especially with regards to dealing with the spread, search for potential vaccines, and the advancement of therapeutics.

 Since quantum computers will typically be of use in areas where large, uncertain complicated systems need to be simulated, industries such as financial markets and weather forecasts.

 Cryptography also stands to be affected by quantum computing. Bear in mind that currently, encryption systems work because decryption by breaking down large numbers into prime numbers is a rather tedious, expensive and impractical affair for your regular computer. But with quantum computers being able to solve such problems easily using quantum cryptography (aka the science of using quantum mechanical properties to do cryptographic tasks), our passwords - and as a result, our password-protected data - become vulnerable. In the event that quantum computers get around to decrypting this data, we would have to resort to staying afloat with - what else but - quantum encryption.

 Many believe that quantum simulations will be among the key applications of quantum computing. Quantum simulations are what make possible the study of quantum systems since they are difficult to study in a lab and impossible to model with a supercomputer. So quantum simulators are special purpose devices created to offer insight into certain physics problems. A popular example of a universal quantum simulator is a quantum computer proposed by Yuri Manin in 1980 and Richard Feynman in 1982.

 It is important to mention quantum information here. It is an interdisciplinary field involving quantum mechanics, computer science, information theory, philosophy and cryptography among others, and its main focus is extracting information from matter at the microscopic scale. The study of this field is also relevant to areas such as cognitive science, psychology and neuroscience.

 Quantum Computers in Day to Day Lives

 As mentioned above, these quantum machines hold within them a lot of potential, to say the least. IBM is already offering a quantum experience where users can sign and use a quantum computer; in fact, one can even play a card game with it.

 The above applications notwithstanding, there are many situations where quantum computers are likely to be outdone by their classical counterparts. For starters, quantum computers are highly sensitive; this means that heat, electromagnetic and magnetic fields and collisions with air molecules can make a qubit lose its quantum properties. This process, known as quantum decoherence, can in turn crash the quantum system.

 Being highly vulnerable to interference, especially electrical interference, these quantum computers will have to be stored in highly cold and sterile environments. This in turn means that quantum computers will - in all likelihood be used only remotely by industries such as banks, businesses and academia. And there is also a possibility that the computers of the future could be combination of both the classical and quantum varieties.

 Quantum Supremacy and The Road Ahead

 US theoretical physicist John Preskill has introduced the term quantum supremacy in order to refer to the hypothetical speedup advantage that quantum computing will offer as compared to classical computing in a certain field. Some practical quantum technologies are already coming up; be it highly effective sensors or actuators. And these devices will only help scientists navigate the nano-scale world with remarkable precision and sensitivity.

 In October 2019, Google claimed that it had achieved quantum supremacy – the point at which a quantum computer can outperform a ordinary computer. A Sycamore processor created with Google AI Quantum is said to have done calculations more than 3,000,000 times as fast as those of Summit, considered to be the world's fastest computer. This claim may have been disputed by rivals such as IBM but it goes to show that a lot of work is being done in the field of quantum computing research.

 In December 2020, a group from University of Science and Technology of China (USTC) developed Jiuzhang, the first photonic quantum computer to attain quantum supremacy. They did so by successfully implementing a restricted model of non-universal quantum computation on 76 photons. The USTC team claims that a classical contemporary supercomputer will need a computational time of 600 million years to produce the number of samples their quantum processor can generate in a mere 20 seconds.


 And yet, quantum computers are not going to pervade our day-to-day lives anytime soon. They are far from hitting the consumer market and this is because the number of qubits that the best quantum computers have right now is around 50. While that does make them quite powerful - each qubit added translates into an exponential increase in processing capacity, so it is without a doubt a lot of computing power - these quantum computers also have really high error rates. So they’re powerful and yet not reliable, which is a far from ideal combination.

 Exploring Quantum Computing with YoungWonks

 Quantum computing represents a breakthrough in technology that promises to revolutionize various fields, from material science to cryptography. For future innovators interested in being at the forefront of this transformation, starting with a strong foundation in coding is crucial. YoungWonks offers Coding Classes for Kids that introduce young learners to the basics of programming, setting the stage for more advanced topics. Our Python Coding Classes for Kids are particularly beneficial for those keen on understanding quantum algorithms, as Python is widely used in the quantum computing community. Furthermore, for students fascinated by the hardware side of tech innovations, our Raspberry Pi, Arduino and Game Development Coding Classes provide hands-on experience, making complex concepts like quantum computing more tangible.

 *Contributors: Written by Vidya Prabhu; Lead image by: Abhishek Aggarwal

 This blog is presented to you by YoungWonks. The leading coding program for kids and teens.

 YoungWonks offers instructor led one-on-one online classes and in-person classes with 4:1 student teacher ratio.

 Sign up for a free trial class by filling out the form below:

 Parent Name
 Phone
 Email
 Child age
 Zip or City
 Country
 United States --------------- Afghanistan Åland Islands Albania Algeria American Samoa Andorra Angola Anguilla Antarctica Antigua and Barbuda Argentina Armenia Aruba Australia Austria Azerbaijan Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia, Plurinational State of Bonaire, Sint Eustatius and Saba Bosnia and Herzegovina Botswana Bouvet Island Brazil British Indian Ocean Territory Brunei Darussalam Bulgaria Burkina Faso Burundi Cambodia Cameroon Canada Cape Verde Cayman Islands Central African Republic Chad Chile China Christmas Island Cocos (Keeling) Islands Colombia Comoros Congo Congo, The Democratic Republic of the Cook Islands Costa Rica Côte d'Ivoire Croatia Cuba Curaçao Cyprus Czech Republic Denmark Djibouti Dominica Dominican Republic Ecuador Egypt El Salvador Equatorial Guinea Eritrea Estonia Ethiopia Falkland Islands (Malvinas) Faroe Islands Fiji Finland France French Guiana French Polynesia French Southern Territories Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guernsey Guinea Guinea-Bissau Guyana Haiti Heard Island and McDonald Islands Holy See (Vatican City State) Honduras Hong Kong Hungary Iceland India Indonesia Iran, Islamic Republic of Iraq Ireland Isle of Man Israel Italy Jamaica Japan Jersey Jordan Kazakhstan Kenya Kiribati Korea, Democratic People's Republic of Korea, Republic of Kuwait Kyrgyzstan Lao People's Democratic Republic Latvia Lebanon Lesotho Liberia Libya Liechtenstein Lithuania Luxembourg Macao Macedonia, Republic of Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia, Federated States of Moldova, Republic of Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands New Caledonia New Zealand Nicaragua Niger Nigeria Niue Norfolk Island Northern Mariana Islands Norway Oman Pakistan Palau Palestine, State of Panama Papua New Guinea Paraguay Peru Philippines Pitcairn Poland Portugal Puerto Rico Qatar Réunion Romania Russian Federation Rwanda Saint Barthélemy Saint Helena, Ascension and Tristan da Cunha Saint Kitts and Nevis Saint Lucia Saint Martin (French part) Saint Pierre and Miquelon Saint Vincent and the Grenadines Samoa San Marino Sao Tome and Principe Saudi Arabia Senegal Serbia Seychelles Sierra Leone Singapore Sint Maarten (Dutch part) Slovakia Slovenia Solomon Islands Somalia South Africa South Georgia and the South Sandwich Islands South Sudan Spain Sri Lanka Sudan Suriname Svalbard and Jan Mayen Swaziland Sweden Switzerland Syrian Arab Republic Taiwan Tajikistan Tanzania, United Republic of Thailand Timor-Leste Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu Uganda Ukraine United Arab Emirates United Kingdom United States Minor Outlying Islands United States Uruguay Uzbekistan Vanuatu Venezuela, Bolivarian Republic of Viet Nam Virgin Islands, British Virgin Islands, U.S. Wallis and Futuna Western Sahara Yemen Zambia Zimbabwe


 By clicking the "Submit" button above, you agree to the privacy policy
 Search for a blog


 Latest Posts

 Web 2.0 vs Web 3.0
 Web 2.0 vs Web 3.0
 Apr 28
 Edge Computing vs Cloud Computing
 Edge Computing vs Cloud Computing
 Apr 27
 Is Technology a Good Career Path?
 Is Technology a Good Career Path?
 Apr 22
 Why is encouragement important?
 Why is encouragement important?
 Apr 21
 Slice vs Splice
 Slice vs Splice
 Apr 15
 Difference Between Chromebook and Laptop
 Difference Between Chromebook and Laptop
 Apr 13
 How to Open Terminal in Visual Studio Code?
 How to Open Terminal in Visual Studio Code?
 Apr 07
 Python 2 vs Python 3
 Python 2 vs Python 3
 Apr 06
 JavaScript Read CSV
 JavaScript Read CSV
 Apr 01
 Is Cyberbullying Illegal?
 Is Cyberbullying Illegal?
 Mar 31
 Share on Facebook Share on Twitter
help

 CONTACT US

 Submit
 * About
 * Careers
 * 
 + Twitter
 + Facebook
 + YouTube
 + Instagram
 + WhatsApp
 * Privacy Policy
 * Terms & Conditions
 * FAQ

 YoungWonks, A DIVISION OF WONKSKNOW LLC
 Coding (Computer Programming) and Engineering Classes for Kids and Teens. Curriculum based on hands on robotics and game development projects.
 6920 Koll Center Parkway, Suite 219 Pleasanton CA 94566 USA +1-855-966-5756
 COPYRIGHT © 2017, WONKSKNOW LLC. ALL RIGHTS RESERVED

By Team YoungWonks
 *
 
In one of our earlier blogs, we dissected the subject of supercomputing (https://www.youngwonks.com/blog/What-is-a-Supercomputer-and-What-are-its-Types--Uses-and-Applications). Another buzzword in the modern tech world is quantum computing. Before we delve into this rather complex topic, let us look at what the term quantum means. 
Outside of the sciences - be it quantum physics, quantum encryption and quantum computing - we keep hearing the phrase ‘quantum leap’. So what does quantum mean here? Does it denote a huge leap? The word quantum has its roots in the Latin word quantus or quantity. In physics, it refers to a ‘discrete quantity of energy proportional in magnitude to the frequency of the radiation it represents.’ Discrete here means non continuous or distinct. In that sense, quantum refers to distinct or significant quantities. 
 Quantum Computing Explained 
In a nutshell, quantum computing is where certain algebraic methods - typically the same methods or those parallel to the ones applied in quantum mechanics are used to develop algorithms for computations. Quantum mechanics in turn refers to a fundamental theory in physics that delves into the description of the physical properties of nature at the scale of atoms and subatomic particles. A quantum computer then is a conceptual computer that can implement such algorithms. So quantum computers are essentially based on quantum bits, also known as qubits, which can be made from a single electron.
Let us try to understand quantum computing better by looking at regular computing. 
 Quantum Computing versus Regular Computing  
A regular computer chip uses bits, which are essentially like switches in that they can either be on or off. The off position is represented by a 0 while the on position is denoted by a 1. Be it apps or websites, they are made up of millions of bits - all of which are combinations of 1s and 0s. What is interesting to note then is the fact that not everything in life can be captured in ones and zeroes; often there’s room for several uncertainties which are ‘discrete’ (aka distinct from each other) as well. This is where quantum computing comes in. Quantum computing follows the principles of quantum mechanics, a set of rules governing at a really small scale of atoms and subatomic particles.
  Superposition  
Instead of bits, quantum computers use qubits. And unlike bits which have to be on or off (aka 1 or 0), qubits can be both on and off at the same time or even between the two. In quantum computing parlance, this phenomenon is called superposition.  
A common example used to understand this is that of a spinning coin. We know that a coin that has been flipped will land either on heads or tails. But what about a coin that’s spinning? Before such a coin comes to a stop, it has chances of both - landing on heads and of landing on tails. Superposition then is like this spinning coin, which means it factors in uncertainty as well, something that ordinary computing does not do. 
So with quantum computers having the advantage of using ones, zeros and “superpositions” of ones and zeroes, they will be able to carry out a huge number of calculations at the same time. Thus, certain difficult tasks that have long been considered impossible to crack by conventional computers are now within the reach of quantum computers. 
Another obviously distinguishing factor is speed; quantum computing is way faster than ordinary computing. Indeed, by deploying superpositions, quantum computers can solve problems simultaneously and much faster. 
 Take for instance, a problem such as figuring the way out of a maze. While a regular computer will explore each route one by one in order to zero in on the correct one, a quantum computer will be able to go down all these paths at the same time, thus enabling it to arrive at the solution - the way out - much faster.  
  Entanglement  
Another key concept that forms the foundation of quantum computing is entanglement. In physics, quantum entanglement refers to a very strong correlation between quantum particles. This correlation is so strong that the two or more quantum particles can be said to be inextricably linked despite great distances. 
To understand this better with a simple analogy that lies outside the contexts of physics and computing, let’s go back to the coin example. Now imagine if there were not one but two coins being tossed. Typically, whether one coin lands on heads or tails has no impact on the result of the other coin toss. But in case of entanglement, both elements - no matter if they are physically distinct from each other - are connected or entangled. So in such a scenario, if one coin is landing on heads, the other one will also show heads and vice versa. 
In other words, thanks to the quantum states of superposition and entanglement, quantum computing allows for multiple and interconnected (hence, predictable) outcomes. This means that quantum computers have a shot at solving complex problems in a timeframe much shorter than our best computers are currently pegged to take up. Quantum computing is thus essentially about harnessing the laws of quantum mechanics to process information.
A quantum algorithm then is an algorithm running on a realistic model of quantum computation. Essentially, it refers to a step-by-step process, where each step is carried out on a quantum computer. Particularly useful are the quantum optimization algorithms which are, as their name suggests, quantum algorithms used to solve optimization problems. Mathematical optimization is when the best solution to a problem is being found from a set of possible solutions. In this context, a classical algorithm is a non-quantum one, referring to a sequence of steps performed on a classical computer.
 Applications of Quantum Computing  
Armed with speed and efficiency, quantum computers show a lot of promise and in several areas. 
It is being said that quantum computers can speedtrack the  development of Artificial Intelligence ; Google is already using quantum computing to hone their autonomous driving software. 
  Modelling chemical reactions  is another area expected to benefit greatly from quantum computing. As of now, supercomputers are in the process of analysing the most basic molecules. But quantum computers are expected to be able to deal with the most complicated reactions.
Increased efficiency in  solving complex equations  is in turn supposed to pave the way for a slew of efficient products - be it better solar panels or increased capacity of batteries in electric cars.
It is also being said that quantum computing can be used in the field of medicine to  spur the production of cheaper medicines  and  even find cures for diseases such as Alzheimer’s . Additionally, since quantum computers are very good at simulating systems with greater accuracy and in a shorter period of time, they have even been said to have helped in the administration of COVID-19 especially with regards to dealing with the spread, search for potential vaccines, and the advancement of therapeutics.
Since quantum computers will typically be of use in areas where large, uncertain complicated systems need to be simulated, industries such as  financial markets  and  weather forecasts . 
  Cryptography also stands to be affected by quantum computing. Bear in mind that currently, encryption systems work because decryption by breaking down large numbers into prime numbers is a rather tedious, expensive and impractical affair for your regular computer. But with quantum computers being able to solve such problems easily using quantum cryptography (aka the science of using quantum mechanical properties to do cryptographic tasks), our passwords - and as a result, our password-protected data - become vulnerable. In the event that quantum computers get around to decrypting this data, we would have to resort to staying afloat with - what else but - quantum encryption.
Many believe that  quantum simulations will be among the key applications of quantum computing. Quantum simulations are what make possible the study of quantum systems since they are difficult to study in a lab and impossible to model with a supercomputer. So quantum simulators are special purpose devices created to offer insight into certain physics problems. A popular example of a universal quantum simulator is a quantum computer proposed by Yuri Manin in 1980 and Richard Feynman in 1982.
It is important to mention quantum information here. It is an interdisciplinary field involving quantum mechanics, computer science, information theory, philosophy and cryptography among others, and its main focus is extracting information from matter at the microscopic scale. The study of this field is also relevant to areas such as  cognitive science ,  psychology and  neuroscience .
 Quantum Computers in Day to Day Lives 
As mentioned above, these quantum machines hold within them a lot of potential, to say the least. IBM is already offering a quantum experience where users can sign and use a quantum computer; in fact, one can even play a card game with it.
The above applications notwithstanding, there are many situations where quantum computers are likely to be outdone by their classical counterparts. For starters, quantum computers are highly sensitive; this means that heat, electromagnetic and magnetic fields and collisions with air molecules can make a qubit lose its quantum properties. This process, known as quantum decoherence, can in turn crash the quantum system.
Being highly vulnerable to interference, especially electrical interference, these quantum computers will have to be stored in highly cold and sterile environments. This in turn means that quantum computers will - in all likelihood be used only remotely by industries such as banks, businesses and academia. And there is also a possibility that the computers of the future could be combination of both the classical and quantum varieties.
 Quantum Supremacy and The Road Ahead 
US theoretical physicist John Preskill has introduced the term quantum supremacy in order to refer to the hypothetical speedup advantage that quantum computing will offer as compared to classical computing in a certain field. Some practical quantum technologies are already coming up; be it highly effective sensors or actuators. And these devices will only help scientists navigate the nano-scale world with remarkable precision and sensitivity.
In October 2019, Google claimed that it had achieved quantum supremacy – the point at which a quantum computer can outperform a ordinary computer. A Sycamore processor created with Google AI Quantum is said to have done calculations more than 3,000,000 times as fast as those of Summit, considered to be the world's fastest computer.  This claim may have been disputed by rivals such as IBM but it goes to show that a lot of work is being done in the field of quantum computing research.
 In December 2020, a group from University of Science and Technology of China (USTC) developed Jiuzhang, the first photonic quantum computer to attain quantum supremacy. They did so by successfully implementing a restricted model of non-universal quantum computation on 76 photons. The USTC team claims that a classical contemporary supercomputer will need a computational time of 600 million years to produce the number of samples their quantum processor can generate in a mere 20 seconds. 
And yet, quantum computers are not going to pervade our day-to-day lives anytime soon. They are far from hitting the consumer market and this is because the number of qubits that the best quantum computers have right now is around 50. While that does make them quite powerful - each qubit added translates into an exponential increase in processing capacity, so it is without a doubt a lot of computing power -  these quantum computers also have really high error rates. So they’re powerful and yet not reliable, which is a far from ideal combination.
Exploring Quantum Computing with YoungWonks
Quantum computing represents a breakthrough in technology that promises to revolutionize various fields, from material science to cryptography. For future innovators interested in being at the forefront of this transformation, starting with a strong foundation in coding is crucial. YoungWonks offers Coding Classes for Kids that introduce young learners to the basics of programming, setting the stage for more advanced topics. Our Python Coding Classes for Kids are particularly beneficial for those keen on understanding quantum algorithms, as Python is widely used in the quantum computing community. Furthermore, for students fascinated by the hardware side of tech innovations, our Raspberry Pi, Arduino and Game Development Coding Classes provide hands-on experience, making complex concepts like quantum computing more tangible.
*Contributors: Written by Vidya Prabhu; Lead image by: Abhishek Aggarwal
 
 
This blog is presented to you by YoungWonks. The leading coding program for
 kids and teens.
YoungWonks offers instructor led one-on-one online classes and in-person classes with 4:1
 student teacher ratio.
  by filling out the form below:
 By clicking the "Submit" button above, you agree to the privacy policy
What is quantum computing, how does it work and how is it different from regular computing?
https://www.youngwonks.com/blog/What-is-Quantum-Computing
https://jakevdp.github.io/blog/2012/09/05/quantum-python/
Quantum Python: Animating the Schrodinger Equation
2012-08-18
Jake VanderPlas
<div><div>
 
<p><em>Update: a reader contributed some improvements to the Python code presented
 below. Please see the
<a href="https://github.com/jakevdp/pySchrodinger">pySchrodinger</a> github repository
for updated code</em></p>
<p>In a <a href="/blog/2012/08/18/matplotlib-animation-tutorial/">previous post</a>
I explored the new animation capabilities of the latest
<a href="http://matplotlib.sourceforge.net/">matplotlib</a> release.
It got me wondering whether it would be possible to simulate more complicated
physical systems in real time in python. Quantum Mechanics was the first
thing that came to mind. It turns out that by mixing a bit of Physics
knowledge with a bit of computing knowledge, it's quite straightforward
to simulate and animate a simple quantum mechanical system with python.</p>
<h2>The Schrodinger Equation</h2>
<p>The dynamics of a one-dimensional quantum system are governed by the
time-dependent Schrodinger equation:</p>
<p>$$
i\hbar\frac{\partial \psi}{\partial t}
 = \frac{-\hbar^2}{2m} \frac{\partial^2 \psi}{\partial x^2} + V \psi
$$</p>
<p>The <em>wave function</em> $\psi$ is a function of both position $x$ and time $t$,
and is the fundamental description of the realm of the very small.
Imagine we are following the motion of a single particle in one
dimension. This wave function represents a probability of measuring
the particle at a position $x$ at a time $t$. Quantum mechanics tells us that
(contrary to our familiar classical reasoning) this probability is not
a limitation of our knowledge of the system, but a reflection of an
unavoidable uncertainty about the position and time of events in the realm
of the very small.</p>
<p>Still, this equation is a bit opaque, but to visualize the results we'll need
to solve this numerically. We'll approach this using the split-step Fourier
method.</p>
<h2>The Split-step Fourier Method</h2>
<p>A standard way to numerically solve certain differential equations is
through the use of the Fourier transform. We'll use a Fourier convention
of the following form:</p>
<p>$$
\widetilde{\psi}(k, t) = \frac{1}{\sqrt{2\pi}}
 \int_{-\infty}^{\infty} \psi(x, t) e^{-ikx} dx
$$</p>
<p>Under this convention, the associated inverse Fourier Transform is given by:</p>
<p>$$
\psi(x, t) = \frac{1}{\sqrt{2\pi}}
 \int_{-\infty}^{\infty} \widetilde{\psi}(k, t) e^{ikx} dk
$$</p>
<p>Substituting this into the Schrodinger equation and simplifying gives the
Fourier-space form of the Schrodinger equation:</p>
<p>$$
i\hbar\frac{\partial \widetilde{\psi}}{\partial t}
 = \frac{\hbar^2 k^2}{2m} \widetilde{\psi}
 + V(i\frac{\partial}{\partial k})\widetilde{\psi}
$$</p>
<p>The two versions of the Schrodinger equation contain an interesting symmetry:
the time step in each case depends on a straightforward multiplication of
the wave function $\psi$, as well as a more complicated term involving
derivatives with respect to $x$ or $k$. The key observation is that while
the equation is difficult to evaluate fully within one of the forms, each
basis offers a straightforward calculation of one of the two contributions.
This suggests an efficient strategy to numerically solve the Schrodinger
Equation.</p>
<p>First we solve the straightforward part of the $x$-space Schrodinger
equation:</p>
<p>$$
i\hbar\frac{\partial \psi}{\partial t}
 = V(x) \psi
$$</p>
<p>For a small time step $\Delta t$, this has a solution of the form</p>
<p>$$
\psi(x, t + \Delta t) = \psi(x, t) e^{-i V(x) \Delta t / \hbar}
$$</p>
<p>Second, we solve the straightforward part of the $k$-space Schrodinger
equation:</p>
<p>$$
i\hbar\frac{\partial \widetilde{\psi}}{\partial t}
 = \frac{\hbar^2 k^2}{2 m} \widetilde{\psi}
$$</p>
<p>For a small time step $\Delta t$, this has a solution of the form</p>
<p>$$
\widetilde{\psi}(k, t + \Delta t)
 = \widetilde{\psi}(k, t) e^{-i \hbar k^2 \Delta t / 2m}
$$</p>
<h2>Numerical Considerations</h2>
<p>Solving this system numerically will require repeated computations of the
Fourier transform of $\psi(x, t)$ and the inverse Fourier transform of
$\widetilde{\psi}(k, t)$. The best-known algorithm for computation of
numerical Fourier transforms is the Fast Fourier Transform (FFT), which
is <a href="http://docs.scipy.org/doc/scipy/reference/fftpack.html">available in scipy</a>
and efficiently computes the following form of the
discrete Fourier transform:</p>
<p>$$
 \widetilde{F_m} = \sum_{n=0}^{N-1} F_n e^{-2\pi i n m / N}
$$</p>
<p>and its inverse</p>
<p>$$
 F_n = \frac{1}{N} \sum_{m=0}^{N-1} \widetilde{F_m} e^{2\pi i n m / N}
$$</p>
<p>We need to know how these relate to the continuous Fourier transforms defined
and used above. Let's take the example of the forward transform. Assume that
the infinite integral is well-approximated by the finite integral from
$a$ to $b$, so that we can write</p>
<p>$$
\widetilde{\psi}(k, t) = \frac{1}{\sqrt{2\pi}}
 \int_a^b \psi(x, t) e^{-ikx} dx
$$</p>
<p>This approximation ends up being equivalent to assuming that the potential
$V(x) \to \infty$ at $x \le a$ and $x \ge b$. We'll now approximate this
integral as a Riemann sum of $N$ terms, and define $\Delta x = (b - a) / N$,
and $x_n = a + n\Delta x$:</p>
<p>$$
\widetilde{\psi}(k, t) \simeq \frac{1}{\sqrt{2\pi}}
 \sum_{n=0}^{N-1} \psi(x_n, t) e^{-ikx_n} \Delta x
$$</p>
<p>This is starting to look like the discrete Fourier transform! To bring it
even closer, let's define $k_m = k_0 + m\Delta k$, with
$\Delta k = 2\pi / (N\Delta x)$. Then our approximation becomes</p>
<p>$$
\widetilde{\psi}(k_m, t) \simeq \frac{1}{\sqrt{2\pi}}
 \sum_{n=0}^{N-1} \psi(x_n, t) e^{-ik_m x_n} \Delta x
$$</p>
<p>(Note that just as we have limited the range of $x$ above, we have here limited
the range of $k$ as well. This means that high-frequency components of the
signal will be lost in our approximation. The Nyquist sampling theorem tells
us that this is an unavoidable consequence of choosing discrete steps in
space, and it can be shown that the spacing we chose above exactly satisfies
the Nyquist limit if we choose $k_0 = - \pi / \Delta x$).</p>
<p>Plugging our expressions for $x_n$ and $k_m$ into the Fourier
approximation and rearranging, we find the following:</p>
<p>$$
\left[\widetilde{\psi}(k_m, t) e^{i m x_0 \Delta k}\right]
 \simeq \sum_{n=0}^{N-1} 
 \left[ \frac{\Delta x}{\sqrt{2\pi}}
 \psi(x_n, t) e^{-ik_0 x_n} \right]
 e^{-2\pi i m n / N}
$$</p>
<p>Similar arguments from the inverse Fourier transform yield:</p>
<p>$$
\left[\frac{\Delta x}{\sqrt{2 \pi}} \psi(x_n, t) e^{-i k_0 x_n}\right]
 \simeq \frac{1}{N} \sum_{m=0}^{N-1} 
 \left[\widetilde{\psi}(k_m, t) e^{-i m x_0 \Delta k} \right]
 e^{2\pi i m n / N}
$$</p>
<p>Comparing these to the discrete Fourier transforms above, we find that the
<em>continuous</em> Fourier pair</p>
<p>$$
 \psi(x, t) \Longleftrightarrow \widetilde{\psi}(k, t)
$$</p>
<p>corresponds to the <em>discrete</em> Fourier pair</p>
<p>$$
 \frac{\Delta x}{\sqrt{2 \pi}} \psi(x_n, t) e^{-i k_0 x_n}
 \Longleftrightarrow
 \widetilde{\psi}(k_m, t) e^{-i m x_0 \Delta k}
$$</p>
<p>subject to the approximations mentioned above. This allows a fast numerical
evaluation of the Schrodinger equation.</p>
<h2>Putting It All Together: the Algorithm</h2>
<p>We now put this all together using the following algorithm</p>
<ol>
<li>
<p>Choose $a$, $b$, $N$, and $k_0$ as above, sufficient to represent the
 initial state of your wave function $\psi(x)$. (<strong>Warning:</strong> this is perhaps
 the hardest part of the entire solution. If limits in $x$ or $k$ are chosen
 which do not suit your problem, then the approximations used above can
 destroy the accuracy of the calculation!) Once these are chosen, then
 $\Delta x = (b - a) / N$ and $\Delta k = 2\pi / (b - a)$. Define
 $x_n = a + n \Delta x$ and $k_m = k_0 + m \Delta k$.</p>
</li>
<li>
<p>Discretize the wave-functions on this grid. Let $\psi_n(t) = \psi(x_n, t)$,
 $V_n = V(x_n)$, and $\widetilde{\psi}_m = \widetilde{\psi}(k_m, t)$.</p>
</li>
<li>
<p>To progress the system by a time-step $\Delta t$, perform the following:</p>
</li>
<li>
<p>Compute a half-step in $x$:
 $\psi_n \longleftarrow \psi_n
 \exp[-i (\Delta t / 2) (V_n / \hbar)]$</p>
</li>
<li>
<p>Calculate $\widetilde{\psi}_m$ from $\psi_n$ using the FFT.</p>
</li>
<li>
<p>Compute a full-step in $k$:
 $\widetilde{\psi}_m \longleftarrow \widetilde{\psi}_m
 \exp[-i \hbar (k \cdot k) \Delta t / (2 m)]$</p>
</li>
<li>
<p>Calculate $\psi_n$ from $\widetilde{\psi}_m$ using the inverse FFT.</p>
</li>
<li>
<p>Compute a second half-step in $x$:
 $\psi_n \longleftarrow \psi_n
 \exp[-i (\Delta t / 2)(V_n / \hbar)]$</p>
</li>
<li>
<p>Repeat step 3 until the desired time is reached.</p>
</li>
</ol>
<p>Note that we have split the $x$-space time-step into two half-steps: this
turns out to lead to a more stable numerical solution than performing
the step all at once. Those familiar with numerical integration
algorithms may recognize this as an example of the
well-known leap-frog integration technique.</p>
<p>To test this out, I've written a python code which sets up a particle in a
box with a potential barrier. The barrier is high enough that a classical
particle would be unable to penetrate it. A quantum particle, however, can
"tunnel" through, leading to a non-zero probability of finding the particle
on the other side of the partition. This quantum tunneling effect lies at
the core of technologies as diverse as electron microsopy, semiconding diodes,
and perhaps even the future of low-powered transistors.</p>
<p>The animation of the result is below (for a brief introduction to the animation
capabilities of python, see
<a href="/blog/2012/08/18/matplotlib-animation-tutorial/">this post</a>).
The top panel shows the position-space wave function, while the bottom panel
shows the momentum-space wave function.</p>
<p>Notice that the height of the potential barrier (denoted by the dashed line in
the bottom panel) is far larger than the energy of the particle. Still, due
to quantum effects, a small part of the wave function is able to tunnel through
the barrier and reach the other side.</p>
<p>The python code used to generate this animation is included below. It's pretty
long, but I've tried to comment extensively to make the algorithm more clear.
If you're so inclined, you might try running the example and adjusting the
potential or the input wave function to see the effect on the dynamics of
the quantum system.</p>
<figure>
<figcaption>Schrodinger schrodinger.py <a href="/downloads/code/schrodinger.py">download</a></figcaption>
<div><pre>"""
General Numerical Solver for the 1D Time-Dependent Schrodinger's equation.
author: Jake Vanderplas
email: vanderplas@astro.washington.edu
website: http://jakevdp.github.com
license: BSD
Please feel free to use and modify this, but keep the above information. Thanks!
"""
import numpy as np
from matplotlib import pyplot as pl
from matplotlib import animation
from scipy.fftpack import fft,ifft
class Schrodinger(object):
 """
 Class which implements a numerical solution of the time-dependent
 Schrodinger equation for an arbitrary potential
 """
 def __init__(self, x, psi_x0, V_x,
 k0 = None, hbar=1, m=1, t0=0.0):
 """
 Parameters
 ----------
 x : array_like, float
 length-N array of evenly spaced spatial coordinates
 psi_x0 : array_like, complex
 length-N array of the initial wave function at time t0
 V_x : array_like, float
 length-N array giving the potential at each x
 k0 : float
 the minimum value of k. Note that, because of the workings of the
 fast fourier transform, the momentum wave-number will be defined
 in the range
 k0 &lt; k &lt; 2*pi / dx
 where dx = x[1]-x[0]. If you expect nonzero momentum outside this
 range, you must modify the inputs accordingly. If not specified,
 k0 will be calculated such that the range is [-k0,k0]
 hbar : float
 value of planck's constant (default = 1)
 m : float
 particle mass (default = 1)
 t0 : float
 initial tile (default = 0)
 """
 # Validation of array inputs
 self.x, psi_x0, self.V_x = map(np.asarray, (x, psi_x0, V_x))
 N = self.x.size
 assert self.x.shape == (N,)
 assert psi_x0.shape == (N,)
 assert self.V_x.shape == (N,)
 # Set internal parameters
 self.hbar = hbar
 self.m = m
 self.t = t0
 self.dt_ = None
 self.N = len(x)
 self.dx = self.x[1] - self.x[0]
 self.dk = 2 * np.pi / (self.N * self.dx)
 # set momentum scale
 if k0 == None:
 self.k0 = -0.5 * self.N * self.dk
 else:
 self.k0 = k0
 self.k = self.k0 + self.dk * np.arange(self.N)
 self.psi_x = psi_x0
 self.compute_k_from_x()
 # variables which hold steps in evolution of the
 self.x_evolve_half = None
 self.x_evolve = None
 self.k_evolve = None
 # attributes used for dynamic plotting
 self.psi_x_line = None
 self.psi_k_line = None
 self.V_x_line = None
 def _set_psi_x(self, psi_x):
 self.psi_mod_x = (psi_x * np.exp(-1j * self.k[0] * self.x)
 * self.dx / np.sqrt(2 * np.pi))
 def _get_psi_x(self):
 return (self.psi_mod_x * np.exp(1j * self.k[0] * self.x)
 * np.sqrt(2 * np.pi) / self.dx)
 def _set_psi_k(self, psi_k):
 self.psi_mod_k = psi_k * np.exp(1j * self.x[0]
 * self.dk * np.arange(self.N))
 def _get_psi_k(self):
 return self.psi_mod_k * np.exp(-1j * self.x[0] * 
 self.dk * np.arange(self.N))
 
 def _get_dt(self):
 return self.dt_
 def _set_dt(self, dt):
 if dt != self.dt_:
 self.dt_ = dt
 self.x_evolve_half = np.exp(-0.5 * 1j * self.V_x
 / self.hbar * dt )
 self.x_evolve = self.x_evolve_half * self.x_evolve_half
 self.k_evolve = np.exp(-0.5 * 1j * self.hbar /
 self.m * (self.k * self.k) * dt)
 
 psi_x = property(_get_psi_x, _set_psi_x)
 psi_k = property(_get_psi_k, _set_psi_k)
 dt = property(_get_dt, _set_dt)
 def compute_k_from_x(self):
 self.psi_mod_k = fft(self.psi_mod_x)
 def compute_x_from_k(self):
 self.psi_mod_x = ifft(self.psi_mod_k)
 def time_step(self, dt, Nsteps = 1):
 """
 Perform a series of time-steps via the time-dependent
 Schrodinger Equation.
 Parameters
 ----------
 dt : float
 the small time interval over which to integrate
 Nsteps : float, optional
 the number of intervals to compute. The total change
 in time at the end of this method will be dt * Nsteps.
 default is N = 1
 """
 self.dt = dt
 if Nsteps &gt; 0:
 self.psi_mod_x *= self.x_evolve_half
 for i in xrange(Nsteps - 1):
 self.compute_k_from_x()
 self.psi_mod_k *= self.k_evolve
 self.compute_x_from_k()
 self.psi_mod_x *= self.x_evolve
 self.compute_k_from_x()
 self.psi_mod_k *= self.k_evolve
 self.compute_x_from_k()
 self.psi_mod_x *= self.x_evolve_half
 self.compute_k_from_x()
 self.t += dt * Nsteps
######################################################################
# Helper functions for gaussian wave-packets
def gauss_x(x, a, x0, k0):
 """
 a gaussian wave packet of width a, centered at x0, with momentum k0
 """ 
 return ((a * np.sqrt(np.pi)) ** (-0.5)
 * np.exp(-0.5 * ((x - x0) * 1. / a) ** 2 + 1j * x * k0))
def gauss_k(k,a,x0,k0):
 """
 analytical fourier transform of gauss_x(x), above
 """
 return ((a / np.sqrt(np.pi))**0.5
 * np.exp(-0.5 * (a * (k - k0)) ** 2 - 1j * (k - k0) * x0))
######################################################################
# Utility functions for running the animation
def theta(x):
 """
 theta function :
 returns 0 if x&lt;=0, and 1 if x&gt;0
 """
 x = np.asarray(x)
 y = np.zeros(x.shape)
 y[x &gt; 0] = 1.0
 return y
def square_barrier(x, width, height):
 return height * (theta(x) - theta(x - width))
######################################################################
# Create the animation
# specify time steps and duration
dt = 0.01
N_steps = 50
t_max = 120
frames = int(t_max / float(N_steps * dt))
# specify constants
hbar = 1.0 # planck's constant
m = 1.9 # particle mass
# specify range in x coordinate
N = 2 ** 11
dx = 0.1
x = dx * (np.arange(N) - 0.5 * N)
# specify potential
V0 = 1.5
L = hbar / np.sqrt(2 * m * V0)
a = 3 * L
x0 = -60 * L
V_x = square_barrier(x, a, V0)
V_x[x &lt; -98] = 1E6
V_x[x &gt; 98] = 1E6
# specify initial momentum and quantities derived from it
p0 = np.sqrt(2 * m * 0.2 * V0)
dp2 = p0 * p0 * 1./80
d = hbar / np.sqrt(2 * dp2)
k0 = p0 / hbar
v0 = p0 / m
psi_x0 = gauss_x(x, d, x0, k0)
# define the Schrodinger object which performs the calculations
S = Schrodinger(x=x,
 psi_x0=psi_x0,
 V_x=V_x,
 hbar=hbar,
 m=m,
 k0=-28)
######################################################################
# Set up plot
fig = pl.figure()
# plotting limits
xlim = (-100, 100)
klim = (-5, 5)
# top axes show the x-space data
ymin = 0
ymax = V0
ax1 = fig.add_subplot(211, xlim=xlim,
 ylim=(ymin - 0.2 * (ymax - ymin),
 ymax + 0.2 * (ymax - ymin)))
psi_x_line, = ax1.plot([], [], c='r', label=r'$|\psi(x)|$')
V_x_line, = ax1.plot([], [], c='k', label=r'$V(x)$')
center_line = ax1.axvline(0, c='k', ls=':',
 label = r"$x_0 + v_0t$")
title = ax1.set_title("")
ax1.legend(prop=dict(size=12))
ax1.set_xlabel('$x$')
ax1.set_ylabel(r'$|\psi(x)|$')
# bottom axes show the k-space data
ymin = abs(S.psi_k).min()
ymax = abs(S.psi_k).max()
ax2 = fig.add_subplot(212, xlim=klim,
 ylim=(ymin - 0.2 * (ymax - ymin),
 ymax + 0.2 * (ymax - ymin)))
psi_k_line, = ax2.plot([], [], c='r', label=r'$|\psi(k)|$')
p0_line1 = ax2.axvline(-p0 / hbar, c='k', ls=':', label=r'$\pm p_0$')
p0_line2 = ax2.axvline(p0 / hbar, c='k', ls=':')
mV_line = ax2.axvline(np.sqrt(2 * V0) / hbar, c='k', ls='--',
 label=r'$\sqrt{2mV_0}$')
ax2.legend(prop=dict(size=12))
ax2.set_xlabel('$k$')
ax2.set_ylabel(r'$|\psi(k)|$')
V_x_line.set_data(S.x, S.V_x)
######################################################################
# Animate plot
def init():
 psi_x_line.set_data([], [])
 V_x_line.set_data([], [])
 center_line.set_data([], [])
 psi_k_line.set_data([], [])
 title.set_text("")
 return (psi_x_line, V_x_line, center_line, psi_k_line, title)
def animate(i):
 S.time_step(dt, N_steps)
 psi_x_line.set_data(S.x, 4 * abs(S.psi_x))
 V_x_line.set_data(S.x, S.V_x)
 center_line.set_data(2 * [x0 + S.t * p0 / m], [0, 1])
 psi_k_line.set_data(S.k, abs(S.psi_k))
 title.set_text("t = %.2f" % S.t)
 return (psi_x_line, V_x_line, center_line, psi_k_line, title)
# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
 frames=frames, interval=30, blit=True)
# uncomment the following line to save the video in mp4 format. This
# requires either mencoder or ffmpeg to be installed on your system
#anim.save('schrodinger_barrier.mp4', fps=15, extra_args=['-vcodec', 'libx264'])
pl.show()
</pre></div>
</figure>
<p><em>Edit: I changed the legend font properties to play nicely with older
 matplotlib versions. Thanks to Yann for pointing it out.</em></p>
 </div>||||I|||| Pythonic Perambulations
 * About
 * Archive
 * 

 Quantum Python: Animating the Schrodinger Equation

 Wed 05 September 2012

 Update: a reader contributed some improvements to the Python code presented below. Please see the pySchrodinger github repository for updated code

 In a previous post I explored the new animation capabilities of the latest matplotlib release. It got me wondering whether it would be possible to simulate more complicated physical systems in real time in python. Quantum Mechanics was the first thing that came to mind. It turns out that by mixing a bit of Physics knowledge with a bit of computing knowledge, it's quite straightforward to simulate and animate a simple quantum mechanical system with python.

 The Schrodinger Equation

 The dynamics of a one-dimensional quantum system are governed by the time-dependent Schrodinger equation:

 $$ i\hbar\frac{\partial \psi}{\partial t} = \frac{-\hbar^2}{2m} \frac{\partial^2 \psi}{\partial x^2} + V \psi $$

 The wave function $\psi$ is a function of both position $x$ and time $t$, and is the fundamental description of the realm of the very small. Imagine we are following the motion of a single particle in one dimension. This wave function represents a probability of measuring the particle at a position $x$ at a time $t$. Quantum mechanics tells us that (contrary to our familiar classical reasoning) this probability is not a limitation of our knowledge of the system, but a reflection of an unavoidable uncertainty about the position and time of events in the realm of the very small.

 Still, this equation is a bit opaque, but to visualize the results we'll need to solve this numerically. We'll approach this using the split-step Fourier method.

 The Split-step Fourier Method

 A standard way to numerically solve certain differential equations is through the use of the Fourier transform. We'll use a Fourier convention of the following form:

 $$ \widetilde{\psi}(k, t) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} \psi(x, t) e^{-ikx} dx $$

 Under this convention, the associated inverse Fourier Transform is given by:

 $$ \psi(x, t) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} \widetilde{\psi}(k, t) e^{ikx} dk $$

 Substituting this into the Schrodinger equation and simplifying gives the Fourier-space form of the Schrodinger equation:

 $$ i\hbar\frac{\partial \widetilde{\psi}}{\partial t} = \frac{\hbar^2 k^2}{2m} \widetilde{\psi} + V(i\frac{\partial}{\partial k})\widetilde{\psi} $$

 The two versions of the Schrodinger equation contain an interesting symmetry: the time step in each case depends on a straightforward multiplication of the wave function $\psi$, as well as a more complicated term involving derivatives with respect to $x$ or $k$. The key observation is that while the equation is difficult to evaluate fully within one of the forms, each basis offers a straightforward calculation of one of the two contributions. This suggests an efficient strategy to numerically solve the Schrodinger Equation.

 First we solve the straightforward part of the $x$-space Schrodinger equation:

 $$ i\hbar\frac{\partial \psi}{\partial t} = V(x) \psi $$

 For a small time step $\Delta t$, this has a solution of the form

 $$ \psi(x, t + \Delta t) = \psi(x, t) e^{-i V(x) \Delta t / \hbar} $$

 Second, we solve the straightforward part of the $k$-space Schrodinger equation:

 $$ i\hbar\frac{\partial \widetilde{\psi}}{\partial t} = \frac{\hbar^2 k^2}{2 m} \widetilde{\psi} $$

 For a small time step $\Delta t$, this has a solution of the form

 $$ \widetilde{\psi}(k, t + \Delta t) = \widetilde{\psi}(k, t) e^{-i \hbar k^2 \Delta t / 2m} $$

 Numerical Considerations

 Solving this system numerically will require repeated computations of the Fourier transform of $\psi(x, t)$ and the inverse Fourier transform of $\widetilde{\psi}(k, t)$. The best-known algorithm for computation of numerical Fourier transforms is the Fast Fourier Transform (FFT), which is available in scipy and efficiently computes the following form of the discrete Fourier transform:

 $$ \widetilde{F_m} = \sum_{n=0}^{N-1} F_n e^{-2\pi i n m / N} $$

 and its inverse

 $$ F_n = \frac{1}{N} \sum_{m=0}^{N-1} \widetilde{F_m} e^{2\pi i n m / N} $$

 We need to know how these relate to the continuous Fourier transforms defined and used above. Let's take the example of the forward transform. Assume that the infinite integral is well-approximated by the finite integral from $a$ to $b$, so that we can write

 $$ \widetilde{\psi}(k, t) = \frac{1}{\sqrt{2\pi}} \int_a^b \psi(x, t) e^{-ikx} dx $$

 This approximation ends up being equivalent to assuming that the potential $V(x) \to \infty$ at $x \le a$ and $x \ge b$. We'll now approximate this integral as a Riemann sum of $N$ terms, and define $\Delta x = (b - a) / N$, and $x_n = a + n\Delta x$:

 $$ \widetilde{\psi}(k, t) \simeq \frac{1}{\sqrt{2\pi}} \sum_{n=0}^{N-1} \psi(x_n, t) e^{-ikx_n} \Delta x $$

 This is starting to look like the discrete Fourier transform! To bring it even closer, let's define $k_m = k_0 + m\Delta k$, with $\Delta k = 2\pi / (N\Delta x)$. Then our approximation becomes

 $$ \widetilde{\psi}(k_m, t) \simeq \frac{1}{\sqrt{2\pi}} \sum_{n=0}^{N-1} \psi(x_n, t) e^{-ik_m x_n} \Delta x $$

 (Note that just as we have limited the range of $x$ above, we have here limited the range of $k$ as well. This means that high-frequency components of the signal will be lost in our approximation. The Nyquist sampling theorem tells us that this is an unavoidable consequence of choosing discrete steps in space, and it can be shown that the spacing we chose above exactly satisfies the Nyquist limit if we choose $k_0 = - \pi / \Delta x$).

 Plugging our expressions for $x_n$ and $k_m$ into the Fourier approximation and rearranging, we find the following:

 $$ \left[\widetilde{\psi}(k_m, t) e^{i m x_0 \Delta k}\right] \simeq \sum_{n=0}^{N-1} \left[ \frac{\Delta x}{\sqrt{2\pi}} \psi(x_n, t) e^{-ik_0 x_n} \right] e^{-2\pi i m n / N} $$

 Similar arguments from the inverse Fourier transform yield:

 $$ \left[\frac{\Delta x}{\sqrt{2 \pi}} \psi(x_n, t) e^{-i k_0 x_n}\right] \simeq \frac{1}{N} \sum_{m=0}^{N-1} \left[\widetilde{\psi}(k_m, t) e^{-i m x_0 \Delta k} \right] e^{2\pi i m n / N} $$

 Comparing these to the discrete Fourier transforms above, we find that the continuous Fourier pair

 $$ \psi(x, t) \Longleftrightarrow \widetilde{\psi}(k, t) $$

 corresponds to the discrete Fourier pair

 $$ \frac{\Delta x}{\sqrt{2 \pi}} \psi(x_n, t) e^{-i k_0 x_n} \Longleftrightarrow \widetilde{\psi}(k_m, t) e^{-i m x_0 \Delta k} $$

 subject to the approximations mentioned above. This allows a fast numerical evaluation of the Schrodinger equation.

 Putting It All Together: the Algorithm

 We now put this all together using the following algorithm

 1. Choose $a$, $b$, $N$, and $k_0$ as above, sufficient to represent the initial state of your wave function $\psi(x)$. (Warning: this is perhaps the hardest part of the entire solution. If limits in $x$ or $k$ are chosen which do not suit your problem, then the approximations used above can destroy the accuracy of the calculation!) Once these are chosen, then $\Delta x = (b - a) / N$ and $\Delta k = 2\pi / (b - a)$. Define $x_n = a + n \Delta x$ and $k_m = k_0 + m \Delta k$.

 2. Discretize the wave-functions on this grid. Let $\psi_n(t) = \psi(x_n, t)$, $V_n = V(x_n)$, and $\widetilde{\psi}_m = \widetilde{\psi}(k_m, t)$.

 3. To progress the system by a time-step $\Delta t$, perform the following:

 4. Compute a half-step in $x$: $\psi_n \longleftarrow \psi_n \exp[-i (\Delta t / 2) (V_n / \hbar)]$

 5. Calculate $\widetilde{\psi}_m$ from $\psi_n$ using the FFT.

 6. Compute a full-step in $k$: $\widetilde{\psi}_m \longleftarrow \widetilde{\psi}_m \exp[-i \hbar (k \cdot k) \Delta t / (2 m)]$

 7. Calculate $\psi_n$ from $\widetilde{\psi}_m$ using the inverse FFT.

 8. Compute a second half-step in $x$: $\psi_n \longleftarrow \psi_n \exp[-i (\Delta t / 2)(V_n / \hbar)]$

 9. Repeat step 3 until the desired time is reached.

 Note that we have split the $x$-space time-step into two half-steps: this turns out to lead to a more stable numerical solution than performing the step all at once. Those familiar with numerical integration algorithms may recognize this as an example of the well-known leap-frog integration technique.

 To test this out, I've written a python code which sets up a particle in a box with a potential barrier. The barrier is high enough that a classical particle would be unable to penetrate it. A quantum particle, however, can "tunnel" through, leading to a non-zero probability of finding the particle on the other side of the partition. This quantum tunneling effect lies at the core of technologies as diverse as electron microsopy, semiconding diodes, and perhaps even the future of low-powered transistors.

 The animation of the result is below (for a brief introduction to the animation capabilities of python, see this post). The top panel shows the position-space wave function, while the bottom panel shows the momentum-space wave function.

 Notice that the height of the potential barrier (denoted by the dashed line in the bottom panel) is far larger than the energy of the particle. Still, due to quantum effects, a small part of the wave function is able to tunnel through the barrier and reach the other side.

 The python code used to generate this animation is included below. It's pretty long, but I've tried to comment extensively to make the algorithm more clear. If you're so inclined, you might try running the example and adjusting the potential or the input wave function to see the effect on the dynamics of the quantum system.

 Schrodinger schrodinger.py download

 """
 General Numerical Solver for the 1D Time-Dependent Schrodinger's equation.
 
 author: Jake Vanderplas
 email: vanderplas@astro.washington.edu
 website: http://jakevdp.github.com
 license: BSD
 Please feel free to use and modify this, but keep the above information. Thanks!
 """
 
 import numpy as np
 from matplotlib import pyplot as pl
 from matplotlib import animation
 from scipy.fftpack import fft,ifft
 
 
 class Schrodinger(object):
 """
 Class which implements a numerical solution of the time-dependent
 Schrodinger equation for an arbitrary potential
 """
 def __init__(self, x, psi_x0, V_x,
 k0 = None, hbar=1, m=1, t0=0.0):
 """
 Parameters
 ----------
 x : array_like, float
 length-N array of evenly spaced spatial coordinates
 psi_x0 : array_like, complex
 length-N array of the initial wave function at time t0
 V_x : array_like, float
 length-N array giving the potential at each x
 k0 : float
 the minimum value of k. Note that, because of the workings of the
 fast fourier transform, the momentum wave-number will be defined
 in the range
 k0 < k < 2*pi / dx
 where dx = x[1]-x[0]. If you expect nonzero momentum outside this
 range, you must modify the inputs accordingly. If not specified,
 k0 will be calculated such that the range is [-k0,k0]
 hbar : float
 value of planck's constant (default = 1)
 m : float
 particle mass (default = 1)
 t0 : float
 initial tile (default = 0)
 """
 # Validation of array inputs
 self.x, psi_x0, self.V_x = map(np.asarray, (x, psi_x0, V_x))
 N = self.x.size
 assert self.x.shape == (N,)
 assert psi_x0.shape == (N,)
 assert self.V_x.shape == (N,)
 
 # Set internal parameters
 self.hbar = hbar
 self.m = m
 self.t = t0
 self.dt_ = None
 self.N = len(x)
 self.dx = self.x[1] - self.x[0]
 self.dk = 2 * np.pi / (self.N * self.dx)
 
 # set momentum scale
 if k0 == None:
 self.k0 = -0.5 * self.N * self.dk
 else:
 self.k0 = k0
 self.k = self.k0 + self.dk * np.arange(self.N)
 
 self.psi_x = psi_x0
 self.compute_k_from_x()
 
 # variables which hold steps in evolution of the
 self.x_evolve_half = None
 self.x_evolve = None
 self.k_evolve = None
 
 # attributes used for dynamic plotting
 self.psi_x_line = None
 self.psi_k_line = None
 self.V_x_line = None
 
 def _set_psi_x(self, psi_x):
 self.psi_mod_x = (psi_x * np.exp(-1j * self.k[0] * self.x)
 * self.dx / np.sqrt(2 * np.pi))
 
 def _get_psi_x(self):
 return (self.psi_mod_x * np.exp(1j * self.k[0] * self.x)
 * np.sqrt(2 * np.pi) / self.dx)
 
 def _set_psi_k(self, psi_k):
 self.psi_mod_k = psi_k * np.exp(1j * self.x[0]
 * self.dk * np.arange(self.N))
 
 def _get_psi_k(self):
 return self.psi_mod_k * np.exp(-1j * self.x[0] * 
 self.dk * np.arange(self.N))
 
 def _get_dt(self):
 return self.dt_
 
 def _set_dt(self, dt):
 if dt != self.dt_:
 self.dt_ = dt
 self.x_evolve_half = np.exp(-0.5 * 1j * self.V_x
 / self.hbar * dt )
 self.x_evolve = self.x_evolve_half * self.x_evolve_half
 self.k_evolve = np.exp(-0.5 * 1j * self.hbar /
 self.m * (self.k * self.k) * dt)
 
 psi_x = property(_get_psi_x, _set_psi_x)
 psi_k = property(_get_psi_k, _set_psi_k)
 dt = property(_get_dt, _set_dt)
 
 def compute_k_from_x(self):
 self.psi_mod_k = fft(self.psi_mod_x)
 
 def compute_x_from_k(self):
 self.psi_mod_x = ifft(self.psi_mod_k)
 
 def time_step(self, dt, Nsteps = 1):
 """
 Perform a series of time-steps via the time-dependent
 Schrodinger Equation.
 
 Parameters
 ----------
 dt : float
 the small time interval over which to integrate
 Nsteps : float, optional
 the number of intervals to compute. The total change
 in time at the end of this method will be dt * Nsteps.
 default is N = 1
 """
 self.dt = dt
 
 if Nsteps > 0:
 self.psi_mod_x *= self.x_evolve_half
 
 for i in xrange(Nsteps - 1):
 self.compute_k_from_x()
 self.psi_mod_k *= self.k_evolve
 self.compute_x_from_k()
 self.psi_mod_x *= self.x_evolve
 
 self.compute_k_from_x()
 self.psi_mod_k *= self.k_evolve
 
 self.compute_x_from_k()
 self.psi_mod_x *= self.x_evolve_half
 
 self.compute_k_from_x()
 
 self.t += dt * Nsteps
 
 
 ######################################################################
 # Helper functions for gaussian wave-packets
 
 def gauss_x(x, a, x0, k0):
 """
 a gaussian wave packet of width a, centered at x0, with momentum k0
 """ 
 return ((a * np.sqrt(np.pi)) ** (-0.5)
 * np.exp(-0.5 * ((x - x0) * 1. / a) ** 2 + 1j * x * k0))
 
 def gauss_k(k,a,x0,k0):
 """
 analytical fourier transform of gauss_x(x), above
 """
 return ((a / np.sqrt(np.pi))**0.5
 * np.exp(-0.5 * (a * (k - k0)) ** 2 - 1j * (k - k0) * x0))
 
 
 ######################################################################
 # Utility functions for running the animation
 
 def theta(x):
 """
 theta function :
 returns 0 if x<=0, and 1 if x>0
 """
 x = np.asarray(x)
 y = np.zeros(x.shape)
 y[x > 0] = 1.0
 return y
 
 def square_barrier(x, width, height):
 return height * (theta(x) - theta(x - width))
 
 ######################################################################
 # Create the animation
 
 # specify time steps and duration
 dt = 0.01
 N_steps = 50
 t_max = 120
 frames = int(t_max / float(N_steps * dt))
 
 # specify constants
 hbar = 1.0 # planck's constant
 m = 1.9 # particle mass
 
 # specify range in x coordinate
 N = 2 ** 11
 dx = 0.1
 x = dx * (np.arange(N) - 0.5 * N)
 
 # specify potential
 V0 = 1.5
 L = hbar / np.sqrt(2 * m * V0)
 a = 3 * L
 x0 = -60 * L
 V_x = square_barrier(x, a, V0)
 V_x[x < -98] = 1E6
 V_x[x > 98] = 1E6
 
 # specify initial momentum and quantities derived from it
 p0 = np.sqrt(2 * m * 0.2 * V0)
 dp2 = p0 * p0 * 1./80
 d = hbar / np.sqrt(2 * dp2)
 
 k0 = p0 / hbar
 v0 = p0 / m
 psi_x0 = gauss_x(x, d, x0, k0)
 
 # define the Schrodinger object which performs the calculations
 S = Schrodinger(x=x,
 psi_x0=psi_x0,
 V_x=V_x,
 hbar=hbar,
 m=m,
 k0=-28)
 
 ######################################################################
 # Set up plot
 fig = pl.figure()
 
 # plotting limits
 xlim = (-100, 100)
 klim = (-5, 5)
 
 # top axes show the x-space data
 ymin = 0
 ymax = V0
 ax1 = fig.add_subplot(211, xlim=xlim,
 ylim=(ymin - 0.2 * (ymax - ymin),
 ymax + 0.2 * (ymax - ymin)))
 psi_x_line, = ax1.plot([], [], c='r', label=r'$|\psi(x)|$')
 V_x_line, = ax1.plot([], [], c='k', label=r'$V(x)$')
 center_line = ax1.axvline(0, c='k', ls=':',
 label = r"$x_0 + v_0t$")
 
 title = ax1.set_title("")
 ax1.legend(prop=dict(size=12))
 ax1.set_xlabel('$x$')
 ax1.set_ylabel(r'$|\psi(x)|$')
 
 # bottom axes show the k-space data
 ymin = abs(S.psi_k).min()
 ymax = abs(S.psi_k).max()
 ax2 = fig.add_subplot(212, xlim=klim,
 ylim=(ymin - 0.2 * (ymax - ymin),
 ymax + 0.2 * (ymax - ymin)))
 psi_k_line, = ax2.plot([], [], c='r', label=r'$|\psi(k)|$')
 
 p0_line1 = ax2.axvline(-p0 / hbar, c='k', ls=':', label=r'$\pm p_0$')
 p0_line2 = ax2.axvline(p0 / hbar, c='k', ls=':')
 mV_line = ax2.axvline(np.sqrt(2 * V0) / hbar, c='k', ls='--',
 label=r'$\sqrt{2mV_0}$')
 ax2.legend(prop=dict(size=12))
 ax2.set_xlabel('$k$')
 ax2.set_ylabel(r'$|\psi(k)|$')
 
 V_x_line.set_data(S.x, S.V_x)
 
 ######################################################################
 # Animate plot
 def init():
 psi_x_line.set_data([], [])
 V_x_line.set_data([], [])
 center_line.set_data([], [])
 
 psi_k_line.set_data([], [])
 title.set_text("")
 return (psi_x_line, V_x_line, center_line, psi_k_line, title)
 
 def animate(i):
 S.time_step(dt, N_steps)
 psi_x_line.set_data(S.x, 4 * abs(S.psi_x))
 V_x_line.set_data(S.x, S.V_x)
 center_line.set_data(2 * [x0 + S.t * p0 / m], [0, 1])
 
 psi_k_line.set_data(S.k, abs(S.psi_k))
 title.set_text("t = %.2f" % S.t)
 return (psi_x_line, V_x_line, center_line, psi_k_line, title)
 
 # call the animator. blit=True means only re-draw the parts that have changed.
 anim = animation.FuncAnimation(fig, animate, init_func=init,
 frames=frames, interval=30, blit=True)
 
 
 # uncomment the following line to save the video in mp4 format. This
 # requires either mencoder or ffmpeg to be installed on your system
 
 #anim.save('schrodinger_barrier.mp4', fps=15, extra_args=['-vcodec', 'libx264'])
 
 pl.show()
 

 Edit: I changed the legend font properties to play nicely with older matplotlib versions. Thanks to Yann for pointing it out.

 matplotlib animation simulation

 Comments

 Please enable JavaScript to view the comments powered by Disqus.
Update: a reader contributed some improvements to the Python code presented
 below. Please see the
pySchrodinger github repository
for updated code 
In a previous post
I explored the new animation capabilities of the latest
matplotlib release.
It got me wondering whether it would be possible to simulate more complicated
physical systems in real time in python. Quantum Mechanics was the first
thing that came to mind. It turns out that by mixing a bit of Physics
knowledge with a bit of computing knowledge, it's quite straightforward
to simulate and animate a simple quantum mechanical system with python.
The Schrodinger Equation
The dynamics of a one-dimensional quantum system are governed by the
time-dependent Schrodinger equation:
$$
i\hbar\frac{\partial \psi}{\partial t}
 = \frac{-\hbar^2}{2m} \frac{\partial^2 \psi}{\partial x^2} + V \psi
$$
The wave function $\psi$ is a function of both position $x$ and time $t$,
and is the fundamental description of the realm of the very small.
Imagine we are following the motion of a single particle in one
dimension. This wave function represents a probability of measuring
the particle at a position $x$ at a time $t$. Quantum mechanics tells us that
(contrary to our familiar classical reasoning) this probability is not
a limitation of our knowledge of the system, but a reflection of an
unavoidable uncertainty about the position and time of events in the realm
of the very small.
Still, this equation is a bit opaque, but to visualize the results we'll need
to solve this numerically. We'll approach this using the split-step Fourier
method.
The Split-step Fourier Method
A standard way to numerically solve certain differential equations is
through the use of the Fourier transform. We'll use a Fourier convention
of the following form:
$$
\widetilde{\psi}(k, t) = \frac{1}{\sqrt{2\pi}}
 \int_{-\infty}^{\infty} \psi(x, t) e^{-ikx} dx
$$
Under this convention, the associated inverse Fourier Transform is given by:
$$
\psi(x, t) = \frac{1}{\sqrt{2\pi}}
 \int_{-\infty}^{\infty} \widetilde{\psi}(k, t) e^{ikx} dk
$$
Substituting this into the Schrodinger equation and simplifying gives the
Fourier-space form of the Schrodinger equation:
$$
i\hbar\frac{\partial \widetilde{\psi}}{\partial t}
 = \frac{\hbar^2 k^2}{2m} \widetilde{\psi}
 + V(i\frac{\partial}{\partial k})\widetilde{\psi}
$$
The two versions of the Schrodinger equation contain an interesting symmetry:
the time step in each case depends on a straightforward multiplication of
the wave function $\psi$, as well as a more complicated term involving
derivatives with respect to $x$ or $k$. The key observation is that while
the equation is difficult to evaluate fully within one of the forms, each
basis offers a straightforward calculation of one of the two contributions.
This suggests an efficient strategy to numerically solve the Schrodinger
Equation.
First we solve the straightforward part of the $x$-space Schrodinger
equation:
$$
i\hbar\frac{\partial \psi}{\partial t}
 = V(x) \psi
$$
For a small time step $\Delta t$, this has a solution of the form
$$
\psi(x, t + \Delta t) = \psi(x, t) e^{-i V(x) \Delta t / \hbar}
$$
Second, we solve the straightforward part of the $k$-space Schrodinger
equation:
$$
i\hbar\frac{\partial \widetilde{\psi}}{\partial t}
 = \frac{\hbar^2 k^2}{2 m} \widetilde{\psi}
$$
For a small time step $\Delta t$, this has a solution of the form
$$
\widetilde{\psi}(k, t + \Delta t)
 = \widetilde{\psi}(k, t) e^{-i \hbar k^2 \Delta t / 2m}
$$
Numerical Considerations
Solving this system numerically will require repeated computations of the
Fourier transform of $\psi(x, t)$ and the inverse Fourier transform of
$\widetilde{\psi}(k, t)$. The best-known algorithm for computation of
numerical Fourier transforms is the Fast Fourier Transform (FFT), which
is available in scipy
and efficiently computes the following form of the
discrete Fourier transform:
$$
 \widetilde{F_m} = \sum_{n=0}^{N-1} F_n e^{-2\pi i n m / N}
$$
and its inverse
$$
 F_n = \frac{1}{N} \sum_{m=0}^{N-1} \widetilde{F_m} e^{2\pi i n m / N}
$$
We need to know how these relate to the continuous Fourier transforms defined
and used above. Let's take the example of the forward transform. Assume that
the infinite integral is well-approximated by the finite integral from
$a$ to $b$, so that we can write
$$
\widetilde{\psi}(k, t) = \frac{1}{\sqrt{2\pi}}
 \int_a^b \psi(x, t) e^{-ikx} dx
$$
This approximation ends up being equivalent to assuming that the potential
$V(x) \to \infty$ at $x \le a$ and $x \ge b$. We'll now approximate this
integral as a Riemann sum of $N$ terms, and define $\Delta x = (b - a) / N$,
and $x_n = a + n\Delta x$:
$$
\widetilde{\psi}(k, t) \simeq \frac{1}{\sqrt{2\pi}}
 \sum_{n=0}^{N-1} \psi(x_n, t) e^{-ikx_n} \Delta x
$$
This is starting to look like the discrete Fourier transform! To bring it
even closer, let's define $k_m = k_0 + m\Delta k$, with
$\Delta k = 2\pi / (N\Delta x)$. Then our approximation becomes
$$
\widetilde{\psi}(k_m, t) \simeq \frac{1}{\sqrt{2\pi}}
 \sum_{n=0}^{N-1} \psi(x_n, t) e^{-ik_m x_n} \Delta x
$$
(Note that just as we have limited the range of $x$ above, we have here limited
the range of $k$ as well. This means that high-frequency components of the
signal will be lost in our approximation. The Nyquist sampling theorem tells
us that this is an unavoidable consequence of choosing discrete steps in
space, and it can be shown that the spacing we chose above exactly satisfies
the Nyquist limit if we choose $k_0 = - \pi / \Delta x$).
Plugging our expressions for $x_n$ and $k_m$ into the Fourier
approximation and rearranging, we find the following:
$$
\left[\widetilde{\psi}(k_m, t) e^{i m x_0 \Delta k}\right]
 \simeq \sum_{n=0}^{N-1} 
 \left[ \frac{\Delta x}{\sqrt{2\pi}}
 \psi(x_n, t) e^{-ik_0 x_n} \right]
 e^{-2\pi i m n / N}
$$
Similar arguments from the inverse Fourier transform yield:
$$
\left[\frac{\Delta x}{\sqrt{2 \pi}} \psi(x_n, t) e^{-i k_0 x_n}\right]
 \simeq \frac{1}{N} \sum_{m=0}^{N-1} 
 \left[\widetilde{\psi}(k_m, t) e^{-i m x_0 \Delta k} \right]
 e^{2\pi i m n / N}
$$
Comparing these to the discrete Fourier transforms above, we find that the
continuous Fourier pair
$$
 \psi(x, t) \Longleftrightarrow \widetilde{\psi}(k, t)
$$
corresponds to the discrete Fourier pair
$$
 \frac{\Delta x}{\sqrt{2 \pi}} \psi(x_n, t) e^{-i k_0 x_n}
 \Longleftrightarrow
 \widetilde{\psi}(k_m, t) e^{-i m x_0 \Delta k}
$$
subject to the approximations mentioned above. This allows a fast numerical
evaluation of the Schrodinger equation.
Putting It All Together: the Algorithm
We now put this all together using the following algorithm
Choose $a$, $b$, $N$, and $k_0$ as above, sufficient to represent the
 initial state of your wave function $\psi(x)$. (Warning: this is perhaps
 the hardest part of the entire solution. If limits in $x$ or $k$ are chosen
 which do not suit your problem, then the approximations used above can
 destroy the accuracy of the calculation!) Once these are chosen, then
 $\Delta x = (b - a) / N$ and $\Delta k = 2\pi / (b - a)$. Define
 $x_n = a + n \Delta x$ and $k_m = k_0 + m \Delta k$.
Discretize the wave-functions on this grid. Let $\psi_n(t) = \psi(x_n, t)$,
 $V_n = V(x_n)$, and $\widetilde{\psi}_m = \widetilde{\psi}(k_m, t)$.
To progress the system by a time-step $\Delta t$, perform the following:
Compute a half-step in $x$:
 $\psi_n \longleftarrow \psi_n
 \exp[-i (\Delta t / 2) (V_n / \hbar)]$
Calculate $\widetilde{\psi}_m$ from $\psi_n$ using the FFT.
Compute a full-step in $k$:
 $\widetilde{\psi}_m \longleftarrow \widetilde{\psi}_m
 \exp[-i \hbar (k \cdot k) \Delta t / (2 m)]$
Calculate $\psi_n$ from $\widetilde{\psi}_m$ using the inverse FFT.
Compute a second half-step in $x$:
 $\psi_n \longleftarrow \psi_n
 \exp[-i (\Delta t / 2)(V_n / \hbar)]$
Repeat step 3 until the desired time is reached.
Note that we have split the $x$-space time-step into two half-steps: this
turns out to lead to a more stable numerical solution than performing
the step all at once. Those familiar with numerical integration
algorithms may recognize this as an example of the
well-known leap-frog integration technique.
To test this out, I've written a python code which sets up a particle in a
box with a potential barrier. The barrier is high enough that a classical
particle would be unable to penetrate it. A quantum particle, however, can
"tunnel" through, leading to a non-zero probability of finding the particle
on the other side of the partition. This quantum tunneling effect lies at
the core of technologies as diverse as electron microsopy, semiconding diodes,
and perhaps even the future of low-powered transistors.
The animation of the result is below (for a brief introduction to the animation
capabilities of python, see
this post).
The top panel shows the position-space wave function, while the bottom panel
shows the momentum-space wave function.
Notice that the height of the potential barrier (denoted by the dashed line in
the bottom panel) is far larger than the energy of the particle. Still, due
to quantum effects, a small part of the wave function is able to tunnel through
the barrier and reach the other side.
The python code used to generate this animation is included below. It's pretty
long, but I've tried to comment extensively to make the algorithm more clear.
If you're so inclined, you might try running the example and adjusting the
potential or the input wave function to see the effect on the dynamics of
the quantum system.
Schrodinger schrodinger.py download 
 """
General Numerical Solver for the 1D Time-Dependent Schrodinger's equation.
author: Jake Vanderplas
email: vanderplas@astro.washington.edu
website: http://jakevdp.github.com
license: BSD
Please feel free to use and modify this, but keep the above information. Thanks!
"""
import numpy as np
from matplotlib import pyplot as pl
from matplotlib import animation
from scipy.fftpack import fft,ifft
class Schrodinger(object):
 """
 Class which implements a numerical solution of the time-dependent
 Schrodinger equation for an arbitrary potential
 """
 def __init__(self, x, psi_x0, V_x,
 k0 = None, hbar=1, m=1, t0=0.0):
 """
 Parameters
 ----------
 x : array_like, float
 length-N array of evenly spaced spatial coordinates
 psi_x0 : array_like, complex
 length-N array of the initial wave function at time t0
 V_x : array_like, float
 length-N array giving the potential at each x
 k0 : float
 the minimum value of k. Note that, because of the workings of the
 fast fourier transform, the momentum wave-number will be defined
 in the range
 k0 &lt; k &lt; 2*pi / dx
 where dx = x[1]-x[0]. If you expect nonzero momentum outside this
 range, you must modify the inputs accordingly. If not specified,
 k0 will be calculated such that the range is [-k0,k0]
 hbar : float
 value of planck's constant (default = 1)
 m : float
 particle mass (default = 1)
 t0 : float
 initial tile (default = 0)
 """
 # Validation of array inputs
 self.x, psi_x0, self.V_x = map(np.asarray, (x, psi_x0, V_x))
 N = self.x.size
 assert self.x.shape == (N,)
 assert psi_x0.shape == (N,)
 assert self.V_x.shape == (N,)
 # Set internal parameters
 self.hbar = hbar
 self.m = m
 self.t = t0
 self.dt_ = None
 self.N = len(x)
 self.dx = self.x[1] - self.x[0]
 self.dk = 2 * np.pi / (self.N * self.dx)
 # set momentum scale
 if k0 == None:
 self.k0 = -0.5 * self.N * self.dk
 else:
 self.k0 = k0
 self.k = self.k0 + self.dk * np.arange(self.N)
 self.psi_x = psi_x0
 self.compute_k_from_x()
 # variables which hold steps in evolution of the
 self.x_evolve_half = None
 self.x_evolve = None
 self.k_evolve = None
 # attributes used for dynamic plotting
 self.psi_x_line = None
 self.psi_k_line = None
 self.V_x_line = None
 def _set_psi_x(self, psi_x):
 self.psi_mod_x = (psi_x * np.exp(-1j * self.k[0] * self.x)
 * self.dx / np.sqrt(2 * np.pi))
 def _get_psi_x(self):
 return (self.psi_mod_x * np.exp(1j * self.k[0] * self.x)
 * np.sqrt(2 * np.pi) / self.dx)
 def _set_psi_k(self, psi_k):
 self.psi_mod_k = psi_k * np.exp(1j * self.x[0]
 * self.dk * np.arange(self.N))
 def _get_psi_k(self):
 return self.psi_mod_k * np.exp(-1j * self.x[0] * 
 self.dk * np.arange(self.N))
 
 def _get_dt(self):
 return self.dt_
 def _set_dt(self, dt):
 if dt != self.dt_:
 self.dt_ = dt
 self.x_evolve_half = np.exp(-0.5 * 1j * self.V_x
 / self.hbar * dt )
 self.x_evolve = self.x_evolve_half * self.x_evolve_half
 self.k_evolve = np.exp(-0.5 * 1j * self.hbar /
 self.m * (self.k * self.k) * dt)
 
 psi_x = property(_get_psi_x, _set_psi_x)
 psi_k = property(_get_psi_k, _set_psi_k)
 dt = property(_get_dt, _set_dt)
 def compute_k_from_x(self):
 self.psi_mod_k = fft(self.psi_mod_x)
 def compute_x_from_k(self):
 self.psi_mod_x = ifft(self.psi_mod_k)
 def time_step(self, dt, Nsteps = 1):
 """
 Perform a series of time-steps via the time-dependent
 Schrodinger Equation.
 Parameters
 ----------
 dt : float
 the small time interval over which to integrate
 Nsteps : float, optional
 the number of intervals to compute. The total change
 in time at the end of this method will be dt * Nsteps.
 default is N = 1
 """
 self.dt = dt
 if Nsteps &gt; 0:
 self.psi_mod_x *= self.x_evolve_half
 for i in xrange(Nsteps - 1):
 self.compute_k_from_x()
 self.psi_mod_k *= self.k_evolve
 self.compute_x_from_k()
 self.psi_mod_x *= self.x_evolve
 self.compute_k_from_x()
 self.psi_mod_k *= self.k_evolve
 self.compute_x_from_k()
 self.psi_mod_x *= self.x_evolve_half
 self.compute_k_from_x()
 self.t += dt * Nsteps
######################################################################
# Helper functions for gaussian wave-packets
def gauss_x(x, a, x0, k0):
 """
 a gaussian wave packet of width a, centered at x0, with momentum k0
 """ 
 return ((a * np.sqrt(np.pi)) ** (-0.5)
 * np.exp(-0.5 * ((x - x0) * 1. / a) ** 2 + 1j * x * k0))
def gauss_k(k,a,x0,k0):
 """
 analytical fourier transform of gauss_x(x), above
 """
 return ((a / np.sqrt(np.pi))**0.5
 * np.exp(-0.5 * (a * (k - k0)) ** 2 - 1j * (k - k0) * x0))
######################################################################
# Utility functions for running the animation
def theta(x):
 """
 theta function :
 returns 0 if x&lt;=0, and 1 if x&gt;0
 """
 x = np.asarray(x)
 y = np.zeros(x.shape)
 y[x &gt; 0] = 1.0
 return y
def square_barrier(x, width, height):
 return height * (theta(x) - theta(x - width))
######################################################################
# Create the animation
# specify time steps and duration
dt = 0.01
N_steps = 50
t_max = 120
frames = int(t_max / float(N_steps * dt))
# specify constants
hbar = 1.0 # planck's constant
m = 1.9 # particle mass
# specify range in x coordinate
N = 2 ** 11
dx = 0.1
x = dx * (np.arange(N) - 0.5 * N)
# specify potential
V0 = 1.5
L = hbar / np.sqrt(2 * m * V0)
a = 3 * L
x0 = -60 * L
V_x = square_barrier(x, a, V0)
V_x[x &lt; -98] = 1E6
V_x[x &gt; 98] = 1E6
# specify initial momentum and quantities derived from it
p0 = np.sqrt(2 * m * 0.2 * V0)
dp2 = p0 * p0 * 1./80
d = hbar / np.sqrt(2 * dp2)
k0 = p0 / hbar
v0 = p0 / m
psi_x0 = gauss_x(x, d, x0, k0)
# define the Schrodinger object which performs the calculations
S = Schrodinger(x=x,
 psi_x0=psi_x0,
 V_x=V_x,
 hbar=hbar,
 m=m,
 k0=-28)
######################################################################
# Set up plot
fig = pl.figure()
# plotting limits
xlim = (-100, 100)
klim = (-5, 5)
# top axes show the x-space data
ymin = 0
ymax = V0
ax1 = fig.add_subplot(211, xlim=xlim,
 ylim=(ymin - 0.2 * (ymax - ymin),
 ymax + 0.2 * (ymax - ymin)))
psi_x_line, = ax1.plot([], [], c='r', label=r'$|\psi(x)|$')
V_x_line, = ax1.plot([], [], c='k', label=r'$V(x)$')
center_line = ax1.axvline(0, c='k', ls=':',
 label = r"$x_0 + v_0t$")
title = ax1.set_title("")
ax1.legend(prop=dict(size=12))
ax1.set_xlabel('$x$')
ax1.set_ylabel(r'$|\psi(x)|$')
# bottom axes show the k-space data
ymin = abs(S.psi_k).min()
ymax = abs(S.psi_k).max()
ax2 = fig.add_subplot(212, xlim=klim,
 ylim=(ymin - 0.2 * (ymax - ymin),
 ymax + 0.2 * (ymax - ymin)))
psi_k_line, = ax2.plot([], [], c='r', label=r'$|\psi(k)|$')
p0_line1 = ax2.axvline(-p0 / hbar, c='k', ls=':', label=r'$\pm p_0$')
p0_line2 = ax2.axvline(p0 / hbar, c='k', ls=':')
mV_line = ax2.axvline(np.sqrt(2 * V0) / hbar, c='k', ls='--',
 label=r'$\sqrt{2mV_0}$')
ax2.legend(prop=dict(size=12))
ax2.set_xlabel('$k$')
ax2.set_ylabel(r'$|\psi(k)|$')
V_x_line.set_data(S.x, S.V_x)
######################################################################
# Animate plot
def init():
 psi_x_line.set_data([], [])
 V_x_line.set_data([], [])
 center_line.set_data([], [])
 psi_k_line.set_data([], [])
 title.set_text("")
 return (psi_x_line, V_x_line, center_line, psi_k_line, title)
def animate(i):
 S.time_step(dt, N_steps)
 psi_x_line.set_data(S.x, 4 * abs(S.psi_x))
 V_x_line.set_data(S.x, S.V_x)
 center_line.set_data(2 * [x0 + S.t * p0 / m], [0, 1])
 psi_k_line.set_data(S.k, abs(S.psi_k))
 title.set_text("t = %.2f" % S.t)
 return (psi_x_line, V_x_line, center_line, psi_k_line, title)
# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
 frames=frames, interval=30, blit=True)
# uncomment the following line to save the video in mp4 format. This
# requires either mencoder or ffmpeg to be installed on your system
#anim.save('schrodinger_barrier.mp4', fps=15, extra_args=['-vcodec', 'libx264'])
pl.show()
 
 Edit: I changed the legend font properties to play nicely with older
 matplotlib versions. Thanks to Yann for pointing it out.
Quantum Python: Animating the Schrodinger Equation
https://jakevdp.github.io/blog/2012/09/05/quantum-python/
https://scottaaronson.blog/?p=6129
The Acrobatics of BQP
2021-11-19
None
<div><div>
<p>Just in case anyone is depressed this afternoon and needs something to cheer them up, students <a href="https://www.cs.utexas.edu/~kretsch/">William Kretschmer</a>, <a href="https://www.quantitativebiology.northwestern.edu/2021/02/23/three-students-awarded-prizes-in-the-great-math-challenge-in-biology-contest/">DeVon Ingram</a>, and I have finally put out a new paper:</p>
<blockquote><p><strong><a href="https://eccc.weizmann.ac.il/report/2021/164/">The Acrobatics of BQP</a></strong></p><p><strong>Abstract:</strong> We show that, in the black-box setting, the behavior of quantum polynomial-time (BQP) can be remarkably decoupled from that of classical complexity classes like NP. Specifically:</p><p>– There exists an oracle relative to which NP<sup>BQP</sup>⊄BQP<sup>PH</sup>, resolving a 2005 problem of Fortnow. Interpreted another way, we show that AC<sup>0</sup> circuits cannot perform useful homomorphic encryption on instances of the Forrelation problem. As a corollary, there exists an oracle relative to which P=NP but BQP≠QCMA.</p><p>– Conversely, there exists an oracle relative to which BQP<sup>NP</sup>⊄PH<sup>BQP</sup>.</p><p>– Relative to a random oracle, PP=PostBQP is not contained in the “QMA hierarchy” QMA<sup>QMA^QMA^…</sup>, and more generally PP⊄(MIP*)<sup>(MIP*)^(MIP*)^…</sup> (!), despite the fact that MIP*=RE in the unrelativized world. This result shows that there is no black-box quantum analogue of Stockmeyer’s approximate counting algorithm.</p><p>– Relative to a random oracle, Σ<sub>k+1</sub>⊄BQP<sup>Σ_k</sup> for every k.</p><p>– There exists an oracle relative to which BQP=P<sup>#P</sup> and yet PH is infinite. (By contrast, if NP⊆BPP, then PH collapses relative to all oracles.)</p><p>– There exists an oracle relative to which P=NP≠BQP=P<sup>#P</sup>.</p><p>To achieve these results, we build on the 2018 achievement by Raz and Tal of an oracle relative to which BQP⊄PH, and associated results about the Forrelation problem. We also introduce new tools that might be of independent interest. These include a “quantum-aware” version of the random restriction method, a concentration theorem for the block sensitivity of AC<sup>0</sup> circuits, and a (provable) analogue of the Aaronson-Ambainis Conjecture for sparse oracles.</p></blockquote>
<p>Incidentally, particularly when I’ve worked on a project with students, I’m often tremendously excited and want to shout about it from the rooftops for the students’ sake … but then I also don’t want to use this blog to privilege my own papers “unfairly.” Can anyone suggest a principle that I should follow going forward?</p>
<p>
<small>
	This entry was posted
	on Friday, November 19th, 2021 at 3:48 pm	and is filed under <a href="https://scottaaronson.blog/?cat=5">Complexity</a>, <a href="https://scottaaronson.blog/?cat=4">Quantum</a>.
	You can follow any responses to this entry through the <a href="https://scottaaronson.blog/?feed=rss2&amp;p=6129">RSS 2.0</a> feed.
	You can <a href="#respond">leave a response</a>, or <a href="https://scottaaronson.blog/wp-trackback.php?p=6129">trackback</a> from your own site.
	</small>
</p>
</div><p>You can use rich HTML in comments! You can also use basic TeX, by enclosing it within for displayed equations or for inline equations.</p></div>||||I|||| Loading web-font TeX/Math/Italic

 Shtetl-Optimized

 The Blog of Scott Aaronson

 If you take nothing else from this blog: quantum computers won't
 solve hard problems instantly by just trying all solutions in parallel.
 « Scott Aaronson, when reached for comment, said…
 Two new talks and an interview »

 The Acrobatics of BQP

 Just in case anyone is depressed this afternoon and needs something to cheer them up, students William Kretschmer, DeVon Ingram, and I have finally put out a new paper:

 The Acrobatics of BQP

 Abstract: We show that, in the black-box setting, the behavior of quantum polynomial-time (BQP) can be remarkably decoupled from that of classical complexity classes like NP. Specifically:

 – There exists an oracle relative to which NPBQP⊄BQPPH, resolving a 2005 problem of Fortnow. Interpreted another way, we show that AC0 circuits cannot perform useful homomorphic encryption on instances of the Forrelation problem. As a corollary, there exists an oracle relative to which P=NP but BQP≠QCMA.

 – Conversely, there exists an oracle relative to which BQPNP⊄PHBQP.

 – Relative to a random oracle, PP=PostBQP is not contained in the “QMA hierarchy” QMAQMA^QMA^…, and more generally PP⊄(MIP*)(MIP*)^(MIP*)^… (!), despite the fact that MIP*=RE in the unrelativized world. This result shows that there is no black-box quantum analogue of Stockmeyer’s approximate counting algorithm.

 – Relative to a random oracle, Σk+1⊄BQPΣ_k for every k.

 – There exists an oracle relative to which BQP=P#P and yet PH is infinite. (By contrast, if NP⊆BPP, then PH collapses relative to all oracles.)

 – There exists an oracle relative to which P=NP≠BQP=P#P.

 To achieve these results, we build on the 2018 achievement by Raz and Tal of an oracle relative to which BQP⊄PH, and associated results about the Forrelation problem. We also introduce new tools that might be of independent interest. These include a “quantum-aware” version of the random restriction method, a concentration theorem for the block sensitivity of AC0 circuits, and a (provable) analogue of the Aaronson-Ambainis Conjecture for sparse oracles.

 Incidentally, particularly when I’ve worked on a project with students, I’m often tremendously excited and want to shout about it from the rooftops for the students’ sake … but then I also don’t want to use this blog to privilege my own papers “unfairly.” Can anyone suggest a principle that I should follow going forward?

 Follow

 This entry was posted on Friday, November 19th, 2021 at 3:48 pm and is filed under Complexity, Quantum. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

 50 Responses to “The Acrobatics of BQP”

 1. Tu Says:
 Comment #1 November 19th, 2021 at 5:19 pm

 Scott,

 This is your blog. It is completely fine for you to celebrate your students work on your blog. If other students don’t have advisors with awesome blogs, that is their problem!

 2. JimV Says:
 Comment #2 November 19th, 2021 at 5:33 pm

 I don’t see any problem with announcing any or all of your papers on your blog.

 (If I had a blog I would talk about new stuff I had done, as well as other things.)

 Congratulations on the paper!

 3. DS Says:
 Comment #3 November 19th, 2021 at 5:35 pm

 Perhaps allow student-authors of student-led papers (for some definition of that term, e.g., primary authors are students) that prove “major results” to guest-post on this blog at some periodic cadence? Since this is your blog, you get to decide what constitutes a major or interesting result; also, in the spirit of your blog, this can inspire students to write up a version of their result for a broad audience. The banner of this blog can also help shed light on nice results by students from less-well-known institutions.

 4. Grad student Says:
 Comment #4 November 19th, 2021 at 7:30 pm

 I follow this blog in part *because* I am curious about what you, who I like as a person because I’ve been reading your blog for nearly a decade now, have been working on. It would be a shame if you were to post less about your work.

 5. Scott Lawrence Says:
 Comment #5 November 19th, 2021 at 11:51 pm

 If you use this blog to promote your own papers, then others will feel pressure to start their own blogs. Then we’ll end up with more computational complexity blogs. So from a slightly consequentialist/utilitarian standpoint… sounds good to me!

 (And of course I also agree with the takes of Tu and JimV and Grad student above.)

 6. Ajit R. Jadhav Says:
 Comment #6 November 20th, 2021 at 12:09 am

 Oh, so simple… Privilege, for instance, my upcoming paper(s) on QM when(ever) they arrive.

 Best,
 –Ajit

 7. Jay Searson Says:
 Comment #7 November 20th, 2021 at 1:54 am

 Privilege them unfairly. 100%.

 8. Bruno Loff Says:
 Comment #8 November 20th, 2021 at 4:17 am

 It’s your blog, no one really expects it to be a cold, unbiased source of universal truth. If you want to distinguish such posts from posts where you are actually trying to be unbiased, just prefix the post with a disclaimer, like you did now.

 9. John Preskill Says:
 Comment #9 November 20th, 2021 at 10:18 am

 I’m always interested in what Scott Aaronson is “tremendously excited” about, even if it does not involve students. I’m sure many other readers feel the same way.

 10. Scott Says:
 Comment #10 November 20th, 2021 at 10:43 am

 Ok, thanks everyone!! I’m constantly making the error of seeking out the people on social media who dislike me most, and assuming their views should be paramount in my mind, and everything I write or don’t write from that point forward should be in an effort to try to satisfy them. I’m sure I’ll make that error many more times, despite all my attempts to correct for it.

 11. A student Says:
 Comment #11 November 20th, 2021 at 11:10 am

 Hi Scott. A basic question that you may have answered many times. Why do we believe quantum computers maynot solve NP-hard problems in polynomial time?

 12. Michael Ball Says:
 Comment #12 November 20th, 2021 at 11:13 am

 Yay complexity! This looks really interesting. Keep it coming

 13. Scott Says:
 Comment #13 November 20th, 2021 at 12:09 pm

 A student #11: We have indeed discussed many times (especially in this blog’s early days), but briefly, it’s the same sort of reasons someone might have for believing P≠NP, just “quantized.” I.e.,

 (1) Shor’s algorithm works only by exploiting extremely special structure in factoring and discrete log, which isn’t shared by any known NP-complete problem.

 (2) Grover’s algorithm is provably optimal for speeding up brute-force search. Thus, any attempt to do better would indeed need to exploit structure in an NP-complete problem.

 (3) There have by now been 25 years of attempts to find quantum algorithms that exploit the structure of NP-complete problems, including the adiabatic algorithm and QAOA. None of these have succeeded in beating the Grover speedup in the worst case.

 Together, this obviously doesn’t add up to a proof of NP⊄BQP—we don’t even have a proof of P≠NP!—but it makes clear that any quantum algorithm that even beat the Grover speedup for typical NP-complete problems, let alone solving them in polynomial time, would be a revolutionary advance.

 14. asdf Says:
 Comment #14 November 20th, 2021 at 12:53 pm

 but then I also don’t want to use this blog to privilege my own papers “unfairly.”

 That’s right! If Aaronson wants to publicize his papers, let him post about them on his own blog! Oh wait…

 More seriously, look at Terry Tao’s blog for example. He always announces his new papers there and I’m sure no one has a problem with it.

 15. HasH Says:
 Comment #15 November 20th, 2021 at 3:34 pm

 John Preskill #9: “I’m always interested in what Scott Aaronson is “tremendously excited” about, even if it does not involve students. I’m sure many other readers feel the same way.”

 Thank you Sir, I feel the same but I cannot express myself with my primitive English! *heart* and *hi5″ emojis.

 I read every post when Scott upload (checking almost everyday). Even I have no idea what is “Σk+1⊄BQPΣ_k” or “P=NP≠BQP=P#P” but I feel my intelligent point increase every post and comments I read

 Peace and Cheers from Overseas!

 16. Tim Converse Says:
 Comment #16 November 20th, 2021 at 11:31 pm

 Scott,

 I have a question that I’d like to ask – relevant to the computational content on your blog, but not relevant to this post or any other recent post. So – do you have any plans for an Ask Me Anything anytime soon? (I ask forgiveness for the fact that this very comment is itself a question that is relevant to your blog but not to this post. )

 17. Scott Says:
 Comment #17 November 20th, 2021 at 11:32 pm

 Tim Converse #16: I’ll consider doing one after the end of the semester.

 18. Lance Fortnow Says:
 Comment #18 November 21st, 2021 at 9:21 am

 Let me tell your readers why I’m excited by this work. It highlights a fundamental difference between quantum and probabilistic computing–that you can’t pull out the quantumness in a computation like you can for randomness.

 19. Scott Says:
 Comment #19 November 21st, 2021 at 11:02 am

 Thanks Lance!! Indeed, virtually every result in our paper codifies that intuition in one way or another.

 20. Matt Says:
 Comment #20 November 21st, 2021 at 5:24 pm

 Just go for it IMO, especially when you’re genuinely excited about the work. If you found yourself being artificially quiet (or negative) about other people’s papers because you saw them as competitors, that would be something to fight against. But a personal blog is a perfectly good place for enthusiastic promotion of whatever interests you, including stuff you have done or played a role in.

 21. matt Says:
 Comment #21 November 21st, 2021 at 7:33 pm

 Scott 13: when you say “any quantum algorithm that even beat the Grover speedup for typical NP-complete problems, let alone solving them in polynomial time, would be a revolutionary advance”, what is a “typical NP-complete problem”? Would random instances of high degree MAX-2-SAT count as typical? Or worst case instances, or what?

 22. Scott Says:
 Comment #22 November 21st, 2021 at 8:52 pm

 matt #21: What I had in mind there was, NP-complete problems like 3SAT or CircuitSAT or Clique or TSP, etc., rather than artificial monstrosities like

 “if the first bit of the input is 0, then factor the number encoded by the remaining n-1 bits; otherwise, solve 3SAT on the next n0.01 bits.”

 The above is indeed an NP-complete problem for which QCs can get more than the Grover speedup, but in a completely uninteresting way!

 I was still thinking about worst-case instances.

 Average-case NP-complete problems are a different beast. There, it would surprise me a lot less if it was possible to beat the Grover speedup for some natural input distributions, although I still haven’t seen a compelling case that the adiabatic algorithm, QAOA, or other such algorithms actually do so—have I missed something?

 23. matt Says:
 Comment #23 November 21st, 2021 at 9:26 pm

 Scott 22: assuming widely believed statistical physics “conjectures” on the entropy of low energy states in the Sherrington-Kirkpatrick model, the short-path algorithm provably achieves a (fairly small) polynomial speedup over Grover for the exact ground state.

 Actually I am not sure if these are conjectures or not. They might be rigorously proven.

 24. Scott Says:
 Comment #24 November 21st, 2021 at 10:14 pm

 matt #23: For Sherrington-Kirkpatrick, doesn’t Montanari’s algorithm also find a near-optimal solution in classical polynomial time, at least under some plausible conjecture? (I’m just going off what Ed Farhi said when he spoke in our group meeting recently.)

 In general, the relevant question is of course super-Grover improvement over the best known classical algorithm—many or even most natural NP-complete problems have nontrivial-but-still-exponential classical algorithms, and no one is shocked unless you beat that by more than a square root.

 If you’re telling me that the short-path algorithm gets a super-Grover improvement even in this strong sense, what’s a good reference?

 25. matt Says:
 Comment #25 November 21st, 2021 at 10:29 pm

 Montanari’s finds a near-optimal solution under a widely believed conjecture.
 Short-path is for the exact optimal solution, not a near optimal solution.
 https://arxiv.org/pdf/1802.10124.pdf

 I don’t know a classical algorithm that finds a strictly optimal solution in time 2^{cN} for c<1 for typical instances. But of course such an algorithm may exist…. And one obvious guess to find it is to think about the entropy of low energy solutions and somehow be able to explore a space of slightly smaller than maximal entropy by perhaps ruling out certain possible configurations (e.g., brute force loop over all assignments to 0.99N spins. On the remaining 0.01 spins, hope that this allows you to reduce the entropy enough to ignore many of the configurations). In which case, it would take a lot of thinking to figure out which is better.

 26. Scott Says:
 Comment #26 November 21st, 2021 at 11:35 pm

 matt #25: OK, thanks very much! I vaguely remembered your paper on the short path algorithm but hadn’t connected it to the Sherrington-Kirkpatrick model. By how much do you expect the algorithm beats Grover—is it more like 20.49n or 20.01n, or something else entirely? (Apologies; I looked through the paper and must have missed where you say.)

 27. Mitchell Porter Says:
 Comment #27 November 22nd, 2021 at 1:21 am

 Lance #18, Scott #19: So if this paper shows the difficulty of pinning down what’s quantum about BQP, perhaps it should be considered in conjunction with 2111.09079, which studies how to dequantize quantum-SVT, recently (2105.02859) proposed as the common ingredient of most known quantum algorithms?

 28. Scott Says:
 Comment #28 November 22nd, 2021 at 1:28 am

 Mitchell Porter #27: If anything, the situation is the opposite—our paper shows that, in the black-box setting, you really can “pin down what’s quantum about BQP,” demonstrating a bunch of dramatic differences between it and BPP basically by leveraging BQP’s ability to solve the Forrelation problem.

 Yes, there’s also a lot of important work happening right now on the dequantization of “applied” (non-black-box) quantum algorithms, but that’s very different from what we do!

 29. matt Says:
 Comment #29 November 22nd, 2021 at 11:09 am

 Scott 26: It is a small improvement. Definitely not 2^{0.01 n}. The reference to S-K is written in the style of “it would be crazy given what we know about S-K if this didn’t give at least 2^{0.49n}”. But I made no real attempt to figure out what the actual power would be given our understanding of S-K. I would expect it is better than 2^{0.49 n} but I don’t remember. It’s been a while!

 30. Douglas Knight Says:
 Comment #30 November 22nd, 2021 at 2:35 pm

 Scott,
 Use the Harrison Bergeron heuristic for fairness: don’t cripple yourself. Maybe you should take positive actions to increase fairness, but failing to take action (eg, promoting papers on your blog) is probably just making the world worse.

 31. Timothy G Flynn Says:
 Comment #31 November 22nd, 2021 at 3:15 pm

 Scott:

 If C_1 and C_2 are complexity classes and R is a relation such as: = , \neq , \subseteq , \not\subseteq , etc, do we know of any triple C_1, C_2, R such that it can be proven that there does not exist an oracle A such that {C_1}^A R {C_2}^A .

 32. Scott Says:
 Comment #32 November 22nd, 2021 at 3:58 pm

 Timothy G Flynn #31: Absolutely, yes! Any inclusion or separation among complexity classes that’s proven in a relativizing way — and that means most of the ones we know — gives another example of what you’re asking for. To give just two examples out of hundreds, there are no oracles relative to which P=EXP (because of the Time Hierarchy Theorem), and there are no oracles relative to which PH⊄P#P (because of Toda’s Theorem, which also relativizes).

 33. Jonathan Thornburg Says:
 Comment #33 November 22nd, 2021 at 4:02 pm

 Scott: Yes, IMHO it is perfectly appropriate to use your blog to describe/announce/publicise/summarise your (and your students’) own papers (or any other papers that strike your fancy, for that matter).

 34. Dave Says:
 Comment #34 November 22nd, 2021 at 9:49 pm

 I second what everyone else said, but I must add that you should **really** delete your twitter account and quit reading that website. Really, you’ll live better and have more time to spend for your life, family and research, instead of worrying what the twitterverse thinks, which in any case is irrelevant. Same thing with Facebook and other social media you may use, perhaps (and just perhaps) with the exception of LinkedIn. It’s clearly grown into a massive, useless waste of time (at least with ole fashioned TV the waste of time brought some solace, education or relaxation….)

 You have this blog for some public interaction, an email address for private communication, and these suffice.

 It goes without saying that I’ve done exactly that myself.

 35. Scott Says:
 Comment #35 November 22nd, 2021 at 10:09 pm

 Dave #34: Thanks! Just to clarify, though, I don’t have and have never had a Twitter account—it reminds me too much of being in high school, and I do indeed feel like email, Facebook, and this blog are more than enough for me. The trouble is that, if people are talking about me on some public platform, then even if I don’t have an account there, I can’t help but look. Even if I know it will just depress me while providing zero useful new insight. It’s like picking at scabs, which I also do.

 The one big bright spot is that, having survived a thermonuclear online denunciation campaign 7 years ago, I can always say to myself, “oh, this isn’t nearly as bad as that was,” and immediately feel better.

 36. ABCDEFG Says:
 Comment #36 November 23rd, 2021 at 9:27 am

 Where can I buy one of the black boxes? Oracle?

 37. Scott Says:
 Comment #37 November 23rd, 2021 at 9:56 am

 ABCDEFG #36: Querying Oracle first is a … relatively good idea, but you might need to adapt based on the query outcome.

 38. arch1 Says:
 Comment #38 November 23rd, 2021 at 11:43 am

 “…when I’ve worked on a project with students, I’m often tremendously excited and want to shout about it from the rooftops for the students’ sake … but then I also don’t want to use this blog to privilege my own papers ‘unfairly.'”

 I suspect you may be overthinking this in the context of a personal blog, but if you’re not convinced by this or the other comments in that direction, you might just ask yourself whether your rooftop-shouting is any louder than it would have been if the project had been done by the student(s) independently of you. If it wouldn’t (and in your case I suspect it rarely would), and your thought experiment is reasonably unbiased, then you *can’t* be privileging your own papers unfairly.

 39. Curious Says:
 Comment #39 November 24th, 2021 at 2:21 am

 “This result shows that there is no black-box quantum analogue of Stockmeyer’s approximate counting algorithm.”

 Why?

 Also on “By contrast, if NP⊆BPP, then PH collapses relative to all oracles.”.

 PH is known to be infinite wrt to a random oracle. So contrapositive means something unknown on np vs bpp. I am confused.

 Please explain both.

 40. Scott Says:
 Comment #40 November 24th, 2021 at 3:00 am

 Curious #39: How about if I just paste the passage from our paper that directly answers your first question?

 We mention another interesting interpretation of Theorem 7: it can be understood as showing that in the black box setting, there is no quantum analogue of Stockmeyer’s approximate countingalgorithm [Sto83]. For a probabilistic machine M that runs in poly(n) time and an error bound ε ≥ 1 , the approximate counting problem is to estimate the acceptance probability of M up to a multiplicative factor of 1 + ε. Stockmeyer’s algorithm [Sto83] gives a poly(n)-time reduction from the approximate counting problem to a problem in the third level of the polynomial hierarchy, and moreover, this reduction relativizes.
 One might wonder: is there a version of Stockmeyer’s algorithm for the quantum approximate counting problem, where we instead wish to approximate the acceptance probability of a quantum algorithm? By well-known reductions involving Aaronson’s postselection theorem [Aar05], all problems in PP = PostBQP efficiently reduce to the quantum approximate counting problem (see e.g. [Kup15, Proposition 2.14]). Hence, Theorem 7 implies that the quantum approximate counting problem cannot reduce efficiently to the QMA hierarchy in a black box manner, giving some sense in which a quantum analogue of Stockmeyer’s algorithm is impossible.

 As for your second question, the meaning of the sentence is that every oracle that causes NP⊆BPP, also causes PH to collapse. A random oracle causes neither to happen, and therefore is consistent with what I just said.

 41. Sniffnoy Says:
 Comment #41 November 24th, 2021 at 2:36 pm

 Curious #39, Scott #40:

 I think there’s an issue of parenthesization here. The statement “If NP⊆BPP, then PH collapses relative to all oracles” can be read as “(If NP⊆BPP, then PH collapses) relative to all oracles” or as “If NP⊆BPP, then (PH collapses relative to all oracles)”. It looks like Scott intended the first meaning and Curious read it as the second.

 42. Scott Says:
 Comment #42 November 24th, 2021 at 3:20 pm

 Sniffnoy #41: Ah, thanks! This is one of those cases where the intended interpretation was so obvious to me that I didn’t even notice the other one.

 43. Curious Says:
 Comment #43 November 24th, 2021 at 4:12 pm

 There is no quantum stockemeyer because “By well-known reductions involving Aaronson’s postselection theorem [Aar05], all problems in PP = PostBQP efficiently reduce to the quantum approximate counting problem (see e.g. [Kup15, Proposition 2.14]). Hence, Theorem 7 implies that the quantum approximate counting problem cannot reduce efficiently to the QMA hierarchy in a black box manner, giving some sense in which a quantum analogue of Stockmeyer’s algorithm is impossible.”

 .. or in easy to read English for beginners “.. else PP is in QMA hierarchy?”.

 44. Scott Says:
 Comment #44 November 24th, 2021 at 5:22 pm

 Curious #43: Classical Stockmeyer says that PostBPP (or, multiplicatively approximating the acceptance probability of a classical algorithm) is easy if NP is easy. So wouldn’t a natural quantum Stockmeyer say that PostBQP (or, multiplicatively approximating the acceptance probability of a quantum algorithm) is easy if QMA is easy? That’s exactly what we rule out in the black-box setting. Should we have worded it differently to be clearer?

 45. Curious Says:
 Comment #45 November 24th, 2021 at 6:06 pm

 Yes simple direct English is traditionally better to read for a non quantum researcher.

 46. Taymon A. Beal Says:
 Comment #46 November 27th, 2021 at 11:21 pm

 Scott, have you said anything about what you personally believe about the third fundamental question from the introduction (“What is the best classical upper bound on the power of quantum computation?”)? Your 2009 paper “presents evidence” that it’s higher than PH, but do you actually believe that’s the case? If so, do you think it tops out at AWPP (the smallest class I could find that’s been proven to contain BQP), or might there be some smaller interesting classical class that contains it?

 Apologies if this was in QCSD or an earlier blog post and I missed it.

 47. Scott Says:
 Comment #47 November 28th, 2021 at 8:17 am

 Taymon A. Beal #46: I strongly believe that there are search, sampling, and promise problems that are solvable in quantum polynomial time but are not in the polynomial hierarchy (good candidates being BosonSampling or dozens of other tasks involving quantum simulation). Many outsiders don’t even realize that that’s different from BQP⊄PH, which refers strictly to languages (ie total decision problems). The latter is a much harder question—if forced to bet, I’d bet on BQP⊄PH, but we still don’t have a single good candidate language for the separation and I’m very open to the possibility that it goes the other way.

 48. OhMyGoodness Says:
 Comment #48 November 28th, 2021 at 10:18 am

 Your students are just very fortunate to have an enthusiastic supportive mentor with a widely read blog, you. If you didn’t have results of your own then they wouldn’t benefit from a widely read blog.

 49. matt Says:
 Comment #49 November 28th, 2021 at 9:21 pm

 Scott 47: what does it mean when you say that you conjecture that some sampling problems are not in the polynomial hierarchy? I thought that PH is a class of decision problems (exactly the point you were making in that comment, I thought!), so by definition sampling problems aren’t in there. Do you mean that you conjecture that some sampling problems cannot be solved by a classical poly time algorithm with an oracle for PH? Or something else?

 50. Scott Says:
 Comment #50 November 28th, 2021 at 10:05 pm

 matt #49: Yes, that’s exactly what I meant. Define SampPH = SampBPPPH; then even if exact BosonSampling was only in SampPH rather than SampBPP, my paper with Arkhipov showed that PH would still collapse.

 Leave a Reply

 You can use rich HTML in comments! You can also use basic TeX, by enclosing it within $$ $$ for displayed equations or \( \) for inline equations.

 Comment Policies:

 1. All comments are placed in moderation and reviewed prior to appearing.
 2. You'll also be sent a verification email to the email address you provided.
 YOU MUST CLICK THE LINK IN YOUR VERIFICATION EMAIL BEFORE YOUR COMMENT CAN APPEAR. WHY IS THIS BOLD, UNDERLINED, ALL-CAPS, AND IN RED? BECAUSE PEOPLE ARE STILL FORGETTING TO DO IT.
 3. This comment section is not a free speech zone. It's my, Scott Aaronson's, virtual living room. Commenters are expected not to say anything they wouldn't say in my actual living room. This means: No trolling. No ad-hominems against me or others. No presumptuous requests (e.g. to respond to a long paper or article). No conspiracy theories. No patronizing me. Comments violating these policies may be left in moderation with no explanation or apology.
 4. Whenever I'm in doubt, I'll forward comments to Shtetl-Optimized Committee of Guardians, and respect SOCG's judgments on whether those comments should appear.
 5. I sometimes accidentally miss perfectly reasonable comments in the moderation queue, or they get caught in the spam filter. If you feel this may have been the case with your comment, shoot me an email.

 Name (required)

 Mail (will not be published) (required)

 Website

 Δ

 Shtetl-Optimized is proudly powered by WordPress
 Entries (RSS) and Comments (RSS).

Just in case anyone is depressed this afternoon and needs something to cheer them up, students William Kretschmer, DeVon Ingram, and I have finally put out a new paper:
   The Acrobatics of BQP    Abstract: We show that, in the black-box setting, the behavior of quantum polynomial-time (BQP) can be remarkably decoupled from that of classical complexity classes like NP. Specifically: – There exists an oracle relative to which NPBQP⊄BQPPH, resolving a 2005 problem of Fortnow. Interpreted another way, we show that AC0 circuits cannot perform useful homomorphic encryption on instances of the Forrelation problem. As a corollary, there exists an oracle relative to which P=NP but BQP≠QCMA. – Conversely, there exists an oracle relative to which BQPNP⊄PHBQP. – Relative to a random oracle, PP=PostBQP is not contained in the “QMA hierarchy” QMAQMA^QMA^…, and more generally PP⊄(MIP*)(MIP*)^(MIP*)^… (!), despite the fact that MIP*=RE in the unrelativized world. This result shows that there is no black-box quantum analogue of Stockmeyer’s approximate counting algorithm. – Relative to a random oracle, Σk+1⊄BQPΣ_k for every k. – There exists an oracle relative to which BQP=P#P and yet PH is infinite. (By contrast, if NP⊆BPP, then PH collapses relative to all oracles.) – There exists an oracle relative to which P=NP≠BQP=P#P. To achieve these results, we build on the 2018 achievement by Raz and Tal of an oracle relative to which BQP⊄PH, and associated results about the Forrelation problem. We also introduce new tools that might be of independent interest. These include a “quantum-aware” version of the random restriction method, a concentration theorem for the block sensitivity of AC0 circuits, and a (provable) analogue of the Aaronson-Ambainis Conjecture for sparse oracles. 
Incidentally, particularly when I’ve worked on a project with students, I’m often tremendously excited and want to shout about it from the rooftops for the students’ sake … but then I also don’t want to use this blog to privilege my own papers “unfairly.” Can anyone suggest a principle that I should follow going forward?
	This entry was posted
	on Friday, November 19th, 2021 at 3:48 pm	and is filed under Complexity, Quantum.
	You can follow any responses to this entry through the RSS 2.0 feed.
	You can leave a response, or trackback from your own site.
	
 You can use rich HTML in comments! You can also use basic TeX, by enclosing it within for displayed equations or for inline equations.
The Acrobatics of BQP
https://scottaaronson.blog/?p=6129
https://scottaaronson.blog/?p=5868
Gaussian BosonSampling, higher-order correlations, and spoofing: An update
2021-10-10
None
<div><div>
	
<p>In my <a href="https://scottaaronson.blog/?p=5859">last post</a>, I wrote (among other things) about an ongoing scientific debate between the group of Chaoyang Lu at USTC in China, which over the past year has been doing experiments that seek to demonstrate quantum supremacy via Gaussian BosonSampling; and the group of Sergio Boixo at Google, which had a <a href="https://arxiv.org/abs/2109.11525">recent paper</a> on a polynomial-time classical algorithm to sample approximately from the same distributions.  I reported the facts as I understood them at the time.  Since then, though, a long call with the Google team gave me a new and different understanding, and I feel duty-bound to share that here.</p>
<p>A week ago, I considered it obvious that if, using a classical spoofer, you could beat the USTC experiment on a metric like total variation distance from the ideal distribution, then you would’ve completely destroyed USTC’s claim of quantum supremacy.  The reason I believed <em>that</em>, in turn, is a proposition that I hadn’t given a name but needs one, so let me call it <strong>Hypothesis H</strong>:</p>
<blockquote><p>The only way a classical algorithm to spoof BosonSampling can possibly do well in total variation distance, is by correctly reproducing the high-order correlations (correlations among the occupation numbers of large numbers of modes) — because that’s where the complexity of BosonSampling lies (if it lies anywhere).</p></blockquote>
<p>Hypothesis H had important downstream consequences.  Google’s algorithm, by the Google team’s own admission, does not reproduce the high-order correlations.  Furthermore, because of limitations on both samples and classical computation time, Google’s paper calculates the total variation distance from the ideal distribution only on the marginal distribution on roughly 14 out of 144 modes.  On that marginal distribution, Google’s algorithm does do better than the experiment in total variation distance.  Google presents a claimed extrapolation to the full 144 modes, but eyeballing the graphs, it was far from clear to me what would happen: like, maybe the spoofing algorithm would continue to win, but maybe the experiment would turn around and win; who knows?</p>
<p>Chaoyang, meanwhile, made a clear prediction that the experiment would turn around and win, because of</p>
<ol><li>the experiment’s success in reproducing the high-order correlations,</li><li>the admitted failure of Google’s algorithm in reproducing the high-order correlations, and</li><li>the seeming impossibility of doing well on BosonSampling <em>without</em> reproducing the high-order correlations (Hypothesis H).</li></ol>
<p>Given everything my experience told me about the central importance of high-order correlations for BosonSampling, I was inclined to agree with Chaoyang.</p>
<p>Now for the kicker: it seems that Hypothesis H is false.  A classical spoofer could beat a BosonSampling experiment on total variation distance from the ideal distribution, without even bothering to reproduce the high-order correlations correctly.</p>
<p>This is true because of a combination of two facts about the existing noisy BosonSampling experiments.  The first fact is that the contribution from the order-k correlations falls off like 1/exp(k).  The second fact is that, due to calibration errors and the like, the experiments already show significant deviations from the ideal distribution on the order-1 and order-2 correlations.</p>
<p>Put these facts together and what do you find?  Well, suppose your classical spoofing algorithm takes care to get the low-order contributions to the distribution exactly right.  Just for that reason alone, it could already win over a noisy BosonSampling experiment, as judged by benchmarks like total variation distance from the ideal distribution, or for that matter linear cross-entropy.  Yes, the experiment will beat the classical simulation on the higher-order correlations.  But because those higher-order correlations are exponentially attenuated anyway, they won’t be enough to make up the difference.  The experiment’s lack of perfection on the low-order correlations will swamp everything else.</p>
<p>Granted, I still don’t know for sure that this <em>is</em> what happens — that depends on whether I believe Sergio or Chaoyang about the extrapolation of the variation distance to the full 144 modes (my own eyeballs having failed to render a verdict!).  But I now see that it’s logically possible, maybe even plausible.</p>
<p>So, let’s imagine for the sake of argument that Google’s simulation wins on variation distance, even though the experiment wins on the high-order correlations.  In that case, what would be our verdict: would USTC have achieved quantum supremacy via BosonSampling, or not?</p>
<p>It’s clear what each side could say.</p>
<p>Google could say: by a metric that Scott Aaronson, the coinventor of BosonSampling, thought was perfectly adequate as late as last week — namely, total variation distance from the ideal distribution — we won.  We achieved lower variation distance than USTC’s experiment, and we did it using a fast classical algorithm.  End of discussion.  No moving the goalposts after the fact.</p>
<p>Google could even add: BosonSampling is a <em>sampling</em> task; it’s right there in the name!  The only purpose of any benchmark — whether Linear XEB or high-order correlation — is to give evidence about whether you are or aren’t sampling from a distribution close to the ideal one.  But that means that, if you accept that we <em>are</em> doing the latter better than the experiment, then there’s nothing more to argue about.</p>
<p>USTC could respond: even if Scott Aaronson <em>is</em> the coinventor of BosonSampling, he’s extremely far from an infallible oracle.  In the case at hand, his lack of appreciation for the sources of error in realistic experiments caused him to fixate inappropriately on variation distance as the success criterion.  If you want to see the quantum advantage in our system, you have to deliberately subtract off the low-order correlations and look at the high-order correlations.</p>
<p>USTC could add: from the very beginning, the whole point of quantum supremacy experiments was to demonstrate a clear speedup on <em>some</em> benchmark — we never particularly cared which one!  That horse is out of the barn as soon as we’re talking about quantum supremacy at all — something the Google group, which itself reported the first quantum supremacy experiment in Fall 2019, again for a completely artificial benchmark — knows as well as anyone else.  (The Google team even has experience with adjusting benchmarks: when, for example, <a href="https://arxiv.org/abs/2103.03074">Pan and Zhang</a> pointed out that Linear XEB as originally specified is pretty easy to spoof for random 2D circuits, the most cogent rejoinder was: OK, fine then, add an extra check that the returned samples are sufficiently different from one another, which kills Pan and Zhang’s spoofing strategy.) In that case, then, why isn’t a benchmark tailored to the high-order correlations as good as variation distance or linear cross-entropy or any other benchmark?</p>
<p>Both positions are reasonable and have merit — though I confess to somewhat greater sympathy for the one that appeals to my doofosity rather than my supposed infallibility!</p>
<p>OK, but suppose, again for the sake of argument, that we accepted the second position, and we said that USTC gets to declare quantum supremacy as long as its experiment does better than any known classical simulation at reproducing the high-order correlations.  We’d still face the question: does the USTC experiment, in fact, do better on that metric?  It would be awkward if, having won the right to change the rules in its favor, USTC still lost even under the new rules.</p>
<p>Sergio tells me that USTC directly reported experimental data only for up to order-7 correlations, and at least individually, the order-7 correlations are easy to reproduce on a laptop (although <em>sampling</em> in a way that reproduces the order-7 correlations might still be hard—a point that Chaoyang confirms, and where further research would be great). OK, but USTC also reported that their experiment seems to reproduce up to order-19 correlations. And order-19 correlations, the Google team agrees, are hard to sample consistently with on a classical computer by any currently known algorithm.</p>
<p>So then, why don’t we have direct data for the order-19 correlations?  The trouble is simply that it would’ve taken USTC an astronomical amount of computation time.  So instead, they relied on a statistical extrapolation from the observed strength of the lower-order correlations — there we go again with the extrapolations!  Of course, if we’re going to let Google rest its case on an extrapolation, then maybe it’s only sporting to let USTC do the same.</p>
<p>You might wonder: why didn’t we have to worry about any of this stuff with the <em>other</em> path to quantum supremacy, the one via random circuit sampling with superconducting qubits?  The reason is that, with random circuit sampling, all the correlations except the highest-order ones are completely trivial — or, to say it another way, the reduced state of any small number of output qubits is exponentially close to the maximally mixed state.  This is a real difference between BosonSampling and random circuit sampling—and even 5-6 years ago, we knew that this represented an advantage for random circuit sampling, although I now have a deeper appreciation for just how great of an advantage it is.  For it means that, with random circuit sampling, it’s easier to place a “sword in the stone”: to say, for example, <em>here</em> is the Linear XEB score achieved by the trivial classical algorithm that outputs random bits, and lo, our experiment achieves a higher score, and lo, we challenge anyone to invent a fast classical spoofing method that achieves a similarly high score.</p>
<p>With BosonSampling, by contrast, we have various metrics with which to judge performance, but so far, for none of those metrics do we have a plausible hypothesis that says “<em>here’s</em> the best that any polynomial-time classical algorithm can possibly hope to do, and it’s completely plausible that even a noisy current or planned BosonSampling experiment can do better than that.”</p>
<p>In the end, then, I come back to the exact same three goals I would’ve recommended a week ago for the future of quantum supremacy experiments, but with all of them now even more acutely important than before:</p>
<ol><li>Experimentally, to increase the fidelity of the devices (with BosonSampling, for example, to observe a larger contribution from the high-order correlations) — a much more urgent goal, from the standpoint of evading classical spoofing algorithms, than further increasing the dimensionality of the Hilbert space.</li><li>Theoretically, to design better ways to verify the results of sampling-based quantum supremacy experiments classically — ideally, even ways that could be applied via polynomial-time tests.</li><li>For Gaussian BosonSampling in particular, to get a better understanding of the plausible limits of classical spoofing algorithms, and exactly how good a noisy device needs to be before it exceeds those limits.</li></ol>
<p>Thanks so much to Sergio Boixo and Ben Villalonga for the conversation, and to Chaoyang Lu and Jelmer Renema for comments on this post. Needless to say, any remaining errors are my own.</p>
	<p>
	<small>
	This entry was posted
	on Sunday, October 10th, 2021 at 1:13 pm	and is filed under <a href="https://scottaaronson.blog/?cat=5">Complexity</a>, <a href="https://scottaaronson.blog/?cat=18">Embarrassing Myself</a>, <a href="https://scottaaronson.blog/?cat=4">Quantum</a>.
	You can follow any responses to this entry through the <a href="https://scottaaronson.blog/?feed=rss2&amp;p=5868">RSS 2.0</a> feed.
	You can <a href="#respond">leave a response</a>, or <a href="https://scottaaronson.blog/wp-trackback.php?p=5868">trackback</a> from your own site.
	</small>
	</p>
	</div><p>You can use rich HTML in comments! You can also use basic TeX, by enclosing it within $$ $$ for displayed equations or \( \) for inline equations.</p>||||I|||| Shtetl-Optimized

 The Blog of Scott Aaronson
 If you take nothing else from this blog: quantum computers won't
 solve hard problems instantly by just trying all solutions in parallel.

 Also, next pandemic, let's approve the vaccines faster!
 « The Physics Nobel, Gaussian BosonSampling, and Dorian Abbot
 Welcome to scottaaronson.blog ! »

 Gaussian BosonSampling, higher-order correlations, and spoofing: An update

 In my last post, I wrote (among other things) about an ongoing scientific debate between the group of Chaoyang Lu at USTC in China, which over the past year has been doing experiments that seek to demonstrate quantum supremacy via Gaussian BosonSampling; and the group of Sergio Boixo at Google, which had a recent paper on a polynomial-time classical algorithm to sample approximately from the same distributions. I reported the facts as I understood them at the time. Since then, though, a long call with the Google team gave me a new and different understanding, and I feel duty-bound to share that here.

 A week ago, I considered it obvious that if, using a classical spoofer, you could beat the USTC experiment on a metric like total variation distance from the ideal distribution, then you would’ve completely destroyed USTC’s claim of quantum supremacy. The reason I believed that, in turn, is a proposition that I hadn’t given a name but needs one, so let me call it Hypothesis H:

 The only way a classical algorithm to spoof BosonSampling can possibly do well in total variation distance, is by correctly reproducing the high-order correlations (correlations among the occupation numbers of large numbers of modes) — because that’s where the complexity of BosonSampling lies (if it lies anywhere).

 Hypothesis H had important downstream consequences. Google’s algorithm, by the Google team’s own admission, does not reproduce the high-order correlations. Furthermore, because of limitations on both samples and classical computation time, Google’s paper calculates the total variation distance from the ideal distribution only on the marginal distribution on roughly 14 out of 144 modes. On that marginal distribution, Google’s algorithm does do better than the experiment in total variation distance. Google presents a claimed extrapolation to the full 144 modes, but eyeballing the graphs, it was far from clear to me what would happen: like, maybe the spoofing algorithm would continue to win, but maybe the experiment would turn around and win; who knows?

 Chaoyang, meanwhile, made a clear prediction that the experiment would turn around and win, because of

 1. the experiment’s success in reproducing the high-order correlations,
 2. the admitted failure of Google’s algorithm in reproducing the high-order correlations, and
 3. the seeming impossibility of doing well on BosonSampling without reproducing the high-order correlations (Hypothesis H).

 Given everything my experience told me about the central importance of high-order correlations for BosonSampling, I was inclined to agree with Chaoyang.

 Now for the kicker: it seems that Hypothesis H is false. A classical spoofer could beat a BosonSampling experiment on total variation distance from the ideal distribution, without even bothering to reproduce the high-order correlations correctly.

 This is true because of a combination of two facts about the existing noisy BosonSampling experiments. The first fact is that the contribution from the order-k correlations falls off like 1/exp(k). The second fact is that, due to calibration errors and the like, the experiments already show significant deviations from the ideal distribution on the order-1 and order-2 correlations.

 Put these facts together and what do you find? Well, suppose your classical spoofing algorithm takes care to get the low-order contributions to the distribution exactly right. Just for that reason alone, it could already win over a noisy BosonSampling experiment, as judged by benchmarks like total variation distance from the ideal distribution, or for that matter linear cross-entropy. Yes, the experiment will beat the classical simulation on the higher-order correlations. But because those higher-order correlations are exponentially attenuated anyway, they won’t be enough to make up the difference. The experiment’s lack of perfection on the low-order correlations will swamp everything else.

 Granted, I still don’t know for sure that this is what happens — that depends on whether I believe Sergio or Chaoyang about the extrapolation of the variation distance to the full 144 modes (my own eyeballs having failed to render a verdict!). But I now see that it’s logically possible, maybe even plausible.

 So, let’s imagine for the sake of argument that Google’s simulation wins on variation distance, even though the experiment wins on the high-order correlations. In that case, what would be our verdict: would USTC have achieved quantum supremacy via BosonSampling, or not?

 It’s clear what each side could say.

 Google could say: by a metric that Scott Aaronson, the coinventor of BosonSampling, thought was perfectly adequate as late as last week — namely, total variation distance from the ideal distribution — we won. We achieved lower variation distance than USTC’s experiment, and we did it using a fast classical algorithm. End of discussion. No moving the goalposts after the fact.

 Google could even add: BosonSampling is a sampling task; it’s right there in the name! The only purpose of any benchmark — whether Linear XEB or high-order correlation — is to give evidence about whether you are or aren’t sampling from a distribution close to the ideal one. But that means that, if you accept that we are doing the latter better than the experiment, then there’s nothing more to argue about.

 USTC could respond: even if Scott Aaronson is the coinventor of BosonSampling, he’s extremely far from an infallible oracle. In the case at hand, his lack of appreciation for the sources of error in realistic experiments caused him to fixate inappropriately on variation distance as the success criterion. If you want to see the quantum advantage in our system, you have to deliberately subtract off the low-order correlations and look at the high-order correlations.

 USTC could add: from the very beginning, the whole point of quantum supremacy experiments was to demonstrate a clear speedup on some benchmark — we never particularly cared which one! That horse is out of the barn as soon as we’re talking about quantum supremacy at all — something the Google group, which itself reported the first quantum supremacy experiment in Fall 2019, again for a completely artificial benchmark — knows as well as anyone else. (The Google team even has experience with adjusting benchmarks: when, for example, Pan and Zhang pointed out that Linear XEB as originally specified is pretty easy to spoof for random 2D circuits, the most cogent rejoinder was: OK, fine then, add an extra check that the returned samples are sufficiently different from one another, which kills Pan and Zhang’s spoofing strategy.) In that case, then, why isn’t a benchmark tailored to the high-order correlations as good as variation distance or linear cross-entropy or any other benchmark?

 Both positions are reasonable and have merit — though I confess to somewhat greater sympathy for the one that appeals to my doofosity rather than my supposed infallibility!

 OK, but suppose, again for the sake of argument, that we accepted the second position, and we said that USTC gets to declare quantum supremacy as long as its experiment does better than any known classical simulation at reproducing the high-order correlations. We’d still face the question: does the USTC experiment, in fact, do better on that metric? It would be awkward if, having won the right to change the rules in its favor, USTC still lost even under the new rules.

 Sergio tells me that USTC directly reported experimental data only for up to order-7 correlations, and at least individually, the order-7 correlations are easy to reproduce on a laptop (although sampling in a way that reproduces the order-7 correlations might still be hard—a point that Chaoyang confirms, and where further research would be great). OK, but USTC also reported that their experiment seems to reproduce up to order-19 correlations. And order-19 correlations, the Google team agrees, are hard to sample consistently with on a classical computer by any currently known algorithm.

 So then, why don’t we have direct data for the order-19 correlations? The trouble is simply that it would’ve taken USTC an astronomical amount of computation time. So instead, they relied on a statistical extrapolation from the observed strength of the lower-order correlations — there we go again with the extrapolations! Of course, if we’re going to let Google rest its case on an extrapolation, then maybe it’s only sporting to let USTC do the same.

 You might wonder: why didn’t we have to worry about any of this stuff with the other path to quantum supremacy, the one via random circuit sampling with superconducting qubits? The reason is that, with random circuit sampling, all the correlations except the highest-order ones are completely trivial — or, to say it another way, the reduced state of any small number of output qubits is exponentially close to the maximally mixed state. This is a real difference between BosonSampling and random circuit sampling—and even 5-6 years ago, we knew that this represented an advantage for random circuit sampling, although I now have a deeper appreciation for just how great of an advantage it is. For it means that, with random circuit sampling, it’s easier to place a “sword in the stone”: to say, for example, here is the Linear XEB score achieved by the trivial classical algorithm that outputs random bits, and lo, our experiment achieves a higher score, and lo, we challenge anyone to invent a fast classical spoofing method that achieves a similarly high score.

 With BosonSampling, by contrast, we have various metrics with which to judge performance, but so far, for none of those metrics do we have a plausible hypothesis that says “here’s the best that any polynomial-time classical algorithm can possibly hope to do, and it’s completely plausible that even a noisy current or planned BosonSampling experiment can do better than that.”

 In the end, then, I come back to the exact same three goals I would’ve recommended a week ago for the future of quantum supremacy experiments, but with all of them now even more acutely important than before:

 1. Experimentally, to increase the fidelity of the devices (with BosonSampling, for example, to observe a larger contribution from the high-order correlations) — a much more urgent goal, from the standpoint of evading classical spoofing algorithms, than further increasing the dimensionality of the Hilbert space.
 2. Theoretically, to design better ways to verify the results of sampling-based quantum supremacy experiments classically — ideally, even ways that could be applied via polynomial-time tests.
 3. For Gaussian BosonSampling in particular, to get a better understanding of the plausible limits of classical spoofing algorithms, and exactly how good a noisy device needs to be before it exceeds those limits.

 Thanks so much to Sergio Boixo and Ben Villalonga for the conversation, and to Chaoyang Lu and Jelmer Renema for comments on this post. Needless to say, any remaining errors are my own.

 Follow

 This entry was posted on Sunday, October 10th, 2021 at 1:13 pm and is filed under Complexity, Embarrassing Myself, Quantum. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

 29 Responses to “Gaussian BosonSampling, higher-order correlations, and spoofing: An update”

 1. Doug S. Says:
 Comment #1 October 10th, 2021 at 2:17 pm

 It would be ironic if it turns out that BPP = BQP after all.

 2. Scott Says:
 Comment #2 October 10th, 2021 at 2:49 pm

 Doug S. #1: I confess, your comment reminded me of Feynman’s parable about the people who spend their entire lives trying to break a particular combination lock, very gradually learning more and more of its secrets, whereupon some amateur walks up to them and asks, in a helpful tone of voice, “did you try 1-2-3-4-5 yet?” 😀

 3. RD Says:
 Comment #3 October 11th, 2021 at 6:24 am

 “The Google team even has experience with adjusting benchmarks”… More than once, i.e. not just with the example you gave. They had a different benchmark in their first paper too, and they basically invented the notion / name “Linear Cross Entropy” in the successor paper (see how many search hits that ten gets that are not originating from their paper).

 4. asdf Says:
 Comment #4 October 11th, 2021 at 6:28 am

 Scott #2, that actually happened, in the cryptanalysis of the Enigma. I am probably garbling this a little but the basic story was like this. The commercial version of Enigma had a QWERTY keyboard, so British cryptanalyists figured the military one was wired the same way, but that didn’t work. They figured out that the keys must have been permuted somehow: ok, there were known alternate setups like AZERTY, etc. None of those worked either: it must be a secret permutation. Lots more work went into figuring it out, still to no avail. Then they were informed that Polish cryptographers had completely solved the thing. They met with the Poles and one of their first questions was “what was the keyboard ordering and how did you figure it out?”. The answer was “QWERTY didn’t work, so we guessed ABCDEF… and that turned out to be the right ordering.”

 5. fred Says:
 Comment #5 October 11th, 2021 at 8:44 am

 I’ve always said that that QC research should be cranking up the number of imperfect qubits only as a goal to create perfect qubits, no matter how few, and not to create some noisy quantum soup where everyone’s getting bogged down wasting time arguing over tenuous correlations.

 6. Nick Drozd Says:
 Comment #6 October 11th, 2021 at 9:25 am

 You changed your mind? Jeez what are you, some kind of flip-flopper?

 7. Scott Says:
 Comment #7 October 11th, 2021 at 10:10 am

 asdf #4: LOL, I hadn’t heard that story! Do you (or anyone else) have a reference?

 8. Scott Says:
 Comment #8 October 11th, 2021 at 10:11 am

 fred #5: Most serious people in the field have been saying that too! But perfect qubits are hard.

 9. Scott Says:
 Comment #9 October 11th, 2021 at 10:15 am

 Nick Drozd #6: It’s funny, I feel like my moral and political views have barely changed since I was a teenager in the 90s, even while half the world around me became woke and the other half became right-wing authoritarian. Meanwhile, I feel like my views about the current quantum supremacy experiments radically change from one week to the next, even while many other people’s views (whatever they happen to be) stay the same. 🙂

 10. fred Says:
 Comment #10 October 11th, 2021 at 10:54 am

 asdf #4

 interesting, and I didn’t know that Germany was actually using QWERTZ rather than QWERTY.

 https://upload.wikimedia.org/wikipedia/commons/b/bd/Enigma_(crittografia)_-_Museo_scienza_e_tecnologia_Milano.jpg

 https://en.wikipedia.org/wiki/QWERTZ#/media/File:Latin_keyboard_layouts_by_country_in_Europe_map.PNG

 11. Mark Says:
 Comment #11 October 11th, 2021 at 12:57 pm

 Scott #7

 I read that same story in ”The Code Book” by Simon Singh I think.

 12. Chris J. Says:
 Comment #12 October 11th, 2021 at 1:48 pm

 I have a vague, partially formed question about quantum supremacy and classical spoofing that may be more on the philosophical side, or at least on the interpretation side. If a given quantum experiment is shown repeatedly to be classically spoofable, does it seem more likely that the experiment is (1) in fact carrying out a classical algorithm “under the hood” (perhaps unbeknownst to the experimenters and/or obscured by the experimental setup and physical effects), or (2) carrying out a quantum implementation of a much less efficient algorithm, but then cancelling out and yielding similar performance in the end? Or does this question not make any sense? Does it make sense to talk about what “algorithm” a physical system is using “under the hood”?

 13. asdf Says:
 Comment #13 October 11th, 2021 at 2:31 pm

 Scott #7, it’s in various WW2 cryptography history books. I just looked in Stephen Budiansky’s “Battle of Wits” (2002) because I have a copy handy, but it’s probably also in Wladislaw Kozaczuk’s “Enigma” which I don’t have but which is afaict still the best book on the topic, or in F. W. Winterbotham’s “The Ultra Secret”. In Budiansky’s book it is in chapter 3, pp. 94-95.

 The British cryptographer involved was Dilwyn Knox, who had many triumphs despite missing that particular trick. If you look for him in the index of some other book, you can probably find the incident. It was very famous. I did get some details wrong but the general outline was accurate.

 14. asdf Says:
 Comment #14 October 11th, 2021 at 2:36 pm

 Fwiw, there was a similar story in “Surely You’re Joking, Mr. Feynman”. Feynman was into safecracking at Los Alamos, and (again in my garbled recollection from the book) he was working away at one particular safe when one of his buddies came along and opened it almost instantly. Feynman asked how the buddy opened it so fast. The buddy replied “oh, I just tried 10-20-30, which is what they set the combination to at the factory. Looks like the safe owner didn’t bother changing it”. Feynman went around trying that combination on other safes and quite a lot of them opened with it. Heh.

 15. Scott Says:
 Comment #15 October 11th, 2021 at 4:02 pm

 asdf #14: I guess that’s where Feynman learned that example then! But his point, I think in The Character of Physical Law, was about just how unlikely it is, in the case of physics research, that the person saying “have you tried 1-2-3-4-5?” is going to be telling the experts something they didn’t already think of.

 16. Scott Says:
 Comment #16 October 11th, 2021 at 4:08 pm

 Chris J. #12: Yes, that’s an extremely natural thing to wonder, although as you’ve already recognized yourself, it’s hard to know how to answer it as stated. Maybe the most useful thing I can say is that some algorithms—like maybe the Gottesman-Knill algorithm for simulating stabilizer circuits—seem wildly unlike any plausible model for what “Nature herself could be doing” (whatever that means), for example because they don’t generalize to even slightly different cases. But other algorithms, like quantum Monte Carlo, seem more plausible—you could just barely imagine some alternate, Gil-Kalai-friendly universe where QMC somehow worked to simulate all realistic quantum systems, and indeed was “the actual reality behind the curtain.” In any case, though, once there’s any fast classical spoofing method at all, even a “physically unrealistic” one, the possibility is then raised that a different method might be found that’s more physically plausible.

 17. asdf Says:
 Comment #17 October 11th, 2021 at 8:15 pm

 But his point, I think in The Character of Physical Law, was about just how unlikely it is, in the case of physics research, that the person saying “have you tried 1-2-3-4-5?” is going to be telling the experts something they didn’t already think of.

 Scott #15, do you mean to tell me that this didn’t really happen? Aww well, what a disappointment. Another illusion shattered.

 18. Raoul Ohio Says:
 Comment #18 October 11th, 2021 at 11:06 pm

 #15,

 Many attempts to “semi brute force” crack passwords start with lists of passwords that are very common, like qaz123, and progress to lists of common words, etc.

 The point being that trying 10-20-30 is more like checking to see if a door is unlocked, than “telling experts something they didn’t know”.

 My top down memory of Feynman’s book includes the fact that he was often successful with the default combo, but not the story of how he got that combo. Those books are great. So is Ulam’s.

 19. fred Says:
 Comment #19 October 12th, 2021 at 8:05 am

 Scott, asdf

 but the more general point is that the practice of safe cracking involves a strong psychological aspect that experts in the mechanical design of locks could be totally ignorant of.
 Just like how most real-life hacking involves skills in social engineering that are totally orthogonal to the mathematics of cryptography.

 20. Doug S. Says:
 Comment #20 October 12th, 2021 at 10:59 am

 I’m pretty sure Feynman got the default combination from a professional locksmith who had been hired to open a safe Feynman couldn’t.

 21. Doug S. Says:
 Comment #21 October 12th, 2021 at 11:08 am

 “1-2-3-4-5? That’s the kind of combination an idiot would put on his luggage!”

 22. Doug S. Says:
 Comment #22 October 12th, 2021 at 12:33 pm

 Scott @2: I was mostly joking. P vs PSPACE is still technically an open problem, so there’s no proof that quantum mechanics can’t be simulated efficiently on a classical computer, even if nobody seriously expects to find one.

 23. Job Says:
 Comment #23 October 12th, 2021 at 2:47 pm

 The takeaway from this discussion is that amateurs guess 1-2-3-4-5 while experts guess 10-20-30.

 Everyone else just tries to grind the lock down.

 24. Dfeldmann Says:
 Comment #24 October 14th, 2021 at 7:27 am

 Hi, Scott ; I have a (probably) stupid question : Why is Schor algorithm (or the more efficient quantum annealing) never mentioned as a benchmark for (future) classical inframacy(?) It seems that to crack efficiently RSA, you would need at least 10^4 qubits, and probably 10^6, but everyone (in the commercial shere at least) is intent to sell quantum computing as the next revolution, so at first sight you would expect crooks trying to sell prototypes guaranteed to solve any code in a few years if they can get a grant, and experts explaining why this has no chance to work ; how come we never see that (or am I missing the obvious) ?

 25. Scott Says:
 Comment #25 October 14th, 2021 at 8:42 am

 Dfeldmann #24: I don’t understand your question. Of course people talk a lot about Shor’s (not Schor’s) algorithm. But to get an actual advantage from it, you’d need a fault-tolerant device with thousands of logical qubits and perhaps millions of physical qubits. That’s why the discussion of near-term quantum advantages focuses on other things, like quantum simulation and random circuit sampling (and adiabatic optimization, QAOA, and quantum machine learning, although those have more of the character of “Hail Mary passes”).

 26. Michel Says:
 Comment #26 October 18th, 2021 at 5:34 pm

 This discussion brings me back to my graduation days: I attacked a few – then – unsolved problems that stumped my professors, in the following way:”If it has a difficult (dis)proof, I can not find it anyway, so what would be the simplest solution that just might work?” And yes, that worked at least three times, getting me a.o. my 1 page (math) masters thesis…

 27. How Much Has Quantum Computing Actually Advanced? - USVI News Says:
 Comment #27 December 2nd, 2021 at 4:17 pm

 […] with qubits. For the boson sampling, there’s a nice experiment coming from USTC in China, and there’s an interesting debate that says the experiment is constructed in such a way that you can classically compute the results, […]

 28. Wang Says:
 Comment #28 December 25th, 2021 at 1:05 am

 Hi, Scott,

 Merry Christmas!

 Are only high-order correlations relevant to potential applications of Gaussian Boson Sampling? In other words can Google’s method be used in problem like molecular docking?

 Another questions: I don’t have good knowledge in this area. Is Google’s sampling algorithm built around known marginal probabilities for small number of modes? Like we know where the arrow is so we draw can circles very close to it.

 29. Anastasia Popova Says:
 Comment #29 December 28th, 2021 at 5:03 am

 In the context of quantum advantage for the 144-mode USTC experiment, Alexey Rubtsov and I have recently updated our paper “Cracking the Quantum Advantage threshold for Gaussian Boson Sampling” (https://arxiv.org/abs/2106.01445) firstly published on arXiv in June 2021. We significantly modified the manuscript according to suggestions and criticism in this blog. I’d like to direct your attention to the fact that we evaluate the global probabilities of random samples for big idealized GBS setups (Fig 4). You are also able to read our Supplementary (choose “Other Formats” on arXiv and download it as .tar.gz) for more details.

 Leave a Reply

 You can use rich HTML in comments! You can also use basic TeX, by enclosing it within $$ $$ for displayed equations or \( \) for inline equations.

 Comment Policies:

 1. All comments are placed in moderation and reviewed prior to appearing.
 2. You'll also be sent a verification email to the email address you provided.
 YOU MUST CLICK THE LINK IN YOUR VERIFICATION EMAIL BEFORE YOUR COMMENT CAN APPEAR. WHY IS THIS BOLD, UNDERLINED, ALL-CAPS, AND IN RED? BECAUSE PEOPLE ARE STILL FORGETTING TO DO IT.
 3. This comment section is not a free speech zone. It's my, Scott Aaronson's, virtual living room. Commenters are expected not to say anything they wouldn't say in my actual living room. This means: No trolling. No ad-hominems against me or others. No presumptuous requests (e.g. to respond to a long paper or article). No conspiracy theories. No patronizing me. Comments violating these policies may be left in moderation with no explanation or apology.
 4. Whenever I'm in doubt, I'll forward comments to Shtetl-Optimized Committee of Guardians, and respect SOCG's judgments on whether those comments should appear.
 5. I sometimes accidentally miss perfectly reasonable comments in the moderation queue, or they get caught in the spam filter. If you feel this may have been the case with your comment, shoot me an email.

 Name (required)

 Mail (will not be published) (required)

 Website

 Δ

 Shtetl-Optimized is proudly powered by WordPress
 Entries (RSS) and Comments (RSS).

In my last post, I wrote (among other things) about an ongoing scientific debate between the group of Chaoyang Lu at USTC in China, which over the past year has been doing experiments that seek to demonstrate quantum supremacy via Gaussian BosonSampling; and the group of Sergio Boixo at Google, which had a recent paper on a polynomial-time classical algorithm to sample approximately from the same distributions.  I reported the facts as I understood them at the time.  Since then, though, a long call with the Google team gave me a new and different understanding, and I feel duty-bound to share that here.
A week ago, I considered it obvious that if, using a classical spoofer, you could beat the USTC experiment on a metric like total variation distance from the ideal distribution, then you would’ve completely destroyed USTC’s claim of quantum supremacy.  The reason I believed that, in turn, is a proposition that I hadn’t given a name but needs one, so let me call it Hypothesis H:
 The only way a classical algorithm to spoof BosonSampling can possibly do well in total variation distance, is by correctly reproducing the high-order correlations (correlations among the occupation numbers of large numbers of modes) — because that’s where the complexity of BosonSampling lies (if it lies anywhere). 
Hypothesis H had important downstream consequences.  Google’s algorithm, by the Google team’s own admission, does not reproduce the high-order correlations.  Furthermore, because of limitations on both samples and classical computation time, Google’s paper calculates the total variation distance from the ideal distribution only on the marginal distribution on roughly 14 out of 144 modes.  On that marginal distribution, Google’s algorithm does do better than the experiment in total variation distance.  Google presents a claimed extrapolation to the full 144 modes, but eyeballing the graphs, it was far from clear to me what would happen: like, maybe the spoofing algorithm would continue to win, but maybe the experiment would turn around and win; who knows?
Chaoyang, meanwhile, made a clear prediction that the experiment would turn around and win, because of
 the experiment’s success in reproducing the high-order correlations, the admitted failure of Google’s algorithm in reproducing the high-order correlations, and the seeming impossibility of doing well on BosonSampling without reproducing the high-order correlations (Hypothesis H). 
Given everything my experience told me about the central importance of high-order correlations for BosonSampling, I was inclined to agree with Chaoyang.
Now for the kicker: it seems that Hypothesis H is false.  A classical spoofer could beat a BosonSampling experiment on total variation distance from the ideal distribution, without even bothering to reproduce the high-order correlations correctly.
This is true because of a combination of two facts about the existing noisy BosonSampling experiments.  The first fact is that the contribution from the order-k correlations falls off like 1/exp(k).  The second fact is that, due to calibration errors and the like, the experiments already show significant deviations from the ideal distribution on the order-1 and order-2 correlations.
Put these facts together and what do you find?  Well, suppose your classical spoofing algorithm takes care to get the low-order contributions to the distribution exactly right.  Just for that reason alone, it could already win over a noisy BosonSampling experiment, as judged by benchmarks like total variation distance from the ideal distribution, or for that matter linear cross-entropy.  Yes, the experiment will beat the classical simulation on the higher-order correlations.  But because those higher-order correlations are exponentially attenuated anyway, they won’t be enough to make up the difference.  The experiment’s lack of perfection on the low-order correlations will swamp everything else.
Granted, I still don’t know for sure that this is what happens — that depends on whether I believe Sergio or Chaoyang about the extrapolation of the variation distance to the full 144 modes (my own eyeballs having failed to render a verdict!).  But I now see that it’s logically possible, maybe even plausible.
So, let’s imagine for the sake of argument that Google’s simulation wins on variation distance, even though the experiment wins on the high-order correlations.  In that case, what would be our verdict: would USTC have achieved quantum supremacy via BosonSampling, or not?
It’s clear what each side could say.
Google could say: by a metric that Scott Aaronson, the coinventor of BosonSampling, thought was perfectly adequate as late as last week — namely, total variation distance from the ideal distribution — we won.  We achieved lower variation distance than USTC’s experiment, and we did it using a fast classical algorithm.  End of discussion.  No moving the goalposts after the fact.
Google could even add: BosonSampling is a sampling task; it’s right there in the name!  The only purpose of any benchmark — whether Linear XEB or high-order correlation — is to give evidence about whether you are or aren’t sampling from a distribution close to the ideal one.  But that means that, if you accept that we are doing the latter better than the experiment, then there’s nothing more to argue about.
USTC could respond: even if Scott Aaronson is the coinventor of BosonSampling, he’s extremely far from an infallible oracle.  In the case at hand, his lack of appreciation for the sources of error in realistic experiments caused him to fixate inappropriately on variation distance as the success criterion.  If you want to see the quantum advantage in our system, you have to deliberately subtract off the low-order correlations and look at the high-order correlations.
USTC could add: from the very beginning, the whole point of quantum supremacy experiments was to demonstrate a clear speedup on some benchmark — we never particularly cared which one!  That horse is out of the barn as soon as we’re talking about quantum supremacy at all — something the Google group, which itself reported the first quantum supremacy experiment in Fall 2019, again for a completely artificial benchmark — knows as well as anyone else.  (The Google team even has experience with adjusting benchmarks: when, for example, Pan and Zhang pointed out that Linear XEB as originally specified is pretty easy to spoof for random 2D circuits, the most cogent rejoinder was: OK, fine then, add an extra check that the returned samples are sufficiently different from one another, which kills Pan and Zhang’s spoofing strategy.) In that case, then, why isn’t a benchmark tailored to the high-order correlations as good as variation distance or linear cross-entropy or any other benchmark?
Both positions are reasonable and have merit — though I confess to somewhat greater sympathy for the one that appeals to my doofosity rather than my supposed infallibility!
OK, but suppose, again for the sake of argument, that we accepted the second position, and we said that USTC gets to declare quantum supremacy as long as its experiment does better than any known classical simulation at reproducing the high-order correlations.  We’d still face the question: does the USTC experiment, in fact, do better on that metric?  It would be awkward if, having won the right to change the rules in its favor, USTC still lost even under the new rules.
Sergio tells me that USTC directly reported experimental data only for up to order-7 correlations, and at least individually, the order-7 correlations are easy to reproduce on a laptop (although sampling in a way that reproduces the order-7 correlations might still be hard—a point that Chaoyang confirms, and where further research would be great). OK, but USTC also reported that their experiment seems to reproduce up to order-19 correlations. And order-19 correlations, the Google team agrees, are hard to sample consistently with on a classical computer by any currently known algorithm.
So then, why don’t we have direct data for the order-19 correlations?  The trouble is simply that it would’ve taken USTC an astronomical amount of computation time.  So instead, they relied on a statistical extrapolation from the observed strength of the lower-order correlations — there we go again with the extrapolations!  Of course, if we’re going to let Google rest its case on an extrapolation, then maybe it’s only sporting to let USTC do the same.
You might wonder: why didn’t we have to worry about any of this stuff with the other path to quantum supremacy, the one via random circuit sampling with superconducting qubits?  The reason is that, with random circuit sampling, all the correlations except the highest-order ones are completely trivial — or, to say it another way, the reduced state of any small number of output qubits is exponentially close to the maximally mixed state.  This is a real difference between BosonSampling and random circuit sampling—and even 5-6 years ago, we knew that this represented an advantage for random circuit sampling, although I now have a deeper appreciation for just how great of an advantage it is.  For it means that, with random circuit sampling, it’s easier to place a “sword in the stone”: to say, for example, here is the Linear XEB score achieved by the trivial classical algorithm that outputs random bits, and lo, our experiment achieves a higher score, and lo, we challenge anyone to invent a fast classical spoofing method that achieves a similarly high score.
With BosonSampling, by contrast, we have various metrics with which to judge performance, but so far, for none of those metrics do we have a plausible hypothesis that says “here’s the best that any polynomial-time classical algorithm can possibly hope to do, and it’s completely plausible that even a noisy current or planned BosonSampling experiment can do better than that.”
In the end, then, I come back to the exact same three goals I would’ve recommended a week ago for the future of quantum supremacy experiments, but with all of them now even more acutely important than before:
 Experimentally, to increase the fidelity of the devices (with BosonSampling, for example, to observe a larger contribution from the high-order correlations) — a much more urgent goal, from the standpoint of evading classical spoofing algorithms, than further increasing the dimensionality of the Hilbert space. Theoretically, to design better ways to verify the results of sampling-based quantum supremacy experiments classically — ideally, even ways that could be applied via polynomial-time tests. For Gaussian BosonSampling in particular, to get a better understanding of the plausible limits of classical spoofing algorithms, and exactly how good a noisy device needs to be before it exceeds those limits. 
Thanks so much to Sergio Boixo and Ben Villalonga for the conversation, and to Chaoyang Lu and Jelmer Renema for comments on this post. Needless to say, any remaining errors are my own.
	
	
	This entry was posted
	on Sunday, October 10th, 2021 at 1:13 pm	and is filed under Complexity, Embarrassing Myself, Quantum.
	You can follow any responses to this entry through the RSS 2.0 feed.
	You can leave a response, or trackback from your own site.
	
	
	 You can use rich HTML in comments! You can also use basic TeX, by enclosing it within $$ $$ for displayed equations or \( \) for inline equations.
Gaussian BosonSampling, higher-order correlations, and spoofing: An update
https://scottaaronson.blog/?p=5868
https://www.preposterousuniverse.com/blog/2016/08/15/you-should-love-or-at-least-respect-the-schrodinger-equation/
You Should Love (or at least respect) the Schrödinger Equation
2016-08-15
None
<div><div>
	<main>
	
<article>
	
<div>
	<p>Over at the twitter dot com website, there has been a briefly-trending topic <a href="https://twitter.com/hashtag/fav7films">#fav7films</a>, discussing your favorite seven films. Part of the purpose of being on twitter is to one-up the competition, so I instead <a href="https://twitter.com/seanmcarroll/status/765215881932648448">listed</a> my <a href="https://twitter.com/hashtag/fav7equations">#fav7equations</a>. Slightly cleaned up, the equations I chose as my seven favorites are:</p>
<ol>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ol>
<p>In order: Newton’s Second Law of motion, the Euler-Lagrange equation, Maxwell’s equations in terms of differential forms, Boltzmann’s definition of entropy, the metric for Minkowski spacetime (special relativity), Einstein’s equation for spacetime curvature (general relativity), and the Schrödinger equation of quantum mechanics. Feel free to Google them for more info, even if equations aren’t your thing. They represent a series of extraordinary insights in the development of physics, from the 1600’s to the present day.</p>
<p>Of course people chimed in with their own favorites, which is all in the spirit of the thing. But one misconception came up that is probably worth correcting: people don’t appreciate how important and all-encompassing the <a href="https://en.wikipedia.org/wiki/Schr%C3%B6dinger_equation">Schrödinger equation</a> is.</p>
<p>I blame society. Or, more accurately, I blame how we teach quantum mechanics. Not that the standard treatment of the Schrödinger equation is fundamentally wrong (as other aspects of how we teach QM are), but that it’s incomplete. And sometimes people get brief introductions to things like the <a href="https://en.wikipedia.org/wiki/Dirac_equation">Dirac equation</a> or the <a href="https://en.wikipedia.org/wiki/Klein%E2%80%93Gordon_equation">Klein-Gordon equation</a>, and come away with the impression that they are somehow relativistic replacements for the Schrödinger equation, which they certainly are not. Dirac et al. may have originally wondered whether they were, but these days we certainly know better.</p>
<p>As I remarked in my post about <a href="https://www.preposterousuniverse.com/blog/2016/07/18/space-emerging-from-quantum-mechanics/">emergent space</a>, we human beings tend to do quantum mechanics by starting with some classical model, and then “quantizing” it. Nature doesn’t work that way, but we’re not as smart as Nature is. By a “classical model” we mean something that obeys the basic Newtonian paradigm: there is some kind of generalized “position” variable, and also a corresponding “momentum” variable (how fast the position variable is changing), which together obey some deterministic equations of motion that can be solved once we are given initial data. Those equations can be derived from a function called the Hamiltonian, which is basically the energy of the system as a function of positions and momenta; the results are <a href="https://en.wikipedia.org/wiki/Hamiltonian_mechanics">Hamilton’s equations</a>, which are essentially a slick version of Newton’s original .</p>
<p>There are various ways of taking such a setup and “quantizing” it, but one way is to take the position variable and consider all possible (<a href="https://en.wikipedia.org/wiki/Square-integrable_function">normalized</a>, complex-valued) <em>functions</em> of that variable. So instead of, for example, a single position coordinate <em>x</em> and its momentum <em>p</em>, quantum mechanics deals with <a href="https://en.wikipedia.org/wiki/Wave_function">wave functions</a> <em>ψ</em>(<em>x</em>). That’s the thing that you square to get the <a href="https://www.preposterousuniverse.com/blog/2014/07/24/why-probability-in-quantum-mechanics-is-given-by-the-wave-function-squared/">probability</a> of observing the system to be at the position <em>x</em>. (We can also transform the wave function to “momentum space,” and calculate the probabilities of observing the system to be at momentum <em>p</em>.) Just as positions and momenta obey Hamilton’s equations, the wave function obeys the Schrödinger equation,</p>
<blockquote><p>.</p></blockquote>
<p>Indeed, the that appears in the Schrödinger equation is just the quantum version of the Hamiltonian.</p>
<p>The problem is that, when we are first taught about the Schrödinger equation, it is usually in the context of a specific, very simple model: a single non-relativistic particle moving in a potential. In other words, we choose a particular kind of wave function, and a particular Hamiltonian. The corresponding version of the Schrödinger equation is</p>
<blockquote><p>.</p></blockquote>
<p>If you don’t dig much deeper into the essence of quantum mechanics, you could come away with the impression that this is “the” Schrödinger equation, rather than just “the non-relativistic Schrödinger equation for a single particle.” Which would be a shame.</p>
<p>What happens if we go beyond the world of non-relativistic quantum mechanics? Is the poor little Schrödinger equation still up to the task? Sure! All you need is the right set of wave functions and the right Hamiltonian. Every quantum system obeys a version of the Schrödinger equation; it’s completely general. In particular, there’s no problem talking about relativistic systems or field theories — just don’t use the non-relativistic version of the equation, obviously.</p>
<p>What about the Klein-Gordon and Dirac equations? These were, indeed, originally developed as “relativistic versions of the non-relativistic Schrödinger equation,” but that’s not what they ended up being useful for. (The story is told that Schrödinger himself invented the Klein-Gordon equation even before his non-relativistic version, but discarded it because it didn’t do the job for describing the hydrogen atom. As my old professor Sidney Coleman put it, “Schrödinger was no dummy. He knew about relativity.”)</p>
<p>The Klein-Gordon and Dirac equations are actually not quantum at all — they are <em>classical field equations</em>, just like Maxwell’s equations are for electromagnetism and Einstein’s equation is for the metric tensor of gravity. They aren’t usually taught that way, in part because (unlike E&amp;M and gravity) there aren’t any macroscopic classical fields in Nature that obey those equations. The KG equation governs relativistic <a href="https://en.wikipedia.org/wiki/Scalar_field">scalar fields</a> like the Higgs boson, while the Dirac equation governs <a href="https://en.wikipedia.org/wiki/Fermionic_field">spinor fields</a> (spin-1/2 fermions) like the electron and neutrinos and quarks. In Nature, spinor fields are a little subtle, because they are anticommuting <a href="https://en.wikipedia.org/wiki/Fermionic_field">Grassmann variables</a> rather than ordinary functions. But make no mistake; the Dirac equation fits perfectly comfortably into the standard Newtonian physical paradigm.</p>
<p>For fields like this, the role of “position” that for a single particle was played by the variable <em>x</em> is now played by <em>an entire configuration of the field throughout space</em>. For a scalar Klein-Gordon field, for example, that might be the values of the field <em>φ</em>(<em>x</em>) at every spatial location <em>x</em>. But otherwise the same story goes through as before. We construct a wave function by attaching a complex number to every possible value of the position variable; to emphasize that it’s a function of functions, we sometimes call it a “wave functional” and write it as a capital letter,</p>
<blockquote><p>.</p></blockquote>
<p>The absolute-value-squared of this wave functional tells you the probability that you will observe the field to have the value <em>φ</em>(<em>x</em>) at each point <em>x</em> in space. The functional obeys — you guessed it — a version of the Schrödinger equation, with the Hamiltonian being that of a relativistic scalar field. There are likewise versions of the Schrödinger equation for the electromagnetic field, for Dirac fields, for the whole <a href="https://www.preposterousuniverse.com/blog/2015/09/29/core-theory-t-shirts/">Core Theory</a>, and what have you.</p>
<p>So the Schrödinger equation is not simply a relic of the early days of quantum mechanics, when we didn’t know how to deal with much more than non-relativistic particles orbiting atomic nuclei. It is the foundational equation of quantum dynamics, and applies to every quantum system there is. (There are equivalent ways of doing quantum mechanics, of course, like the <a href="https://en.wikipedia.org/wiki/Heisenberg_picture">Heisenberg picture</a> and the <a href="https://en.wikipedia.org/wiki/Path_integral_formulation">path-integral formulation</a>, but they’re all basically equivalent.) You tell me what the quantum state of your system is, and what is its Hamiltonian, and I will plug into the Schrödinger equation to see how that state will evolve with time. And as far as we know, quantum mechanics is how the universe works. Which makes the Schrödinger equation arguably the most important equation in all of physics.</p>
<p>While we’re at it, people complained that the cosmological constant Λ didn’t appear in Einstein’s equation (6). Of course it does — it’s part of the energy-momentum tensor on the right-hand side. Again, Einstein didn’t necessarily think of it that way, but these days we know better. The whole thing that is great about physics is that we keep learning things; we don’t need to remain stuck with the first ideas that were handed down by the great minds of the past.</p>
	</div>
	
</article>
	 
	</main>
	</div>||||I||||Skip to content
 Sean Carroll

 in truth, only atoms and the void

 Main Menu
 * About This Blog
 * About Sean
 * Greatest Hits

 You Should Love (or at least respect) the Schrödinger Equation

 47 Comments / Science

 Over at the twitter dot com website, there has been a briefly-trending topic #fav7films, discussing your favorite seven films. Part of the purpose of being on twitter is to one-up the competition, so I instead listed my #fav7equations. Slightly cleaned up, the equations I chose as my seven favorites are:

 1. 
 2. 
 3. 
 4. 
 5. 
 6. 
 7. 

 In order: Newton’s Second Law of motion, the Euler-Lagrange equation, Maxwell’s equations in terms of differential forms, Boltzmann’s definition of entropy, the metric for Minkowski spacetime (special relativity), Einstein’s equation for spacetime curvature (general relativity), and the Schrödinger equation of quantum mechanics. Feel free to Google them for more info, even if equations aren’t your thing. They represent a series of extraordinary insights in the development of physics, from the 1600’s to the present day.

 Of course people chimed in with their own favorites, which is all in the spirit of the thing. But one misconception came up that is probably worth correcting: people don’t appreciate how important and all-encompassing the Schrödinger equation is.

 I blame society. Or, more accurately, I blame how we teach quantum mechanics. Not that the standard treatment of the Schrödinger equation is fundamentally wrong (as other aspects of how we teach QM are), but that it’s incomplete. And sometimes people get brief introductions to things like the Dirac equation or the Klein-Gordon equation, and come away with the impression that they are somehow relativistic replacements for the Schrödinger equation, which they certainly are not. Dirac et al. may have originally wondered whether they were, but these days we certainly know better.

 As I remarked in my post about emergent space, we human beings tend to do quantum mechanics by starting with some classical model, and then “quantizing” it. Nature doesn’t work that way, but we’re not as smart as Nature is. By a “classical model” we mean something that obeys the basic Newtonian paradigm: there is some kind of generalized “position” variable, and also a corresponding “momentum” variable (how fast the position variable is changing), which together obey some deterministic equations of motion that can be solved once we are given initial data. Those equations can be derived from a function called the Hamiltonian, which is basically the energy of the system as a function of positions and momenta; the results are Hamilton’s equations, which are essentially a slick version of Newton’s original .

 There are various ways of taking such a setup and “quantizing” it, but one way is to take the position variable and consider all possible (normalized, complex-valued) functions of that variable. So instead of, for example, a single position coordinate x and its momentum p, quantum mechanics deals with wave functions ψ(x). That’s the thing that you square to get the probability of observing the system to be at the position x. (We can also transform the wave function to “momentum space,” and calculate the probabilities of observing the system to be at momentum p.) Just as positions and momenta obey Hamilton’s equations, the wave function obeys the Schrödinger equation,

 .

 Indeed, the that appears in the Schrödinger equation is just the quantum version of the Hamiltonian.

 The problem is that, when we are first taught about the Schrödinger equation, it is usually in the context of a specific, very simple model: a single non-relativistic particle moving in a potential. In other words, we choose a particular kind of wave function, and a particular Hamiltonian. The corresponding version of the Schrödinger equation is

 .

 If you don’t dig much deeper into the essence of quantum mechanics, you could come away with the impression that this is “the” Schrödinger equation, rather than just “the non-relativistic Schrödinger equation for a single particle.” Which would be a shame.

 What happens if we go beyond the world of non-relativistic quantum mechanics? Is the poor little Schrödinger equation still up to the task? Sure! All you need is the right set of wave functions and the right Hamiltonian. Every quantum system obeys a version of the Schrödinger equation; it’s completely general. In particular, there’s no problem talking about relativistic systems or field theories — just don’t use the non-relativistic version of the equation, obviously.

 What about the Klein-Gordon and Dirac equations? These were, indeed, originally developed as “relativistic versions of the non-relativistic Schrödinger equation,” but that’s not what they ended up being useful for. (The story is told that Schrödinger himself invented the Klein-Gordon equation even before his non-relativistic version, but discarded it because it didn’t do the job for describing the hydrogen atom. As my old professor Sidney Coleman put it, “Schrödinger was no dummy. He knew about relativity.”)

 The Klein-Gordon and Dirac equations are actually not quantum at all — they are classical field equations, just like Maxwell’s equations are for electromagnetism and Einstein’s equation is for the metric tensor of gravity. They aren’t usually taught that way, in part because (unlike E&M and gravity) there aren’t any macroscopic classical fields in Nature that obey those equations. The KG equation governs relativistic scalar fields like the Higgs boson, while the Dirac equation governs spinor fields (spin-1/2 fermions) like the electron and neutrinos and quarks. In Nature, spinor fields are a little subtle, because they are anticommuting Grassmann variables rather than ordinary functions. But make no mistake; the Dirac equation fits perfectly comfortably into the standard Newtonian physical paradigm.

 For fields like this, the role of “position” that for a single particle was played by the variable x is now played by an entire configuration of the field throughout space. For a scalar Klein-Gordon field, for example, that might be the values of the field φ(x) at every spatial location x. But otherwise the same story goes through as before. We construct a wave function by attaching a complex number to every possible value of the position variable; to emphasize that it’s a function of functions, we sometimes call it a “wave functional” and write it as a capital letter,

 .

 The absolute-value-squared of this wave functional tells you the probability that you will observe the field to have the value φ(x) at each point x in space. The functional obeys — you guessed it — a version of the Schrödinger equation, with the Hamiltonian being that of a relativistic scalar field. There are likewise versions of the Schrödinger equation for the electromagnetic field, for Dirac fields, for the whole Core Theory, and what have you.

 So the Schrödinger equation is not simply a relic of the early days of quantum mechanics, when we didn’t know how to deal with much more than non-relativistic particles orbiting atomic nuclei. It is the foundational equation of quantum dynamics, and applies to every quantum system there is. (There are equivalent ways of doing quantum mechanics, of course, like the Heisenberg picture and the path-integral formulation, but they’re all basically equivalent.) You tell me what the quantum state of your system is, and what is its Hamiltonian, and I will plug into the Schrödinger equation to see how that state will evolve with time. And as far as we know, quantum mechanics is how the universe works. Which makes the Schrödinger equation arguably the most important equation in all of physics.

 While we’re at it, people complained that the cosmological constant Λ didn’t appear in Einstein’s equation (6). Of course it does — it’s part of the energy-momentum tensor on the right-hand side. Again, Einstein didn’t necessarily think of it that way, but these days we know better. The whole thing that is great about physics is that we keep learning things; we don’t need to remain stuck with the first ideas that were handed down by the great minds of the past.

 Related Posts:

 * Entropic Time
 * Trending Topic on Twitter
 * Quantum Mechanics and Decision Theory
 47 Comments
 Post navigation
 ← Previous Post
 Next Post →

 47 thoughts on “You Should Love (or at least respect) the Schrödinger Equation”

 Newer Comments

 Newer Comments
 1. Richard Casey
 August 15, 2016 at 3:45 pm

 Not only would I generally agree with this set of equations as my favorites, but I have them as screensavers to remind me of their fundamental importance in scientific inquiry. Thanks for sharing.

 2. Walker Lee Guthrie
 August 15, 2016 at 4:07 pm

 Great post

 3. BobC
 August 15, 2016 at 4:24 pm

 As an engineer I’ve always enjoyed the elegance and power of Maxwell’s Equations, but when it comes to practical matters (making stuff that works), few equations eclipse Ohm’s Law and Kirchoff’s Laws (KVL and KCL), and few tools eclipse the Laplace and Fourier transforms.

 4. John Anderson
 August 15, 2016 at 5:53 pm

 I love lists like this. Similar fun with Robert Crease’s book “The Great Equations”, and Wm. Dunham’s book “Journey through Genius” or the video course “Great Thinkers Great Theorems”.

 Forty years after I studied Q.M. in college I got a proof from CU/Boulder (really just a justification of Schrödinger’s equation); I said “Wow, it’s not just a postulate; it makes some sense!”

 Weird Al Yankovic made music history by having Schrödinger’s equation as part of his video backdrop in “White and Nerdy”.

 5. Fred Gray
 August 15, 2016 at 6:26 pm

 Wow! Made my day. I just realized that I’m really stupid, in the grand scheme of things. Bummer.

 6. Reader297
 August 15, 2016 at 7:49 pm

 Sean–

 Great post! I agree about respecting the Schrodinger equation, and not confusing it with its special case for a nonrelativistic system of particles, nor with the common idea that somehow the Dirac equation or the Klein-Gordon equation generalize the Schrodinger equation.

 However, your post has an important couple of typos or oversights. If one is going to go to all the trouble of trying to rectify popular misconceptions, one should be sure not to instill new ones!

 You write “Every quantum system obeys a version of the Schrödinger equation; it’s completely general.” You later also write “It is the foundational equation of quantum dynamics, and applies to every quantum system there is… You tell me what the quantum state of your system is, and what is its Hamiltonian, and I will plug into the Schrödinger equation to see how that state will evolve with time.”

 These statements are not correct. They apply only in the special case of a *closed* quantum system. For a *closed* system that begins and remains in a pure state, the Schrodinger equation expresses conservation of information with time, with the consequence in particular that the system’s Von Neumann entropy is and remains exactly zero.

 An *open* quantum system, however, does not generically begin or end in a pure state, does not generically conserve information with time, and does not generically satisfy the Schrodinger equation. After all, without being in a pure state, there isn’t a state vector or wave function available even in principle to satisfy the Schrodinger equation in the first place!

 The dynamics of an open system is, at best, expressible in terms of the system’s density matrix. With certain assumptions and approximation, open quantum systems evolve according to a linear CPTP mapping, an example of which is the Lindblad quation (https://en.wikipedia.org/wiki/Lindblad_equation), which assumes linearity and homogeneity in time, both of which are always just approximations in practice.

 Open systems certainly aren’t just a curiosity. All systems apart from the entire universe are generically at least a little bit open. So not only does the Schrodinger equation not describe general systems, it doesn’t really describe *any* systems at all, apart from the universe as a whole. Even more importantly, any system undergoing a measurement process is at least temporarily very much open, and, of course, an ideal measurement process without postselection can be written as a linear CPTP mapping, namely, the Von Neumann-Luders projection.

 For a totally general quantum system and without making approximations or assumptions, it isn’t even the case that the system’s evolution is necessarily linear.

 7. Moshe
 August 15, 2016 at 9:57 pm

 Surprising how many people who should know better still talk about “relativistic quantum mechanics”, even when teaching graduate classes, and consequently just how much unconfusing you have to do when teaching QFT. One more common confusion is thinking the Schrodinger equation is non-relativistic because it involves time derivatives but not spatial ones (of course both sides of the equation transform the same way under Lorentz transformations, so the equation is perfectly Lorentz invariant, even if it is not phrased as a statement about Lorntz scalers)

 8. Bee
 August 15, 2016 at 11:06 pm

 It’s a confusion I have encountered frequently in comments on my blog, thanks for clearing up.

 9. Richard Gaylord
 August 15, 2016 at 11:59 pm

 “we don’t need to remain stuck with the first ideas that were handed down by the great minds of the past.”. it’s comforting to know that string theory will ‘go away’ eventually. unfortunately, in the words of Max Planck ““Science advances one funeral at a time.”

 10. vmarko
 August 16, 2016 at 2:22 am

 Sean,

 I have to say that I agree with Reader297 on this. The Schrodinger equation works for isolated systems only, so basically it’s just an approximation rather than a fundamental equation of nature.

 Reader297,

 “So not only does the Schrodinger equation not describe general systems, it doesn’t really describe *any* systems at all, apart from the universe as a whole.”

 Not only that, but the Schrodinger equation doesn’t apply even to the universe as a whole. In general relativity (and basically all physical systems which have diffeomorphism symmetry) the Hamiltonian of the system is a linear combination of the constraints, and is therefore equal to zero. So the Schrodinger equation for the whole universe just tells you that the total wavefunctional doesn’t depend on time. IOW, there is no equation to solve there, it’s trivial.

 So I’d say that the Schrodinger equation is far from being fundamental in any respect. It’s not relevant for any realistic physical system, unless you introduce approximations.

 🙂
 Marko

 11. Bob Zannelli
 August 16, 2016 at 3:09 am

 I think it’s ironic that Schrodinger was not very pleased with what this equation is really telling us about nature. Its “true” meaning was made clear by Max Born, perhaps one of the most overlooked of the great physicists who gave us the quantum revolution. Like Einstein, Schrodinger was never reconciled with what he has discovered.

 12. masmadera
 August 16, 2016 at 3:18 am

 Eq.(4) is only important to the extent that one adds the second principle (the entropy always increases or remains the same, defining the equilibrium). Otherwise is like writing how you compute the energy without saying why the energy is important (time invariance). But Thermo seems to be getting old fashion and somehow few people think now that Delta S > 0 is a beautiful equation.

 I fully disagree with commenters downgrading the Schrödinger equation. I agree that it is incomplete, in the general framework of Quantum Mechanics, without invoking Born’s rule. But then, you can only pick 7 equations!

 13. Moe
 August 16, 2016 at 5:42 am

 In your last post you said that quantum mechanics says that the real world is best described by a wave function, an element of Hilbert space, evolving through time.

 Do you believe that the total wave function has a time dependency?

 I find it very hard to understand how space and time can be so intermingled in Relativity, yet seem to seperate so much in quantum mechanics. Even in considering gravity emerging from entanglement entropy, time seems to have some special position seperate from the other dimensions.

 14. Carl
 August 16, 2016 at 6:25 am

 Sean,

 What a great post and concise explanation of the complex relationships of the relevant equations. This should be included in every “Introduction to QM” class.

 “As I remarked in my post about emergent space, we human beings tend to do quantum mechanics by starting with some classical model, and then “quantizing” it. Nature doesn’t work that way, but we’re not as smart as Nature is.”

 I totally agree about your assessment of the way “traditional” QM is usually introduced. That was my introduction to QM.

 Thanks again for a great post.

 Carl G.
 =====

 15. Sean Carroll
 August 16, 2016 at 7:57 am

 Moe– I honestly don’t know whether the true wave function of the universe is time-dependent or not. It’s very possible that the apparent time evolution of the universe is an emergent phenomenon, just like space. We’ll have to see.

 It’s true that the Lorentz symmetry of relativity seems to put time and space on an equal footing, which they don’t seem to be from the perspective of the Schrödinger equation. But again, Lorentz invariance could just be an emergent approximation.

 16. Joseph Salmon
 August 16, 2016 at 8:09 am

 Please let me encourage another “TEDD Radio Hour” talk on this and other ambitious projects.

 17. Moe
 August 16, 2016 at 8:13 am

 @Sean

 Thanks for those thoughts.

 Maybe I haven’t caught this before.

 Are you in favor of the idea that the universe is ‘just information’?

 As in… space and gravity just energe from entanglement entropy, and time also emerges from entropy?

 Then the whole universe could just be described by bits of information?

 Potentially?

 18. Neil
 August 16, 2016 at 9:17 am

 Now why does #4 look so familiar?

 19. Left Coast Bernard
 August 16, 2016 at 12:15 pm

 Prof. Carroll,
 Please recommend a (graduate level) quantum physics book that explains the ideas about quantum theory correctly as you describe in this interesting post.
 Also, I wonder if you might comment on the apparent essential place of complex functions and numbers in quantum theory. After all, any experimental result or observation will be a rational number. Physics theories usually deal in real numbers and real functions. Schrodinger’s earliest papers state results as the real part or the imaginary part of the wave function, but now physicists see the wave function’s complex nature as central, and not just a matter of computational convenience as complex functions are, say, in electrical engineering. Computers, on the other hand, have a finite number of possible numbers, with a maximum, a minimum, and a limited precision.

 20. Sean Carroll
 August 16, 2016 at 2:38 pm

 I don’t really have a favorite grad-level QM book, I’m afraid. About complex numbers, people have speculated on the deeper significance there, but it’s not something I’ve personally thought about.

 21. Gabriel
 August 16, 2016 at 2:52 pm

 Great post, I’ve wondered for awhile what the general Schroedinger equation encompasses. I’ve been reading The Big Picture and enjoying it very much. Just wondering if a Schroedinger equation for the core theory has been written down by anyone or if you were going to possibly post one? Also, curious why the yang-mills equations didn’t make the list.

 22. Julio Siqueira
 August 16, 2016 at 2:57 pm

 .
 As an incurable layman in physics ( 🙁 ), I try erratically and clumsily to grasp some inklings of physic’s insights from writings of people like Sean Carroll, both in books and in blog posts (articles) like this one that he just wrote. And often I find perplexing oppositions like the ones expressed by the phrases below:
 .
 [Sean Carroll] And as far as we know, quantum mechanics is how the universe works.
 .
 [Reader297] So not only does the Schrodinger equation not describe general systems, it doesn’t really describe *any* systems at all, apart from the universe as a whole.
 .
 [vmarko] Not only that, but the Schrodinger equation doesn’t apply even to the universe as a whole. So I’d say that the Schrodinger equation is far from being fundamental in any respect.
 .
 Now, you enlighted ones, imagine how we humble laymen feel when facing these perplexing different scientific views…
 .
 Best Wishes,
 Julio Siqueira
 juliocbsiqueira2012@gmail.com
 http://www.criticandokardec.com.br/criticizingskepticism.htm
 —————————————————————————————————

 23. John B
 August 16, 2016 at 8:51 pm

 A part of me dies a little bit inside every time you fight for the MWI, because I have always heard that the Schrodinger equation implies that quantum uncertainty is fundamental.

 24. Moe
 August 17, 2016 at 2:12 am

 @John B

 Quantum uncertainty is not in the Schrödinger equation. It is completely deterministic. Uncertainty only exists when measurements are taken. MWI allows these to both be true. The uncertainty only exists within particular branches that seem to be unique, from the standpoint of the observers within them. Taken as a whole, MWI results directly from the Schrödinger equation, without ever needing to collapse the wavefunction.

 25. MassiveFermion
 August 17, 2016 at 4:23 am

 Hi Sean
 Thanks for the nice post
 I have a question about it though.
 When you try to pursue a parallel path with non-Rel. QM, surely it seems very plausible to think that the square of the absolute value of the wave-functional gives the probability for the field to be in the configuration that was given to the wave-functional as the input. But when I think about it, it seems to me that its useless to the extent that I wonder why such an identification should be made.
 There are two reasons for what I said:
 1) Its not possible, even in theory(I think), to conduct an experiment that gives us enough information to find out which configuration the field actually is in.
 2) Its not possible, even in theory, to have an ensemble of identically prepared fields.
 So I’m wondering whether it even makes sense to have a functional formulation of QFT!
 What do you think?

 Newer Comments

 Newer Comments

 Comments are closed.

 Search for:

 Sean’s Twitter

 Follow @seanmcarroll

 Blog Updates via Twitter

 Follow @preposterousuni

 Recent Posts

 * Thanksgiving
 * The Biggest Ideas in the Universe: Space, Time, and Motion
 * Johns Hopkins
 * Thanksgiving
 * The Zombie Argument for Physicalism (Contra Panpsychism)
 * Energy Conservation and Non-Conservation in Quantum Mechanics
 * Thanksgiving
 * What I Look for in Podcast Guests

 Archives

 Archives Select Month November 2022 (1) September 2022 (1) March 2022 (1) November 2021 (2) January 2021 (1) November 2020 (1) September 2020 (2) August 2020 (5) July 2020 (4) June 2020 (5) May 2020 (4) April 2020 (4) March 2020 (3) November 2019 (1) September 2019 (1) July 2019 (1) January 2019 (1) November 2018 (1) September 2018 (1) July 2018 (1) June 2018 (1) May 2018 (2) March 2018 (1) February 2018 (2) January 2018 (2) November 2017 (1) October 2017 (2) September 2017 (1) June 2017 (1) May 2017 (4) April 2017 (1) January 2017 (1) December 2016 (2) November 2016 (6) September 2016 (2) August 2016 (2) July 2016 (1) June 2016 (1) May 2016 (10) April 2016 (2) March 2016 (2) February 2016 (3) January 2016 (3) December 2015 (3) November 2015 (2) October 2015 (1) September 2015 (2) August 2015 (2) July 2015 (6) June 2015 (2) May 2015 (2) April 2015 (5) March 2015 (6) February 2015 (5) January 2015 (4) December 2014 (4) November 2014 (5) October 2014 (5) September 2014 (5) August 2014 (4) July 2014 (4) June 2014 (5) May 2014 (6) April 2014 (8) March 2014 (10) February 2014 (10) January 2014 (6) December 2013 (6) November 2013 (7) October 2013 (6) September 2013 (5) August 2013 (10) July 2013 (8) June 2013 (6) May 2013 (14) April 2013 (8) March 2013 (7) February 2013 (13) January 2013 (10) December 2012 (15) November 2012 (14) October 2012 (11) September 2012 (11) August 2012 (14) July 2012 (10) June 2012 (17) May 2012 (8) April 2012 (15) March 2012 (10) February 2012 (11) January 2012 (8) December 2011 (12) November 2011 (12) October 2011 (13) September 2011 (13) August 2011 (14) July 2011 (12) June 2011 (12) May 2011 (18) April 2011 (18) March 2011 (15) February 2011 (17) January 2011 (20) December 2010 (14) November 2010 (16) October 2010 (19) September 2010 (9) August 2010 (4) July 2010 (3) June 2010 (12) May 2010 (11) April 2010 (17) March 2010 (16) February 2010 (16) January 2010 (19) December 2009 (15) November 2009 (10) October 2009 (14) September 2009 (17) August 2009 (16) July 2009 (16) June 2009 (14) May 2009 (13) April 2009 (15) March 2009 (13) February 2009 (18) January 2009 (16) December 2008 (18) November 2008 (20) October 2008 (19) September 2008 (22) August 2008 (18) July 2008 (21) June 2008 (20) May 2008 (6) April 2008 (17) March 2008 (18) February 2008 (19) January 2008 (20) December 2007 (13) November 2007 (18) October 2007 (10) September 2007 (15) August 2007 (15) July 2007 (20) June 2007 (16) May 2007 (17) April 2007 (16) March 2007 (17) February 2007 (16) January 2007 (21) December 2006 (17) November 2006 (17) October 2006 (13) September 2006 (11) August 2006 (11) July 2006 (16) June 2006 (21) May 2006 (16) April 2006 (17) March 2006 (19) February 2006 (18) January 2006 (23) December 2005 (30) November 2005 (17) October 2005 (24) September 2005 (21) August 2005 (32) July 2005 (30) June 2005 (24) May 2005 (30) April 2005 (36) March 2005 (45) February 2005 (30) January 2005 (36) December 2004 (31) November 2004 (27) October 2004 (33) September 2004 (42) August 2004 (23) July 2004 (26) June 2004 (25) May 2004 (27) April 2004 (24) March 2004 (38) February 2004 (2)

 Categories

 Categories Select Category Academia (103) Advice (21) Arts (20) arxiv (77) Big Picture (18) Biggest Ideas in the Universe (27) Blog (63) Entertainment (77) Environment (14) Food and Drink (16) Guest Post (48) Health (7) Higgs (46) Human Rights (34) Humanity (42) Humor (93) Internet (108) Math (22) Media (14) Miscellany (593) Music (40) News (8) Personal (120) Philosophy (122) Politics (98) Religion (120) Science (639) Science and Politics (58) Science and Society (120) Science and the Media (101) Space (10) Sports (17) Technology (34) Time (101) Travel (36) Women in Science (27) Words (168) World (34)

 Buy Stuff

 Something Deeply Hidden
 The Big Picture: On the Origins of Life, Meaning, and the Universe Itself
 The Particle at the End of the Universe: How the Hunt for the Higgs Boson Leads Us to the Edge of a New World
 From Eternity to Here: The Quest for the Ultimate Theory of Time
 Spacetime and Geometry: An Introduction to General Relativity
 The Higgs Boson and Beyond (The Great Courses)
 Mysteries of Modern Physics -- Time (The Great Courses)
 Dark Matter and Dark Energy (The Great Courses)

 All text copyright © Sean M. Carroll.

 Copyright © 2023 Sean Carroll | Site Designed by Digital Executrix
 Scroll to Top
Over at the twitter dot com website, there has been a briefly-trending topic #fav7films, discussing your favorite seven films. Part of the purpose of being on twitter is to one-up the competition, so I instead listed my #fav7equations. Slightly cleaned up, the equations I chose as my seven favorites are:
 
 
 
 
 
 
 
In order: Newton’s Second Law of motion, the Euler-Lagrange equation, Maxwell’s equations in terms of differential forms, Boltzmann’s definition of entropy, the metric for Minkowski spacetime (special relativity), Einstein’s equation for spacetime curvature (general relativity), and the Schrödinger equation of quantum mechanics. Feel free to Google them for more info, even if equations aren’t your thing. They represent a series of extraordinary insights in the development of physics, from the 1600’s to the present day.
Of course people chimed in with their own favorites, which is all in the spirit of the thing. But one misconception came up that is probably worth correcting: people don’t appreciate how important and all-encompassing the Schrödinger equation is.
I blame society. Or, more accurately, I blame how we teach quantum mechanics. Not that the standard treatment of the Schrödinger equation is fundamentally wrong (as other aspects of how we teach QM are), but that it’s incomplete. And sometimes people get brief introductions to things like the Dirac equation or the Klein-Gordon equation, and come away with the impression that they are somehow relativistic replacements for the Schrödinger equation, which they certainly are not. Dirac et al. may have originally wondered whether they were, but these days we certainly know better.
As I remarked in my post about emergent space, we human beings tend to do quantum mechanics by starting with some classical model, and then “quantizing” it. Nature doesn’t work that way, but we’re not as smart as Nature is. By a “classical model” we mean something that obeys the basic Newtonian paradigm: there is some kind of generalized “position” variable, and also a corresponding “momentum” variable (how fast the position variable is changing), which together obey some deterministic equations of motion that can be solved once we are given initial data. Those equations can be derived from a function called the Hamiltonian, which is basically the energy of the system as a function of positions and momenta; the results are Hamilton’s equations, which are essentially a slick version of Newton’s original .
There are various ways of taking such a setup and “quantizing” it, but one way is to take the position variable and consider all possible (normalized, complex-valued) functions of that variable. So instead of, for example, a single position coordinate x and its momentum p, quantum mechanics deals with wave functions ψ(x). That’s the thing that you square to get the probability of observing the system to be at the position x. (We can also transform the wave function to “momentum space,” and calculate the probabilities of observing the system to be at momentum p.) Just as positions and momenta obey Hamilton’s equations, the wave function obeys the Schrödinger equation,
 . 
Indeed, the that appears in the Schrödinger equation is just the quantum version of the Hamiltonian.
The problem is that, when we are first taught about the Schrödinger equation, it is usually in the context of a specific, very simple model: a single non-relativistic particle moving in a potential. In other words, we choose a particular kind of wave function, and a particular Hamiltonian. The corresponding version of the Schrödinger equation is
 . 
If you don’t dig much deeper into the essence of quantum mechanics, you could come away with the impression that this is “the” Schrödinger equation, rather than just “the non-relativistic Schrödinger equation for a single particle.” Which would be a shame.
What happens if we go beyond the world of non-relativistic quantum mechanics? Is the poor little Schrödinger equation still up to the task? Sure! All you need is the right set of wave functions and the right Hamiltonian. Every quantum system obeys a version of the Schrödinger equation; it’s completely general. In particular, there’s no problem talking about relativistic systems or field theories — just don’t use the non-relativistic version of the equation, obviously.
What about the Klein-Gordon and Dirac equations? These were, indeed, originally developed as “relativistic versions of the non-relativistic Schrödinger equation,” but that’s not what they ended up being useful for. (The story is told that Schrödinger himself invented the Klein-Gordon equation even before his non-relativistic version, but discarded it because it didn’t do the job for describing the hydrogen atom. As my old professor Sidney Coleman put it, “Schrödinger was no dummy. He knew about relativity.”)
The Klein-Gordon and Dirac equations are actually not quantum at all — they are classical field equations, just like Maxwell’s equations are for electromagnetism and Einstein’s equation is for the metric tensor of gravity. They aren’t usually taught that way, in part because (unlike E&amp;M and gravity) there aren’t any macroscopic classical fields in Nature that obey those equations. The KG equation governs relativistic scalar fields like the Higgs boson, while the Dirac equation governs spinor fields (spin-1/2 fermions) like the electron and neutrinos and quarks. In Nature, spinor fields are a little subtle, because they are anticommuting Grassmann variables rather than ordinary functions. But make no mistake; the Dirac equation fits perfectly comfortably into the standard Newtonian physical paradigm.
For fields like this, the role of “position” that for a single particle was played by the variable x is now played by an entire configuration of the field throughout space. For a scalar Klein-Gordon field, for example, that might be the values of the field φ(x) at every spatial location x. But otherwise the same story goes through as before. We construct a wave function by attaching a complex number to every possible value of the position variable; to emphasize that it’s a function of functions, we sometimes call it a “wave functional” and write it as a capital letter,
 . 
The absolute-value-squared of this wave functional tells you the probability that you will observe the field to have the value φ(x) at each point x in space. The functional obeys — you guessed it — a version of the Schrödinger equation, with the Hamiltonian being that of a relativistic scalar field. There are likewise versions of the Schrödinger equation for the electromagnetic field, for Dirac fields, for the whole Core Theory, and what have you.
So the Schrödinger equation is not simply a relic of the early days of quantum mechanics, when we didn’t know how to deal with much more than non-relativistic particles orbiting atomic nuclei. It is the foundational equation of quantum dynamics, and applies to every quantum system there is. (There are equivalent ways of doing quantum mechanics, of course, like the Heisenberg picture and the path-integral formulation, but they’re all basically equivalent.) You tell me what the quantum state of your system is, and what is its Hamiltonian, and I will plug into the Schrödinger equation to see how that state will evolve with time. And as far as we know, quantum mechanics is how the universe works. Which makes the Schrödinger equation arguably the most important equation in all of physics.
While we’re at it, people complained that the cosmological constant Λ didn’t appear in Einstein’s equation (6). Of course it does — it’s part of the energy-momentum tensor on the right-hand side. Again, Einstein didn’t necessarily think of it that way, but these days we know better. The whole thing that is great about physics is that we keep learning things; we don’t need to remain stuck with the first ideas that were handed down by the great minds of the past.
You Should Love (or at least respect) the Schrödinger Equation
https://www.preposterousuniverse.com/blog/2016/08/15/you-should-love-or-at-least-respect-the-schrodinger-equation/
https://blog.cupcakephysics.com/quantum%20mechanics/2015/08/16/the-heisenberg-equation-part-1.html
The Heisenberg Equation (Part 1)
2015-08-16
Cyrus Vandrevala
<div><div>
<h3>Introduction</h3>
<p>Most students of quantum mechanics are familiar with the <a href="http://scienceworld.wolfram.com/physics/SchroedingerEquation.html">Schrodinger equation</a>:</p><p>
\[\begin{equation}
i\hbar \frac{d \psi (t)}{dt} = H \psi (t)
\end{equation}\]
</p><p>It is the starting point for a huge number of derivations and solutions in the quantum world. Arguably, it is the most important equation in non-relativistic quantum mechanics. However, the Schrodinger equation has an often neglected twin brother - the Heisenberg equation. If we simply shift our focus from <a href="https://en.wikipedia.org/wiki/Wave_function">wavefunctions</a> to <a href="https://en.wikipedia.org/wiki/Operator_(physics)">operators</a>, we find that the quantum world is much deeper than we once thought.</p>
<p>Let’s start off with the simple example of the time evolution of <a href="https://en.wikipedia.org/wiki/Expectation_value_(quantum_mechanics)">expectation values</a>. We will use that as a stepping stone to derive the Heisenberg equation.</p>
<p></p>
<h3>The Time Evolution of an Expectation Value</h3>
<p>Suppose I have some operator \(Q\) with an expectation value given by:</p><p>
\[\begin{equation}
\left \langle Q \right \rangle = \left \langle \psi (t) \right | Q \left | \psi (t) \right \rangle \equiv \left \langle \psi \right | Q \left | \psi \right \rangle
\end{equation}\]
</p><p>I want to calculate how \(\left \langle Q \right \rangle\) evolves as a function of time. To start off I can take a time derivative of the expression above and expand it using the <a href="https://en.wikipedia.org/wiki/Product_rule">product rule</a>.</p><p>
\[\begin{align}
\frac{d}{dt} \left \langle Q \right \rangle &amp;= \frac{d}{dt} \left [ \left \langle \psi \right | Q \left | \psi \right \rangle \right ]\\[0.1cm]
&amp;= \left \langle \frac{d \psi}{dt} \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \frac{d \psi}{dt} \right \rangle
\end{align}\]
</p><p>The Schrodinger equation tells us how the time derivative of the wavefunction is related to the Hamiltonian of the system. Thus, we can substitute the expression for the Hamiltonian in for the time derivatives. Remember, we do have to take into account the fact that the bra and ket terms differ by a minus sign:</p><p>
\[\begin{equation}
\left | \frac{d\psi}{dt} \right \rangle = \left | \frac{1}{i\hbar} H \psi \right \rangle
\end{equation}\]
\[\begin{equation}
\left \langle \frac{d\psi}{dt} \right | = \left \langle -\frac{1}{i\hbar} H \psi \right |
\end{equation}\]
</p><p>Then:</p><p>
\[\begin{align}
\frac{d}{dt} \left \langle Q \right \rangle &amp;= \left \langle \frac{d \psi}{dt} \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \frac{d \psi}{dt} \right \rangle\\[0.1cm]
&amp;= \left \langle \left ( -\frac{1}{i\hbar}H\psi \right ) \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \left ( \frac{1}{i\hbar}H\psi \right ) \right \rangle\\[0.1cm]
&amp;= \left \langle \left ( -\frac{1}{i\hbar}H\psi \right ) \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \left ( \frac{1}{i\hbar}H\psi \right ) \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle
\end{align}\]
</p><p>Factoring out the \(-(i\hbar)^{-1}\) term yields:</p><p>
\[\begin{align}
\frac{d}{dt} \left \langle Q \right \rangle &amp;= -\frac{1}{i\hbar} \left [ \left \langle H \psi \right | Q \left | \psi \right \rangle - \left \langle \psi \right | Q \left | H \psi \right \rangle \right ] + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left [ \left \langle \psi \right | HQ \left | \psi \right \rangle - \left \langle \psi \right | QH \left | \psi \right \rangle \right ] + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left \langle \psi \right | HQ - QH \left | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left \langle \psi \right | [H,Q] \left | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
\end{align}\]
</p><p>Now we can write out the final expression for the time evolution of the expectation value:</p><p>
\[\begin{equation}
\frac{d\left \langle Q \right \rangle}{dt} = \frac{i}{\hbar} \left \langle [H,Q] \right \rangle + \left \langle \frac{dQ}{dt} \right \rangle
\end{equation}\]
</p><p>This is a neat result! It gives a simple expression for the time evolution of the expectation value of \(Q\).</p>
<h3>The Heisenberg Equation</h3>
<p>Let’s take a step back and approach quantum mechanics in a slightly different way. In the last section we assumed that the operators were constant in time and the wavefunction had some time dependence. Now, we will assume that the wavefunction is constant in time and move the time dependence to the operators.</p>
<p>The wavefunction of a particle at some final time \(t\) is equal to the wavefunction of the particle at some initial time \(t_o\) multiplied by a <a href="https://en.wikipedia.org/wiki/Unitary_operator">unitary operator</a>.</p><p>
\[\begin{equation}
\psi (t) = U(t,t_o) \psi (t_o)
\end{equation}\]
</p><p>In the expression above, \(\psi(t_o)\) is a constant wavefunction and the unitary operator \(U\) carries all of the time dependence of the system. We can substitute the expression for \(\psi(t)\) into the Schrodinger equation and solve for \(U\):</p><p>
\[\begin{equation}
i\hbar \frac{d\psi(t)}{dt} = H \psi(t)
\end{equation}\]
\[\begin{equation}
i\hbar \frac{d}{dt} \left [ U(t,t_o) \psi (t_o) \right ] = H U(t,t_o) \psi (t_o)
\end{equation}\]
</p><p>The unitary operator \(U\) is a function of time \(t\). However, the wavefunction \(\psi(t_o)\) is not a function of \(t\). Thus, we can pull \(\psi(t_o)\) out of the time derivative.</p><p>
\[\begin{equation}
i\hbar \frac{dU(t,t_o)}{dt} \psi (t_o) = H U(t,t_o) \psi (t_o)
\end{equation}\]
</p><p>This expression needs to be true for any initial condition \(\psi(t_o)\). Thus, we will cancel \(\psi(t_o)\) on each side of the expression.</p><p>
\[\begin{equation}
i\hbar \frac{dU(t,t_o)}{dt} = H U(t,t_o)
\end{equation}\]
</p><p>Just to simplify our notation, we will let \(U(t,t_o) \equiv U\).</p><p>
\[\begin{equation}
i\hbar \frac{dU}{dt} = HU
\end{equation}\]
</p><p>That is pretty neat. The expression for \(U\) above is almost identical to the expression for \(\psi(t)\) in the previous section. Let’s solve for the expectation value of some operator \(Q\) like we did in the previous section. Starting with the definition of an expectation value, we get:</p><p>
\[\begin{align}
\left \langle Q \right \rangle &amp;= \left \langle \psi (t) \right | Q \left | \psi (t) \right \rangle\\[0.1cm]
&amp;= \left \langle \psi (t_o) U^\dagger \right | Q \left | U \psi (t_o) \right \rangle\\[0.1cm]
&amp;= \left \langle \psi (t_o) \right | U^\dagger Q U \left | \psi (t_o) \right \rangle\\[0.1cm]
\end{align}\]
</p><p>We can rewrite the time-dependent operator in terms of the time-independent operator and a unitary operator. To keep our notation clear, I will call \(Q_H\) the time-dependent operator and \(Q_S \equiv Q\) the time-independent operator. Those of you who have taken an advanced course in quantum mechanics might recognize these as the Heisenberg and Schrodinger pictures of the operator.</p><p>
\[\begin{equation}
Q_H = U^\dagger Q_S U \equiv U^\dagger Q U
\end{equation}\]
</p><p>We can now solve for the time evolution of the Heisenberg operator.</p><p>
\[\begin{align}
\frac{dQ_H}{dt} &amp;= \frac{d}{dt} \left [ U^\dagger Q U \right ]\\[0.1cm]
&amp;= \frac{d U^\dagger}{dt} QU + U^\dagger \frac{dQ}{dt} U + U^\dagger Q \frac{d U}{dt}
\end{align}\]
</p><p>Similar to section one, we can expand \(dU/dt\) using the Hamiltonian.</p><p>
\[\begin{equation}
\frac{dU}{dt} = \frac{1}{i\hbar} HU
\end{equation}\]
\[\begin{equation}
\frac{dU^\dagger}{dt} = -\frac{1}{i\hbar} U^\dagger H
\end{equation}\]
</p><p>Then:</p><p>
\[\begin{align}
\frac{dQ_H}{dt} &amp;= \left ( -\frac{1}{i\hbar} U^\dagger H \right ) QU + U^\dagger \frac{dQ}{dt} U + U^\dagger Q \left ( \frac{1}{i\hbar} HU \right )\\[0.1cm]
&amp;= -\frac{1}{i\hbar} U^\dagger HQU + \frac{1}{i\hbar} U^\dagger Q HU + U^\dagger \frac{dQ}{dt} U
\end{align}\]
</p><p>Recall that \(U^\dagger U = U U^\dagger = 1\) for a unitary operator. Then:</p><p>
\[\begin{align}
\frac{dQ_H}{dt} &amp;= -\frac{1}{i\hbar} U^\dagger HQU + \frac{1}{i\hbar} U^\dagger Q HU + U^\dagger \frac{dQ}{dt} U\\[0.1cm]
&amp;= -\frac{1}{i\hbar} U^\dagger HU U^\dagger QU + \frac{1}{i\hbar} U^\dagger QU U^\dagger HU + U^\dagger \frac{dQ}{dt} U\\[0.1cm]
&amp;= -\frac{1}{i\hbar} H Q_H + \frac{1}{i\hbar} Q_H H + U^\dagger \frac{dQ}{dt} U
\end{align}\]
</p><p>Factoring out the \(-(i\hbar)^{-1}\) term yields:</p><p>
\[\begin{align}
\frac{dQ_H}{dt} &amp;= -\frac{1}{i\hbar} H Q_H + \frac{1}{i\hbar} Q_H H + U^\dagger \frac{dQ}{dt} U\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left [ H Q_H - Q_H H \right ] + U^\dagger \frac{dQ}{dt} U
\end{align}\]
\[\begin{equation}
\frac{dQ_H}{dt} = \frac{i}{\hbar} \left [H, Q_H \right ] + \left ( \frac{dQ}{dt} \right )_H
\end{equation}\]
</p><h3>Aren’t Those Answers Exactly the Same?</h3>
<p></p>
<p>No, they aren’t :)</p>
<p>The final expression in the first section gives the time derivative of the expectation value of an operator. The final expression in the second section gives the time derivative of an operator in the Heisenberg picture (i.e. the model of quantum mechanics where the wavefunctions are constant and the operators evolve in time). They describe two different things under two different models of quantum mechanics. However, the final expressions are almost identical in form, alluding to the fact that these two models of quantum mechanics are intimately related.</p>
<p>What we should take away from this is that the Schrodinger equation is not the end-all equation of quantum mechanics. Sometimes, the Heisenberg equation can yield very useful insights into the properties of a system. Additionally, any calculations done using the Schrodinger equation are intimately related to the calculations done using the Heisenberg equation due to the similarity of the expressions calculated above.</p>
<p>Next week, we will solve some specific examples using the Heisenberg equation and see how the solutions relate to those of the Schrodinger equation.</p>
</div></div>||||I|||| cupcake physics

 * 
 August 16th, 2015

 The Heisenberg Equation (Part 1)

 Introduction

 Most students of quantum mechanics are familiar with the Schrodinger equation:

 \[\begin{equation} i\hbar \frac{d \psi (t)}{dt} = H \psi (t) \end{equation}\]

 It is the starting point for a huge number of derivations and solutions in the quantum world. Arguably, it is the most important equation in non-relativistic quantum mechanics. However, the Schrodinger equation has an often neglected twin brother - the Heisenberg equation. If we simply shift our focus from wavefunctions to operators, we find that the quantum world is much deeper than we once thought.

 Let’s start off with the simple example of the time evolution of expectation values. We will use that as a stepping stone to derive the Heisenberg equation.

 The Time Evolution of an Expectation Value

 Suppose I have some operator \(Q\) with an expectation value given by:

 \[\begin{equation} \left \langle Q \right \rangle = \left \langle \psi (t) \right | Q \left | \psi (t) \right \rangle \equiv \left \langle \psi \right | Q \left | \psi \right \rangle \end{equation}\]

 I want to calculate how \(\left \langle Q \right \rangle\) evolves as a function of time. To start off I can take a time derivative of the expression above and expand it using the product rule.

 \[\begin{align} \frac{d}{dt} \left \langle Q \right \rangle &= \frac{d}{dt} \left [ \left \langle \psi \right | Q \left | \psi \right \rangle \right ]\\[0.1cm] &= \left \langle \frac{d \psi}{dt} \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \frac{d \psi}{dt} \right \rangle \end{align}\]

 The Schrodinger equation tells us how the time derivative of the wavefunction is related to the Hamiltonian of the system. Thus, we can substitute the expression for the Hamiltonian in for the time derivatives. Remember, we do have to take into account the fact that the bra and ket terms differ by a minus sign:

 \[\begin{equation} \left | \frac{d\psi}{dt} \right \rangle = \left | \frac{1}{i\hbar} H \psi \right \rangle \end{equation}\] \[\begin{equation} \left \langle \frac{d\psi}{dt} \right | = \left \langle -\frac{1}{i\hbar} H \psi \right | \end{equation}\]

 Then:

 \[\begin{align} \frac{d}{dt} \left \langle Q \right \rangle &= \left \langle \frac{d \psi}{dt} \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \frac{d \psi}{dt} \right \rangle\\[0.1cm] &= \left \langle \left ( -\frac{1}{i\hbar}H\psi \right ) \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \left ( \frac{1}{i\hbar}H\psi \right ) \right \rangle\\[0.1cm] &= \left \langle \left ( -\frac{1}{i\hbar}H\psi \right ) \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \left ( \frac{1}{i\hbar}H\psi \right ) \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle \end{align}\]

 Factoring out the \(-(i\hbar)^{-1}\) term yields:

 \[\begin{align} \frac{d}{dt} \left \langle Q \right \rangle &= -\frac{1}{i\hbar} \left [ \left \langle H \psi \right | Q \left | \psi \right \rangle - \left \langle \psi \right | Q \left | H \psi \right \rangle \right ] + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm] &= -\frac{1}{i\hbar} \left [ \left \langle \psi \right | HQ \left | \psi \right \rangle - \left \langle \psi \right | QH \left | \psi \right \rangle \right ] + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm] &= -\frac{1}{i\hbar} \left \langle \psi \right | HQ - QH \left | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm] &= -\frac{1}{i\hbar} \left \langle \psi \right | [H,Q] \left | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm] \end{align}\]

 Now we can write out the final expression for the time evolution of the expectation value:

 \[\begin{equation} \frac{d\left \langle Q \right \rangle}{dt} = \frac{i}{\hbar} \left \langle [H,Q] \right \rangle + \left \langle \frac{dQ}{dt} \right \rangle \end{equation}\]

 This is a neat result! It gives a simple expression for the time evolution of the expectation value of \(Q\).

 The Heisenberg Equation

 Let’s take a step back and approach quantum mechanics in a slightly different way. In the last section we assumed that the operators were constant in time and the wavefunction had some time dependence. Now, we will assume that the wavefunction is constant in time and move the time dependence to the operators.

 The wavefunction of a particle at some final time \(t\) is equal to the wavefunction of the particle at some initial time \(t_o\) multiplied by a unitary operator.

 \[\begin{equation} \psi (t) = U(t,t_o) \psi (t_o) \end{equation}\]

 In the expression above, \(\psi(t_o)\) is a constant wavefunction and the unitary operator \(U\) carries all of the time dependence of the system. We can substitute the expression for \(\psi(t)\) into the Schrodinger equation and solve for \(U\):

 \[\begin{equation} i\hbar \frac{d\psi(t)}{dt} = H \psi(t) \end{equation}\] \[\begin{equation} i\hbar \frac{d}{dt} \left [ U(t,t_o) \psi (t_o) \right ] = H U(t,t_o) \psi (t_o) \end{equation}\]

 The unitary operator \(U\) is a function of time \(t\). However, the wavefunction \(\psi(t_o)\) is not a function of \(t\). Thus, we can pull \(\psi(t_o)\) out of the time derivative.

 \[\begin{equation} i\hbar \frac{dU(t,t_o)}{dt} \psi (t_o) = H U(t,t_o) \psi (t_o) \end{equation}\]

 This expression needs to be true for any initial condition \(\psi(t_o)\). Thus, we will cancel \(\psi(t_o)\) on each side of the expression.

 \[\begin{equation} i\hbar \frac{dU(t,t_o)}{dt} = H U(t,t_o) \end{equation}\]

 Just to simplify our notation, we will let \(U(t,t_o) \equiv U\).

 \[\begin{equation} i\hbar \frac{dU}{dt} = HU \end{equation}\]

 That is pretty neat. The expression for \(U\) above is almost identical to the expression for \(\psi(t)\) in the previous section. Let’s solve for the expectation value of some operator \(Q\) like we did in the previous section. Starting with the definition of an expectation value, we get:

 \[\begin{align} \left \langle Q \right \rangle &= \left \langle \psi (t) \right | Q \left | \psi (t) \right \rangle\\[0.1cm] &= \left \langle \psi (t_o) U^\dagger \right | Q \left | U \psi (t_o) \right \rangle\\[0.1cm] &= \left \langle \psi (t_o) \right | U^\dagger Q U \left | \psi (t_o) \right \rangle\\[0.1cm] \end{align}\]

 We can rewrite the time-dependent operator in terms of the time-independent operator and a unitary operator. To keep our notation clear, I will call \(Q_H\) the time-dependent operator and \(Q_S \equiv Q\) the time-independent operator. Those of you who have taken an advanced course in quantum mechanics might recognize these as the Heisenberg and Schrodinger pictures of the operator.

 \[\begin{equation} Q_H = U^\dagger Q_S U \equiv U^\dagger Q U \end{equation}\]

 We can now solve for the time evolution of the Heisenberg operator.

 \[\begin{align} \frac{dQ_H}{dt} &= \frac{d}{dt} \left [ U^\dagger Q U \right ]\\[0.1cm] &= \frac{d U^\dagger}{dt} QU + U^\dagger \frac{dQ}{dt} U + U^\dagger Q \frac{d U}{dt} \end{align}\]

 Similar to section one, we can expand \(dU/dt\) using the Hamiltonian.

 \[\begin{equation} \frac{dU}{dt} = \frac{1}{i\hbar} HU \end{equation}\] \[\begin{equation} \frac{dU^\dagger}{dt} = -\frac{1}{i\hbar} U^\dagger H \end{equation}\]

 Then:

 \[\begin{align} \frac{dQ_H}{dt} &= \left ( -\frac{1}{i\hbar} U^\dagger H \right ) QU + U^\dagger \frac{dQ}{dt} U + U^\dagger Q \left ( \frac{1}{i\hbar} HU \right )\\[0.1cm] &= -\frac{1}{i\hbar} U^\dagger HQU + \frac{1}{i\hbar} U^\dagger Q HU + U^\dagger \frac{dQ}{dt} U \end{align}\]

 Recall that \(U^\dagger U = U U^\dagger = 1\) for a unitary operator. Then:

 \[\begin{align} \frac{dQ_H}{dt} &= -\frac{1}{i\hbar} U^\dagger HQU + \frac{1}{i\hbar} U^\dagger Q HU + U^\dagger \frac{dQ}{dt} U\\[0.1cm] &= -\frac{1}{i\hbar} U^\dagger HU U^\dagger QU + \frac{1}{i\hbar} U^\dagger QU U^\dagger HU + U^\dagger \frac{dQ}{dt} U\\[0.1cm] &= -\frac{1}{i\hbar} H Q_H + \frac{1}{i\hbar} Q_H H + U^\dagger \frac{dQ}{dt} U \end{align}\]

 Factoring out the \(-(i\hbar)^{-1}\) term yields:

 \[\begin{align} \frac{dQ_H}{dt} &= -\frac{1}{i\hbar} H Q_H + \frac{1}{i\hbar} Q_H H + U^\dagger \frac{dQ}{dt} U\\[0.1cm] &= -\frac{1}{i\hbar} \left [ H Q_H - Q_H H \right ] + U^\dagger \frac{dQ}{dt} U \end{align}\] \[\begin{equation} \frac{dQ_H}{dt} = \frac{i}{\hbar} \left [H, Q_H \right ] + \left ( \frac{dQ}{dt} \right )_H \end{equation}\]

 Aren’t Those Answers Exactly the Same?

 No, they aren’t :)

 The final expression in the first section gives the time derivative of the expectation value of an operator. The final expression in the second section gives the time derivative of an operator in the Heisenberg picture (i.e. the model of quantum mechanics where the wavefunctions are constant and the operators evolve in time). They describe two different things under two different models of quantum mechanics. However, the final expressions are almost identical in form, alluding to the fact that these two models of quantum mechanics are intimately related.

 What we should take away from this is that the Schrodinger equation is not the end-all equation of quantum mechanics. Sometimes, the Heisenberg equation can yield very useful insights into the properties of a system. Additionally, any calculations done using the Schrodinger equation are intimately related to the calculations done using the Heisenberg equation due to the similarity of the expressions calculated above.

 Next week, we will solve some specific examples using the Heisenberg equation and see how the solutions relate to those of the Schrodinger equation.

 Please enable JavaScript to view the comments powered by Disqus.
 * Categories
 * Tags
 * About
 * 
 * 

 Cupcake Physics by Cyrus Vandrevala | All Rights Reserved

Introduction
Most students of quantum mechanics are familiar with the Schrodinger equation: 
\[\begin{equation}
i\hbar \frac{d \psi (t)}{dt} = H \psi (t)
\end{equation}\]
 It is the starting point for a huge number of derivations and solutions in the quantum world. Arguably, it is the most important equation in non-relativistic quantum mechanics. However, the Schrodinger equation has an often neglected twin brother - the Heisenberg equation. If we simply shift our focus from wavefunctions to operators, we find that the quantum world is much deeper than we once thought.
Let’s start off with the simple example of the time evolution of expectation values. We will use that as a stepping stone to derive the Heisenberg equation.
 
The Time Evolution of an Expectation Value
Suppose I have some operator \(Q\) with an expectation value given by: 
\[\begin{equation}
\left \langle Q \right \rangle = \left \langle \psi (t) \right | Q \left | \psi (t) \right \rangle \equiv \left \langle \psi \right | Q \left | \psi \right \rangle
\end{equation}\]
 I want to calculate how \(\left \langle Q \right \rangle\) evolves as a function of time. To start off I can take a time derivative of the expression above and expand it using the product rule. 
\[\begin{align}
\frac{d}{dt} \left \langle Q \right \rangle &amp;= \frac{d}{dt} \left [ \left \langle \psi \right | Q \left | \psi \right \rangle \right ]\\[0.1cm]
&amp;= \left \langle \frac{d \psi}{dt} \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \frac{d \psi}{dt} \right \rangle
\end{align}\]
 The Schrodinger equation tells us how the time derivative of the wavefunction is related to the Hamiltonian of the system. Thus, we can substitute the expression for the Hamiltonian in for the time derivatives. Remember, we do have to take into account the fact that the bra and ket terms differ by a minus sign: 
\[\begin{equation}
\left | \frac{d\psi}{dt} \right \rangle = \left | \frac{1}{i\hbar} H \psi \right \rangle
\end{equation}\]
\[\begin{equation}
\left \langle \frac{d\psi}{dt} \right | = \left \langle -\frac{1}{i\hbar} H \psi \right |
\end{equation}\]
 Then: 
\[\begin{align}
\frac{d}{dt} \left \langle Q \right \rangle &amp;= \left \langle \frac{d \psi}{dt} \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \frac{d \psi}{dt} \right \rangle\\[0.1cm]
&amp;= \left \langle \left ( -\frac{1}{i\hbar}H\psi \right ) \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \left ( \frac{1}{i\hbar}H\psi \right ) \right \rangle\\[0.1cm]
&amp;= \left \langle \left ( -\frac{1}{i\hbar}H\psi \right ) \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \psi \right \rangle + \left \langle \psi \bigg | \hspace{0.5mm} Q \hspace{0.5mm} \bigg | \left ( \frac{1}{i\hbar}H\psi \right ) \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle
\end{align}\]
 Factoring out the \(-(i\hbar)^{-1}\) term yields: 
\[\begin{align}
\frac{d}{dt} \left \langle Q \right \rangle &amp;= -\frac{1}{i\hbar} \left [ \left \langle H \psi \right | Q \left | \psi \right \rangle - \left \langle \psi \right | Q \left | H \psi \right \rangle \right ] + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left [ \left \langle \psi \right | HQ \left | \psi \right \rangle - \left \langle \psi \right | QH \left | \psi \right \rangle \right ] + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left \langle \psi \right | HQ - QH \left | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left \langle \psi \right | [H,Q] \left | \psi \right \rangle + \left \langle \psi \bigg | \frac{dQ}{dt} \bigg | \psi \right \rangle\\[0.1cm]
\end{align}\]
 Now we can write out the final expression for the time evolution of the expectation value: 
\[\begin{equation}
\frac{d\left \langle Q \right \rangle}{dt} = \frac{i}{\hbar} \left \langle [H,Q] \right \rangle + \left \langle \frac{dQ}{dt} \right \rangle
\end{equation}\]
 This is a neat result! It gives a simple expression for the time evolution of the expectation value of \(Q\).
The Heisenberg Equation
Let’s take a step back and approach quantum mechanics in a slightly different way. In the last section we assumed that the operators were constant in time and the wavefunction had some time dependence. Now, we will assume that the wavefunction is constant in time and move the time dependence to the operators.
The wavefunction of a particle at some final time \(t\) is equal to the wavefunction of the particle at some initial time \(t_o\) multiplied by a unitary operator. 
\[\begin{equation}
\psi (t) = U(t,t_o) \psi (t_o)
\end{equation}\]
 In the expression above, \(\psi(t_o)\) is a constant wavefunction and the unitary operator \(U\) carries all of the time dependence of the system. We can substitute the expression for \(\psi(t)\) into the Schrodinger equation and solve for \(U\): 
\[\begin{equation}
i\hbar \frac{d\psi(t)}{dt} = H \psi(t)
\end{equation}\]
\[\begin{equation}
i\hbar \frac{d}{dt} \left [ U(t,t_o) \psi (t_o) \right ] = H U(t,t_o) \psi (t_o)
\end{equation}\]
 The unitary operator \(U\) is a function of time \(t\). However, the wavefunction \(\psi(t_o)\) is not a function of \(t\). Thus, we can pull \(\psi(t_o)\) out of the time derivative. 
\[\begin{equation}
i\hbar \frac{dU(t,t_o)}{dt} \psi (t_o) = H U(t,t_o) \psi (t_o)
\end{equation}\]
 This expression needs to be true for any initial condition \(\psi(t_o)\). Thus, we will cancel \(\psi(t_o)\) on each side of the expression. 
\[\begin{equation}
i\hbar \frac{dU(t,t_o)}{dt} = H U(t,t_o)
\end{equation}\]
 Just to simplify our notation, we will let \(U(t,t_o) \equiv U\). 
\[\begin{equation}
i\hbar \frac{dU}{dt} = HU
\end{equation}\]
 That is pretty neat. The expression for \(U\) above is almost identical to the expression for \(\psi(t)\) in the previous section. Let’s solve for the expectation value of some operator \(Q\) like we did in the previous section. Starting with the definition of an expectation value, we get: 
\[\begin{align}
\left \langle Q \right \rangle &amp;= \left \langle \psi (t) \right | Q \left | \psi (t) \right \rangle\\[0.1cm]
&amp;= \left \langle \psi (t_o) U^\dagger \right | Q \left | U \psi (t_o) \right \rangle\\[0.1cm]
&amp;= \left \langle \psi (t_o) \right | U^\dagger Q U \left | \psi (t_o) \right \rangle\\[0.1cm]
\end{align}\]
 We can rewrite the time-dependent operator in terms of the time-independent operator and a unitary operator. To keep our notation clear, I will call \(Q_H\) the time-dependent operator and \(Q_S \equiv Q\) the time-independent operator. Those of you who have taken an advanced course in quantum mechanics might recognize these as the Heisenberg and Schrodinger pictures of the operator. 
\[\begin{equation}
Q_H = U^\dagger Q_S U \equiv U^\dagger Q U
\end{equation}\]
 We can now solve for the time evolution of the Heisenberg operator. 
\[\begin{align}
\frac{dQ_H}{dt} &amp;= \frac{d}{dt} \left [ U^\dagger Q U \right ]\\[0.1cm]
&amp;= \frac{d U^\dagger}{dt} QU + U^\dagger \frac{dQ}{dt} U + U^\dagger Q \frac{d U}{dt}
\end{align}\]
 Similar to section one, we can expand \(dU/dt\) using the Hamiltonian. 
\[\begin{equation}
\frac{dU}{dt} = \frac{1}{i\hbar} HU
\end{equation}\]
\[\begin{equation}
\frac{dU^\dagger}{dt} = -\frac{1}{i\hbar} U^\dagger H
\end{equation}\]
 Then: 
\[\begin{align}
\frac{dQ_H}{dt} &amp;= \left ( -\frac{1}{i\hbar} U^\dagger H \right ) QU + U^\dagger \frac{dQ}{dt} U + U^\dagger Q \left ( \frac{1}{i\hbar} HU \right )\\[0.1cm]
&amp;= -\frac{1}{i\hbar} U^\dagger HQU + \frac{1}{i\hbar} U^\dagger Q HU + U^\dagger \frac{dQ}{dt} U
\end{align}\]
 Recall that \(U^\dagger U = U U^\dagger = 1\) for a unitary operator. Then: 
\[\begin{align}
\frac{dQ_H}{dt} &amp;= -\frac{1}{i\hbar} U^\dagger HQU + \frac{1}{i\hbar} U^\dagger Q HU + U^\dagger \frac{dQ}{dt} U\\[0.1cm]
&amp;= -\frac{1}{i\hbar} U^\dagger HU U^\dagger QU + \frac{1}{i\hbar} U^\dagger QU U^\dagger HU + U^\dagger \frac{dQ}{dt} U\\[0.1cm]
&amp;= -\frac{1}{i\hbar} H Q_H + \frac{1}{i\hbar} Q_H H + U^\dagger \frac{dQ}{dt} U
\end{align}\]
 Factoring out the \(-(i\hbar)^{-1}\) term yields: 
\[\begin{align}
\frac{dQ_H}{dt} &amp;= -\frac{1}{i\hbar} H Q_H + \frac{1}{i\hbar} Q_H H + U^\dagger \frac{dQ}{dt} U\\[0.1cm]
&amp;= -\frac{1}{i\hbar} \left [ H Q_H - Q_H H \right ] + U^\dagger \frac{dQ}{dt} U
\end{align}\]
\[\begin{equation}
\frac{dQ_H}{dt} = \frac{i}{\hbar} \left [H, Q_H \right ] + \left ( \frac{dQ}{dt} \right )_H
\end{equation}\]
 Aren’t Those Answers Exactly the Same?
 
No, they aren’t :)
The final expression in the first section gives the time derivative of the expectation value of an operator. The final expression in the second section gives the time derivative of an operator in the Heisenberg picture (i.e. the model of quantum mechanics where the wavefunctions are constant and the operators evolve in time). They describe two different things under two different models of quantum mechanics. However, the final expressions are almost identical in form, alluding to the fact that these two models of quantum mechanics are intimately related.
What we should take away from this is that the Schrodinger equation is not the end-all equation of quantum mechanics. Sometimes, the Heisenberg equation can yield very useful insights into the properties of a system. Additionally, any calculations done using the Schrodinger equation are intimately related to the calculations done using the Heisenberg equation due to the similarity of the expressions calculated above.
Next week, we will solve some specific examples using the Heisenberg equation and see how the solutions relate to those of the Schrodinger equation.
The Heisenberg Equation (Part 1)
https://blog.cupcakephysics.com/quantum%20mechanics/2015/08/16/the-heisenberg-equation-part-1.html