[{"data":1,"prerenderedAt":1586},["ShallowReactive",2],{"blog-post-quantum-foundations\u002Fmatrices":3,"sibling-dives-quantum-foundations\u002Fmatrices":148,"learn-track-quantum-foundations\u002Fmatrices":149},{"id":4,"title":5,"authors":6,"body":8,"breadcrumb":115,"builders":119,"byline":120,"challenge":123,"courseAuthor":123,"courseLead":123,"dek":124,"description":124,"draft":125,"extension":126,"eyebrow":123,"finish":123,"fork":123,"hero":127,"heroAlt":123,"heroCta":123,"heroImage":123,"kind":129,"lessonCount":130,"meta":131,"navigation":132,"newsItems":123,"next":133,"ogImage":123,"order":137,"outcomes":123,"path":138,"publishDate":139,"readingTime":140,"related":141,"relatedProjects":123,"seo":142,"stem":144,"tags":145,"track":146,"trackName":118,"__hash__":147},"blog\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fmatrices.md","Matrices",[7],"stewart-smith",{"type":9,"value":10,"toc":107},"minimark",[11,20,25,34,37,41,49,53,64,84,88],[12,13,14,15,19],"p",{},"This quick review of matrices will prime you to learn what qubits actually represent, including a concrete, non-",[16,17,18],"em",{},"woo-woo"," definition of superposition. Let’s get started.",[21,22,24],"h2",{"id":23},"grid-of-numbers","Grid of numbers",[12,26,27,28,33],{},"A ",[29,30,32],"a",{"href":31},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FMatrix_(mathematics)","matrix"," is just a grid of numbers; rows and columns containing values. Matrices can be of any size. Here’s an example of a 3×2 matrix. It is 3 columns wide and 2 rows tall, containing the values 1 through 6.",[12,35,36],{},"When describing the dimensions of a matrix we always specify the number of rows first, then the number of columns. The above is an example of a 3×2 matrix, while below is a matrix containing similar data, but in a 2×3 configuration.",[21,38,40],{"id":39},"order-matters","Order matters",[12,42,43,44,48],{},"For our purposes, we’ll express our matrices in ",[29,45,47],{"href":46},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FRow-_and_column-major_order","row-major order",". This means we read the values just as they are ordered above, starting with the top-most row, reading values from left to right, then proceeding to the next row down and repeating that process. Our choice of row-major order makes reading and writing matrix values more akin to reading and writing in English; easier to type and program here.",[21,50,52],{"id":51},"vectors-are-slices","Vectors are slices",[12,54,55,56,59,60,63],{},"While a matrix is a two-dimensional ",[16,57,58],{},"grid"," of numbers, a vector is more like a ",[16,61,62],{},"slice"," of numbers, such as a “skinny” matrix that is only one column wide, or a “flat” matrix that is only one row high. Let’s look at some examples of matrices that are simultaneously vectors.",[12,65,66,67,70,71,74,75,78,79,83],{},"While the above 2×2 matrix is not a vector, you could say that it ",[16,68,69],{},"contains"," vectors: Two ",[16,72,73],{},"column"," vectors or two ",[16,76,77],{},"row"," vectors. Because vectors are just a type of matrix we can add them, multiply them, and so on, just like any other matrix. Vectors will play a prominent role in defining ",[29,80,82],{"href":81},"\u002Flearn\u002Fquantum-foundations\u002Fqubits","Qubits"," and expressing the state of a quantum circuit.",[21,85,87],{"id":86},"complex-numbers","Complex numbers",[12,89,90,91,95,96,99,100,102,103,106],{},"In addition to storing regular numbers, matrices can contain ",[29,92,94],{"href":93},"\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers","complex numbers",". This is both useful and ",[16,97,98],{},"necessary",": ",[29,101,82],{"href":81}," are really just a pair of complex numbers that we store in a 1×2 matrix. So, yes, the example matrices above are each ",[16,104,105],{},"larger"," than a qubit!",{"title":108,"searchDepth":109,"depth":109,"links":110},"",2,[111,112,113,114],{"id":23,"depth":109,"text":24},{"id":39,"depth":109,"text":40},{"id":51,"depth":109,"text":52},{"id":86,"depth":109,"text":87},[116,117,118,5],"Qollab","Learn","Quantum foundations",[],{"username":7,"name":121,"role":122,"avatar":108},"Stewart Smith","Creative technologist",null,"Matrices are the mathematical building blocks for quantum bits, quantum gates, and quantum circuits.",false,"md",{"image":128,"alt":5},"\u002F_content\u002Fimages\u002Fmatrices\u002Fhero.webp","lesson",5,{},true,{"slug":134,"title":135,"desc":136},"\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fqubits","4 · Qubits (quantum bits)","Like bits in classical computing, qubits are the fundamental containers for storing value in a quantum circuit. These stored values can be altered…",3,"\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fmatrices","2025-12-08","4 min read",[],{"title":143,"description":124},"Matrices · Quantum foundations","blog\u002Flearn\u002Fquantum-foundations\u002Fmatrices",[],"quantum-foundations","igq53qzMMNKclGgfZBiX1sYPhHgDco44qyZnX1Uss7Y",[],[150,474,583,650,1154],{"id":151,"title":152,"authors":153,"body":154,"breadcrumb":453,"builders":454,"byline":455,"challenge":123,"courseAuthor":123,"courseLead":123,"dek":456,"description":457,"draft":125,"extension":126,"eyebrow":123,"finish":123,"fork":123,"hero":458,"heroAlt":123,"heroCta":123,"heroImage":123,"kind":129,"lessonCount":130,"meta":460,"navigation":132,"newsItems":123,"next":461,"ogImage":123,"order":465,"outcomes":123,"path":466,"publishDate":139,"readingTime":467,"related":468,"relatedProjects":123,"seo":469,"stem":471,"tags":472,"track":146,"trackName":118,"__hash__":473},"blog\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fwhats-quantum-computing.md","What’s quantum computing?",[7],{"type":9,"value":155,"toc":432},[156,177,181,184,189,196,200,211,215,222,226,259,263,291,295,298,302,309,322,325,329,332,336,352,356,359,363,375,378,381,385,401,405,425,429],[12,157,158,159,163,164,168,169,172,173,176],{},"This page provides a gentle explanation of what a quantum computer is, why quantum computers are important, and then provides links to ",[29,160,162],{"href":161},"\u002Flearn\u002Fquantum-foundations","quantum concept primers",", ",[29,165,167],{"href":166},"\u002Flearn\u002Fbuilding-your-first-qollab-project","software development kits",", and other relevant resources. These modules are far from comprehensive. They’re not the ",[16,170,171],{},"conclusion"," of your learning journey. They are the ",[16,174,175],{},"beginning",".",[21,178,180],{"id":179},"whats-a-quantum-computer","What’s a quantum computer?",[12,182,183],{},"A quantum computer isn’t really a computer, at least, not in the way we use the word “computer” today. Usually when we speak about “computers” we’re referring to something with a screen. A keyboard. Some kind of pointing device like a mouse, trackpad, or even a touch screen. Your desktop or laptop computer might even have a camera, microphone, or speakers. A quantum computer doesn’t have any of those things.",[185,186,188],"h3",{"id":187},"like-a-graphics-card","Like a graphics card",[12,190,191,192,195],{},"Quantum computers are more like graphics cards. If you’re not familiar, a graphics card is a piece of hardware that slots into your computer’s innards and boosts its ability to render complex, high resolution graphics. The crown jewel of a graphics card is its GPU, or Graphics Processing Unit. The GPU is a special computer chip built for rendering graphics quickly. Graphics cards aren’t “computers” in the way we commonly use that word, but they are absolutely computers in the sense that their job is to ",[16,193,194],{},"compute."," In fact, that is all that they do.",[185,197,199],{"id":198},"different-tools-for-different-problems","Different tools for different problems",[12,201,202,203,206,207,210],{},"So why bother with a graphics card? Your computer already contains a CPU, or Central Processing Unit. Isn’t that good enough? Yes and no. CPUs are designed to execute a very long series of instructions incredibly quickly, one instruction at a time. But a ",[16,204,205],{},"GPU"," is engineered to execute ",[16,208,209],{},"millions of copies of one tiny program at once."," Most software, like applications for composing and editing text documents, are perfectly suited for CPUs. But some problems, like computing the color values for millions of pixels in order to paint one frame of a large 3D scene, are more efficiently solved by GPUs. Certain procedures lend themselves to one kind of tool, while other procedures are more efficiently solved by another.",[185,212,214],{"id":213},"a-new-kind-of-tool","A new kind of tool",[12,216,217,218,221],{},"That’s where quantum computers come in. A quantum computer has its own crown jewel: the QPU, or Quantum Processing Unit. QPUs are a third style of hardware architecture, engineered to more efficiently answer a special set of logic questions that are ",[16,219,220],{},"not"," as easily answered by either CPUs or GPUs. Just like a graphics card, a quantum computer must be attached to a “regular computer”, that is, a computer that has a screen, keyboard, and pointing device, in order for us humans to tell the quantum computer what to do. (And for receiving \u002F rendering the results of a quantum computation.) Quantum computers are a different kind of tool for a different kind of problem.",[185,223,225],{"id":224},"a-quantum-tool","A quantum tool",[12,227,228,229,233,234,163,238,163,242,246,247,251,252,254,255,258],{},"Quantum computers are different because unlike other computing architectures, they harness properties of ",[29,230,232],{"href":231},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_mechanics","quantum mechanics"," in order to solve logic problems. These properties include interesting and often counterintuitive behaviors like ",[29,235,237],{"href":236},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_superposition","superposition",[29,239,241],{"href":240},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_entanglement","entanglement",[29,243,245],{"href":244},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FWave_interference","interference",", and ",[29,248,250],{"href":249},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_teleportation","teleportation",". (No, quantum teleportation is ",[16,253,220],{}," like Star Trek, sadly.) There are different types of quantum computer hardware architectures, but ",[16,256,257],{},"all"," of them leverage these same quantum principles.",[185,260,262],{"id":261},"math-not-physics","Math, not physics",[12,264,265,266,269,270,273,274,276,277,163,279,163,283,246,286,290],{},"Thankfully, you don’t need to be an expert in quantum physics to begin coding quantum programs (known in the industry as “quantum ",[16,267,268],{},"circuits","”) for a quantum computer. In fact, you don’t need to understand the physics ",[16,271,272],{},"at all."," Quantum software is just software. And software is just math expressed as a story. In order to write your quantum stories you’ll need to brush up on a tiny bit of math. To assist you with this, we’ve written a few ",[29,275,162],{"href":161},". These cover ",[29,278,94],{"href":93},[29,280,282],{"href":281},"\u002Flearn\u002Fquantum-foundations\u002Fmatrices","matrices",[29,284,285],{"href":81},"qubits",[29,287,289],{"href":288},"\u002Flearn\u002Fquantum-foundations\u002Fgates","quantum logic gates",". With just these intellectual tools under your belt, you’ll understand the building blocks of quantum algorithms, and you’ll be able to write your own.",[21,292,294],{"id":293},"why-do-quantum-computers-matter","Why do quantum computers matter?",[12,296,297],{},"Quantum computers allow us compute using the physics of the universe itself, opening up problems that are inaccessible to classical computation. They allow us to solve certain logic puzzles that would otherwise take a lot longer, sometimes longer than a human lifespan. Let’s look at some examples.",[185,299,301],{"id":300},"_1-they-access-exponentially-large-state-spaces","1. They access exponentially large state spaces",[12,303,304,305,308],{},"A classical computer stores one configuration of bits at a time. A quantum computer stores a ",[29,306,307],{"href":93},"complex-valued"," amplitude over 2ⁿ possible bitstrings simultaneously.",[310,311,312,316,319],"ul",{},[313,314,315],"li",{},"10 qubits → amplitudes over 1,024 states.",[313,317,318],{},"50 qubits → amplitudes over 1 quadrillion states.",[313,320,321],{},"1,000 logical qubits → amplitudes over 10³⁰⁰ states (more than atoms in the universe).",[12,323,324],{},"This doesn’t mean “magical parallel computing.” It means quantum computers can represent (and operate on) huge structured spaces compactly. They matter for tasks where that structure can be used instead of collapsing into noise.",[185,326,328],{"id":327},"_2-they-use-interference-as-a-computational-primitive","2. They use interference as a computational primitive",[12,330,331],{},"Classical bits don’t “cancel each other out.” Quantum amplitudes do. Quantum algorithms work by: Spreading amplitude over many candidate solutions Computing a phase pattern that encodes a problem Using interference to amplify the correct solutions and suppress incorrect ones This interference is the heart of algorithms like: Grover (search) Shor (period finding → factoring) HHL (linear systems) VQE & QAOA (optimization via physics dynamics) Interference is why the right answer “pops out” without needing to know it ahead of time.",[185,333,335],{"id":334},"_3-they-implement-linear-algebra-natively","3. They implement linear algebra natively",[12,337,338,339,343,344,347,348,351],{},"Quantum operations are matrices. Quantum states are vectors. Quantum evolution is matrix multiplication. Anything that requires huge vectors, huge matrices, transformations (like Fourier transforms, eigenvalue estimation, or simulation of unitary dynamics), all get a natural hardware-level boost. This is why quantum computers matter for: - ",[340,341,342],"strong",{},"Chemistry",". Simulating molecules is exponentially hard classically because electron wavefunctions live in huge Hilbert spaces. Quantum hardware matches that structure. - ",[340,345,346],{},"Materials",". Superconductors, catalysts, batteries, photovoltaics, these are quantum many-body systems. - ",[340,349,350],{},"Optimization & machine learning",". Quantum systems naturally explore complex energy landscapes and encode correlations compactly.",[185,353,355],{"id":354},"_4-they-can-simulate-physics-in-ways-classical-computers-fundamentally-cannot","4. They can simulate physics in ways classical computers fundamentally cannot",[12,357,358],{},"Our universe is quantum mechanical. If you’re aiming to simulate the nitty-gritty aspects of it, you just can’t rely on classical computation. You need quantum computation in order to match the behavior of our reality. Quantum simulation is likely the first mega-use-case that reaches real-world impact: - Drug discovery. - Materials design. - Climate and energy applications. - Quantum chemistry (enzymes, catalysts). - Superconductivity and quantum phases of matter.",[21,360,362],{"id":361},"how-can-i-play-with-quantum-computing","How can I play with quantum computing?",[12,364,365,366,370,371,374],{},"Use the ",[29,367,369],{"href":368},"#resources-sitemap","Resources sitemap"," below as your personal roadmap to quantum computing. First, we’ll brush up on just a tiny bit of math. Then, we’ll get some quantum programming software setup on your own personal computer. From there we can run quantum ",[16,372,373],{},"simulations"," either on your own machine or in the cloud. And that’s when we reach the summit: We’ll run your quantum circuits on actual quantum computing hardware connected to the cloud.",[21,376,369],{"id":377},"resources-sitemap",[12,379,380],{},"You don’t need to be a physicist to write quantum software. Let’s get you up and running.",[185,382,384],{"id":383},"quantum-concept-primers","Quantum concept primers",[12,386,387,388,390,391,393,394,397,398],{},"These math references are your foundation for understanding the building blocks of quantum algorithms. (No physics degree required.) They progress in order, so start from the top. 1. ",[29,389,87],{"href":93}," 2. ",[29,392,5],{"href":281}," 3. ",[29,395,396],{"href":81},"Qubits (quantum bits)"," 4. ",[29,399,400],{"href":288},"Quantum logic gates",[185,402,404],{"id":403},"quantum-software-tools","Quantum software tools",[12,406,407,408,411,412,415,416,420,421],{},"You know what a Hadamard gate is and you feel you’re ready to cook. Let’s look at some common software tools, programming languages and software development kits (SDKs), that will allow you to replicate tutorial examples, ",[16,409,410],{},"simulate"," quantum outcomes, potentially execute your code on ",[16,413,414],{},"actual quantum hardware",", and begin dreaming up your very own quantum algorithms. These tutorials are in progress, so if you don’t find what you’re looking for check back soon. - ",[29,417,419],{"href":418},"\u002Flearn\u002Fbuilding-your-first-qollab-project\u002Fpython-basics","Python (programming language)"," - ",[29,422,424],{"href":423},"\u002Flearn\u002Fbuilding-your-first-qollab-project\u002Fqiskit-setup","IBM Qiskit SDK",[185,426,428],{"id":427},"upskill-to-quantum","Upskill to quantum",[12,430,431],{},"Looking to make the leap from your current day job to a quantum computing role? Stay tuned! We’re drafting a roster of “upskill” tutorials to take you from roles like Web developer, AI engineer, or even musician, to a future entry-level role in quantum computing.",{"title":108,"searchDepth":109,"depth":109,"links":433},[434,441,447,448],{"id":179,"depth":109,"text":180,"children":435},[436,437,438,439,440],{"id":187,"depth":137,"text":188},{"id":198,"depth":137,"text":199},{"id":213,"depth":137,"text":214},{"id":224,"depth":137,"text":225},{"id":261,"depth":137,"text":262},{"id":293,"depth":109,"text":294,"children":442},[443,444,445,446],{"id":300,"depth":137,"text":301},{"id":327,"depth":137,"text":328},{"id":334,"depth":137,"text":335},{"id":354,"depth":137,"text":355},{"id":361,"depth":109,"text":362},{"id":377,"depth":109,"text":369,"children":449},[450,451,452],{"id":383,"depth":137,"text":384},{"id":403,"depth":137,"text":404},{"id":427,"depth":137,"text":428},[116,117,118,152],[],{"username":7,"name":121,"role":122,"avatar":108},"Quantum computing is easier than you might think. (Remember it’s just computing, it’s not quantum physics!) Some quick math brush-ups and few concept primers are all you need to start making meaningful mistakes.","Quantum computing is easier than you think. It's computing, not physics. A little math and a few concept primers are all you need to start.",{"image":459,"alt":152},"\u002F_content\u002Fimages\u002Fwhats-quantum-computing\u002Fhero.webp",{},{"slug":462,"title":463,"desc":464},"\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers","2 · Complex numbers","Complex numbers are a key part of orchestrating quantum algorithms, and you can learn what they are in just a few minutes.",1,"\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fwhats-quantum-computing","8 min read",[],{"title":470,"description":457},"What’s quantum computing? · Quantum foundations","blog\u002Flearn\u002Fquantum-foundations\u002Fwhats-quantum-computing",[],"NDWKnyWnMAgoHttyJhBNq7p1dkHtAWvTI2Musnaq_vk",{"id":475,"title":87,"authors":476,"body":477,"breadcrumb":569,"builders":570,"byline":571,"challenge":123,"courseAuthor":123,"courseLead":123,"dek":464,"description":464,"draft":125,"extension":126,"eyebrow":123,"finish":123,"fork":123,"hero":572,"heroAlt":123,"heroCta":123,"heroImage":123,"kind":129,"lessonCount":130,"meta":574,"navigation":132,"newsItems":123,"next":575,"ogImage":123,"order":109,"outcomes":123,"path":462,"publishDate":139,"readingTime":140,"related":577,"relatedProjects":123,"seo":578,"stem":580,"tags":581,"track":146,"trackName":118,"__hash__":582},"blog\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers.md",[7],{"type":9,"value":478,"toc":564},[479,482,486,494,500,503,511,515,526,533,539,542,547,551,559],[12,480,481],{},"We’ll start with what you know: regular numbers. Then we’ll introduce “imaginary” numbers. A complex number is just a combination of a regular number with an imaginary one. Let’s go.",[21,483,485],{"id":484},"real-numbers-ℝ","Real numbers ( ℝ )",[12,487,488,489,493],{},"Our regular, ordinary, everyday numbers are called ",[29,490,492],{"href":491},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FReal_number","real numbers",". These include integers and decimals. You can visualize real numbers as existing along an infinite number line, with zero in the middle, positive numbers counting up forever to infinity on the right, and negative numbers doing the exact opposite on the left.",[495,496],"blog-figure",{"alt":497,"caption":498,"no":108,"src":499},"A horizontal number line of Real Numbers with values labeled from -5 (left) to +5 (right) and arrows on either extreme indicating that these numbers extend infinitely in either direction.","The Real number line.","\u002F_content\u002Fimages\u002Fcomplex-numbers\u002Freal-numberline-3.webp",[12,501,502],{},"When a real number is multiplied by itself the product is always positive. For example, if we choose the number 2 we see that 2 × 2 = 4. Similarly, had we chosen the negative number -2, the product would still be positive because two negative numbers multiplied together also produce a positive result; -2 × -2 = 4. For brevity we could rewrite these equations as 22 = 4 and (-2)2 = 4, respectively.",[12,504,505,506,510],{},"The ",[29,507,509],{"href":508},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FSquare_root","square root"," of a real number has two possible answers. The square root of 4, for example, is both 2 and -2 because both are solutions for x in the equation x = 4.",[21,512,514],{"id":513},"imaginary-numbers-𝕀","Imaginary numbers ( 𝕀 )",[12,516,517,518,521,522,525],{},"But suppose we wanted to find the square root of a ",[16,519,520],{},"negative"," number. Is there any number that could solve for x in the equation x = -4? Sadly, there is not. Or more precisely: there is not any ",[16,523,524],{},"real"," solution for the square root of a negative number.",[12,527,528,532],{},[29,529,531],{"href":530},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FImaginary_number","Imaginary numbers"," might be considered an “intermediate impossible.” The symbol i is defined as the imaginary solution to the equation x = -1, therefore i2 = -1. With this imaginary device we now have a solution to the above equation x = -4 and that solution is 2i. (And also -2i, of course. We can indicate this “plus or minus” possibility as ±2i.) Let’s inspect this more closely.",[534,535,536],"blockquote",{},[12,537,538],{},"x = -4 x = 4 × -1 x = 4 × -1 x = ±2 × -1 x = ±2 × i x = ±2i",[12,540,541],{},"2i is an imaginary number that consists of a real number multiplier, 2, and our imaginary solution to -1, called i. Like real numbers, imaginary numbers also exist along an infinite number line. We plotted our real number line horizontally, so let’s plot our imaginary number line vertically.",[495,543],{"alt":544,"caption":545,"no":108,"src":546},"A vertical number line of Imaginary Numbers with values labeled from -5i (bottom) to +5 (top) and arrows on either extreme indicating that these numbers extend infinitely in either direction.","The Imaginary number line.","\u002F_content\u002Fimages\u002Fcomplex-numbers\u002Fimaginary-numberline-3.webp",[21,548,550],{"id":549},"complex-numbers-ℂ","Complex numbers ( ℂ )",[12,552,553,554,558],{},"We just saw that multiplying a real number by i yields an imaginary number. But what if you add a real number to an imaginary one? Things get complex. A ",[29,555,557],{"href":556},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FComplex_number","complex number"," is a number that can be expressed in the form a + bi, where a is the real component and bi is the imaginary component. Some examples might be 1 + 2i or 3 - 4i.",[495,560],{"alt":561,"caption":562,"no":108,"src":563},"Complex plane diagram.","The Complex plane.","\u002F_content\u002Fimages\u002Fcomplex-numbers\u002Fcomplex-plane-3.webp",{"title":108,"searchDepth":109,"depth":109,"links":565},[566,567,568],{"id":484,"depth":109,"text":485},{"id":513,"depth":109,"text":514},{"id":549,"depth":109,"text":550},[116,117,118,87],[],{"username":7,"name":121,"role":122,"avatar":108},{"image":573,"alt":87},"\u002F_content\u002Fimages\u002Fcomplex-numbers\u002Fhero.webp",{},{"slug":138,"title":576,"desc":124},"3 · Matrices",[],{"title":579,"description":464},"Complex numbers · Quantum foundations","blog\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers",[],"p6kGszjbHdzS19ERzfnn4xvISFRCcC9_QjrXTuMwNZA",{"id":4,"title":5,"authors":584,"body":585,"breadcrumb":641,"builders":642,"byline":643,"challenge":123,"courseAuthor":123,"courseLead":123,"dek":124,"description":124,"draft":125,"extension":126,"eyebrow":123,"finish":123,"fork":123,"hero":644,"heroAlt":123,"heroCta":123,"heroImage":123,"kind":129,"lessonCount":130,"meta":645,"navigation":132,"newsItems":123,"next":646,"ogImage":123,"order":137,"outcomes":123,"path":138,"publishDate":139,"readingTime":140,"related":647,"relatedProjects":123,"seo":648,"stem":144,"tags":649,"track":146,"trackName":118,"__hash__":147},[7],{"type":9,"value":586,"toc":635},[587,591,593,597,599,601,605,607,613,623,625],[12,588,14,589,19],{},[16,590,18],{},[21,592,24],{"id":23},[12,594,27,595,33],{},[29,596,32],{"href":31},[12,598,36],{},[21,600,40],{"id":39},[12,602,43,603,48],{},[29,604,47],{"href":46},[21,606,52],{"id":51},[12,608,55,609,59,611,63],{},[16,610,58],{},[16,612,62],{},[12,614,66,615,70,617,74,619,78,621,83],{},[16,616,69],{},[16,618,73],{},[16,620,77],{},[29,622,82],{"href":81},[21,624,87],{"id":86},[12,626,90,627,95,629,99,631,102,633,106],{},[29,628,94],{"href":93},[16,630,98],{},[29,632,82],{"href":81},[16,634,105],{},{"title":108,"searchDepth":109,"depth":109,"links":636},[637,638,639,640],{"id":23,"depth":109,"text":24},{"id":39,"depth":109,"text":40},{"id":51,"depth":109,"text":52},{"id":86,"depth":109,"text":87},[116,117,118,5],[],{"username":7,"name":121,"role":122,"avatar":108},{"image":128,"alt":5},{},{"slug":134,"title":135,"desc":136},[],{"title":143,"description":124},[],{"id":651,"title":396,"authors":652,"body":653,"breadcrumb":1134,"builders":1135,"byline":1136,"challenge":123,"courseAuthor":123,"courseLead":123,"dek":1137,"description":1138,"draft":125,"extension":126,"eyebrow":123,"finish":123,"fork":123,"hero":1139,"heroAlt":123,"heroCta":123,"heroImage":123,"kind":129,"lessonCount":130,"meta":1141,"navigation":132,"newsItems":123,"next":1142,"ogImage":123,"order":1146,"outcomes":123,"path":134,"publishDate":139,"readingTime":1147,"related":1148,"relatedProjects":123,"seo":1149,"stem":1151,"tags":1152,"track":146,"trackName":118,"__hash__":1153},"blog\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fqubits.md",[7],{"type":9,"value":654,"toc":1124},[655,658,662,674,707,727,731,734,742,750,754,770,779,789,795,799,811,839,842,867,887,890,894,911,926,940,947,950,973,985,1002,1005,1008,1011,1014,1021,1025,1036,1081,1089,1104,1108,1120],[12,656,657],{},"We’ll learn that qubits are mathematically simple structures, yet provide tremendous computational power. While there are multiple ways to implement physical qubits, we’re only interested in the mathematical concept of a qubit. Regardless of what method a quantum computer uses to implement its physical qubits, how they operate as a computing tools remains the same.",[21,659,661],{"id":660},"perfect-pairs","Perfect pairs",[12,663,27,664,668,669,673],{},[29,665,667],{"href":666},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQubit","qubit"," is just a pair of numbers. That’s it, two ",[29,670,672],{"href":671},"https:\u002F\u002Fyoutu.be\u002FYYOKMUTTDdA","shiny happy number values, holding hands",". Let’s call the first number “alpha” and the second number “beta.” Look at this handsome couple:",[12,675,676,677,679,680,683,684,687,688,692,693,695,696,698,699,702,703,706],{},"We can package alpha and beta together by storing them in a very small ",[29,678,32],{"href":281}," that is only ",[340,681,682],{},"one"," unit wide and ",[340,685,686],{},"two"," units tall, and because this matrix is only one unit wide it is not merely a matrix, it’s also a ",[29,689,691],{"href":690},"\u002Flearn\u002Fquantum-foundations\u002Fmatrices#vectors-are-slices","vector",". (What’s a ",[29,694,32],{"href":281},"? What’s a ",[29,697,691],{"href":690},"? See our ",[29,700,701],{"href":281},"matrix explainer"," for quick refreshers on both.) So when you think of a qubit you can imagine it as a 1 × 2 ",[29,704,32],{"href":705},"\u002Flearn\u002Fquantum-foundations\u002Fmatrices\u002F"," containing its alpha value on the top and its beta value on the bottom, like so:",[12,708,709,710,712,713,717,718,722,723,726],{},"Now that we know a qubit is a ",[29,711,32],{"href":281},", we also know that we can perform ",[29,714,716],{"href":715},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FMatrix_addition","addition"," with qubits, perform ",[29,719,721],{"href":720},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FMatrix_multiplication","multiplication"," with qubits, and so on, just as one can do with any matrix. (That will become rather important when we eventually introduce the idea of ",[29,724,725],{"href":288},"quantum gates",", which are also matrices.)",[21,728,730],{"id":729},"predictable-couples","Predictable couples",[12,732,733],{},"The thing that makes this pair of numbers special is their relationship to each other, which we can define as follows: alpha multiplied by alpha, added to beta multiplied by beta, must always equal one. We can express this as an equation:",[12,735,736,737,741],{},"The parentheses in the equation above are not strictly necessary as the ",[29,738,740],{"href":739},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FOrder_of_operations","“order of operations” rules"," dictate that these multiplications must be carried out prior to the additions, but emphasis can often be more helpful than brevity when learning something new. And now that we understand this relationship we can express it more compactly using exponents rather than multiplications: alpha squared added to beta squared must always equal one.",[12,743,744,745,749],{},"A bit ",[29,746,748],{"href":747},"#complex-couples","further below"," we’ll add one small wrinkle to this equation, but otherwise this is what defines a qubit. That’s it. It’s that easy.",[21,751,753],{"id":752},"named-couples","Named couples",[12,755,756,757,761,762,765,766,769],{},"Let’s start plugging in values for alpha and beta. Each different value combination makes a different sort of qubit. The most frequently used qubit value combinations have names and belong to a set of named vectors called ",[29,758,760],{"href":759},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FJones_calculus#The_Jones_vector","Jones vectors",". We’ll begin with the two simplest qubits. This first qubit is named ",[16,763,764],{},"Horizontal"," and the second is named ",[16,767,768],{},"Vertical",". Both are composed from a zero and a one and we can see that this satisfies our qubit definition above.",[12,771,772,773,775,776,778],{},"What does it mean to be named ",[16,774,764],{}," or ",[16,777,768],{},"? Where do these orientation-based names come from? Are there more orientation-based names? To understand, let’s plot these two qubit vectors on a graph. We’ll use the alpha value as our x coordinate and the beta value as our y coordinate:",[12,780,781,782,785,786,176],{},"Plotting alpha and beta as x and y yields (1,0) for a ",[16,783,784],{},"Horizontal qubit"," and (0,1) for a ",[16,787,788],{},"Vertical qubit",[12,790,791,792,794],{},"We can see that the values from a Horizontal qubit, when plotted as x and y, form a horizontal line from the origin (0,0) out to (1,0). Meanwhile, when we plot the values of a Vertical qubit as x and y, it forms a vertical line from the origin (0,0) up to (0,1). Before we introduce more named ",[29,793,760],{"href":759}," let’s take what we’ve learned about qubit values and generalize it for vectors with more than two elements so we can better understand what these qubit values truly mean.",[21,796,798],{"id":797},"state-vectors","State vectors",[12,800,801,802,806,807,810],{},"Did it seem strange to read that the qubit we refer to as “",[803,804,805],"code",{},"0","” begins with an alpha value of 1? (Or that the qubit we refer to as “",[803,808,809],{},"1","” begins with an alpha value of 0?) Does that mean we refer to qubits by their beta values? Is that some sort of quantum computing convention?",[12,812,813,814,817,818,820,821,825,826,828,829,832,833,835,836,176],{},"The short answer is “No.” To understand why, we must recognize that a qubit is the simplest example of a quantum ",[16,815,816],{},"state vector",", a list of all possible states for a quantum system to exist in, with each possible state accompanied by the probability that the system is indeed in that state. When a single qubit is measured there are only two possible states for it to be in: 0 or 1. This is why a qubit is represented by a two-element vector; one element per possible outcome. On this very short list of possible outcomes, 0 is the first possible outcome and 1 is the second possible outcome. When we say that a Horizontal qubit is “",[803,819,805],{},"” ",[29,822,824],{"href":823},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=DfSL-HeIrxA","we’re not referring to the qubit’s beta value at all",". We’re instead highlighting the fact that the 1 in this (1,0) pair happens to be in the “zeroth” slot, the alpha slot of this (alpha,beta) pair. We’re saying that for the possible outcome “",[803,827,805],{},"” our qubit is voting 1, or ",[803,830,831],{},"TRUE",". At the same time we’re saying that for the possible outcome “",[803,834,809],{},"”, our qubit is voting 0, or ",[803,837,838],{},"FALSE",[12,840,841],{},"For good measure let’s look at the converse example.",[12,843,844,845,847,848,850,851,853,854,163,857,163,860,246,863,866],{},"To further clarify, and to hint at how a quantum circuit functions, let’s look at a state vector for a quantum system composed of ",[340,846,686],{}," qubits. With one qubit there were two possible outcomes: ",[803,849,805],{}," and ",[803,852,809],{},". (And because there are only two elements of a qubit vector we named them alpha and beta to make referring to them more convenient.) For two qubits there are four possible outcomes: ",[803,855,856],{},"00",[803,858,859],{},"01",[803,861,862],{},"10",[803,864,865],{},"11",". (We won’t bother to name elements of state vectors larger than two. It would get unwieldy rather quickly.) Which of those four possible outcomes might the following state vector represent?",[12,868,869,870,872,873,875,876,872,878,880,881,883,884,886],{},"The above vector represents four possible outcomes and we see that three out of those four possible outcomes are ",[803,871,838],{}," (",[803,874,805],{},"). Meanwhile, the third of those four possible outcomes is ",[803,877,831],{},[803,879,809],{},"). Because the result value of the third possible outcome is ",[803,882,862],{}," we see that this two qubit vector state is telling us it represents a result of ",[803,885,862],{},". Let’s break this down the same way we did with Horizontal and Vertical qubits.",[12,888,889],{},"We’ve learned that a single qubit is the simplest example of a quantum state vector. It is a list of the votes per each possible outcome, and for a single qubit there are only two possible outcomes. We’ve also seen that we can represent the state of a multi-qubit system where there are more than two possible outcomes.",[21,891,893],{"id":892},"ket-notation","Ket notation",[12,895,896,900,901,905,906,910],{},[29,897,899],{"href":898},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPaul_Dirac","Paul Dirac","’s ",[29,902,904],{"href":903},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBra%E2%80%93ket_notation","“bra-ket” notation"," offers us a more compact means of describing ",[29,907,909],{"href":908},"#state-vectors","quantum state vectors",", and by extension, qubits. (While “bra-ket” offers us two named elements, “bra” and “ket”, for our purposes we need only focus on the latter.) Kets represent the result value that our quantum vector state represents. They are expressed as values enclosed between a vertical bar and a rightward angle bracket. The following is pronounced “ket zero.”",[12,912,913,914,918,919,921,922,925],{},"We ",[29,915,917],{"href":916},"#named-couples","began"," by stating that a Horizontal qubit represents “",[803,920,805],{},"”, and later ",[29,923,924],{"href":908},"explained"," why this was so. Kets provide us a convenient way to refer to this result state directly as in-line text rather than a clunky matrix.",[12,927,928,929,932,933,935,936,939],{},"Similarly, we ",[29,930,931],{"href":916},"defined"," a Vertical qubit as representing “",[803,934,809],{},"” and ",[29,937,938],{"href":908},"illustrated this"," as well. We can now also express this column vector as a ket.",[12,941,942,943,176],{},"The convenience of ket notation becomes more apparent as we represent state vectors that are larger than a single qubit. (For n qubits we must use a state vector that has 2n elements. Meanwhile our ket values are still just n digits long.) Here we express four possible states of a two qubit system as both state vectors and their ",[29,944,946],{"href":945},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQubit#Standard_representation","equivalent kets",[21,948,949],{"id":237},"Superposition",[12,951,952,953,955,956,960,961,963,964,966,967,969,970,972],{},"You’ve probably heard the term “",[29,954,237],{"href":236},"”, and along with that you’ve likely been spoonfed some measure of mysticism; ",[29,957,959],{"href":958},"https:\u002F\u002Fyoutu.be\u002FCMdHDHEuOUE","pizza-bagels"," and whatnot. In the real, physical world, superposition is indeed weird magic. But mathematically it’s dead simple: Superposition is any qubit state where the alpha and beta values are anything other than exactly 0 or exactly 1. Up until now we’ve thought of alpha and beta values as being either ",[803,962,831],{}," (1) or ",[803,965,838],{}," (0) but each is actually capable of expressing an entire spectrum between ",[803,968,831],{}," (1) and ",[803,971,838],{}," (0). Let’s investigate that idea by building on what we’ve already learned.",[12,974,975,976,980,981,984],{},"Given the constraint alpha 2 + beta 2 = 1 , if we plot all of the possible alpha and beta values on a graph as x and y respectively, the outcome is a circle with a radius of 1 centered at the origin ( 0 , 0 ) ; ie. a ",[29,977,979],{"href":978},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FUnit_circle","unit circle","). All possible combinations of alpha and beta lay on the perimeter of this circle. To illustrate this, here’s a plot of named ",[29,982,760],{"href":983},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FJones_calculus#Jones_vectors"," as well as their conjugates.",[12,986,987,988,992,993,997,998,1001],{},"What the alpha and beta values represent are the individual ",[29,989,991],{"href":990},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FProbability_amplitude","probability amplitudes"," for each outcome; that a qubit when measured will be in either a | 0 ⟩ or a | 1 ⟩ state. Measurement itself causes a qubit’s ",[29,994,996],{"href":995},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FWave_function_collapse","probability wave to collapse",", bringing an end to its superposition. The probability that upon measurement a qubit’s ",[29,999,1000],{"href":990},"probability amplitude"," will collapse to | 0 ⟩ is alpha2, while the probability that it will collapse to | 1 ⟩ is beta2.",[12,1003,1004],{},"We already know that a Horizontal qubit exists in a state of | 0 ⟩ (“ket zero”) and therefore has a 100% chance of being measured as | 0 ⟩ .",[12,1006,1007],{},"Similarly, we also know that a Vertical qubit exists in a state of | 1 ⟩ (“ket one”) and therefore has a 100% chance of being measured as | 1 ⟩ .",[12,1009,1010],{},"Meanwhile, a Diagonal qubit exists in a state of superposition as | + ⟩ (“ket plus”). It is a state which does not have a definite result value prior to measurement but it does of course have a definite state vector and that state vector has a positive orientation. (Recall our unit circle diagram above to see how this value lays in a positive quadrant of the graph.) There is a 50% chance of it being measured as | 0 ⟩ (“ket zero”) and a 50% chance of it being measured as | 1 ⟩ (“ket one”).",[12,1012,1013],{},"And finally, an Anti-diagonal qubit also exists in a state of superposition, but as | - ⟩ (“ket minus”). Like the Diagonal qubit it has a 50% chance of being measured as | 0 ⟩ (“ket zero”) and a 50% chance of being measured as | 1 ⟩ (“ket one”).",[12,1015,1016,1017,1020],{},"What does it mean that a Diagonal qubit state and an Anti-diagonal qubit state collapse with the same probabilies? What about their conjugates which also behave in this same fashion? ",[29,1018,1019],{"href":166},"quantum circuits"," the aspects of quantum computing that quantum algorithms are engineered to take advantage of.",[21,1022,1024],{"id":1023},"complex-couples","Complex couples",[12,1026,1027,1028,1032,1033,176],{},"We’ve spent the majority of this primer describing qubits as containing alpha and beta values ranging from 0 up to 1. The ",[29,1029,1031],{"href":1030},"#superposition","unit circle above"," illustrates that these values can also range from 0 down to −1. While all of this remains true, the story is slightly more ",[16,1034,1035],{},"complex",[12,1037,1038,1039,1042,1043,1046,1047,1050,1051,163,1054,246,1058,1061,1062,1064,1065,1068,1069,1071,1072,1074,1075,1077,1078,1080],{},"Qubits are actually made of ",[29,1040,557],{"href":1041},"\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers\u002F"," pairs, meaning there is an ",[16,1044,1045],{},"imaginary component."," (See the ",[29,1048,1049],{"href":1041},"Complex Numbers page"," for a quick refresher on ",[29,1052,524],{"href":1053},"\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers\u002F#real-numbers-%E2%84%9D",[29,1055,1057],{"href":1056},"\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers\u002F#imaginary-numbers-%F0%9D%95%80","imaginary",[29,1059,94],{"href":1060},"\u002Flearn\u002Fquantum-foundations\u002Fcomplex-numbers\u002F#complex-numbers-%E2%84%82",".) This means ",[16,1063,682],{}," qubit is actually made of ",[16,1066,1067],{},"four"," parts: The alpha value has a ① ",[29,1070,524],{"href":1053}," component and an ② ",[29,1073,1057],{"href":1056}," one. The beta value also has a ③ ",[29,1076,524],{"href":1053}," component and an ④ ",[29,1079,1057],{"href":1056}," one.",[12,1082,1083,1084,1088],{},"To account for this we must slightly evolve our definition of a qubit; specifically the relationship between its alpha and beta values. Rather than simply adding their squares together, we must instead add the squares of their ",[29,1085,1087],{"href":1086},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FAbsolute_value","absolute values",". Our evolved equation, which indicates absolute values by enclosing numbers between vertical bars, now looks like this:",[12,1090,1091,1092,1094,1095,1098,1099,775,1101,1103],{},"By taking the ",[29,1093,1087],{"href":1086}," of alpha and beta before squaring them, we continue to ensure that our sum of squares will equal exactly 1; that it continues to equal a simple, ",[29,1096,1097],{"href":1053},"real number"," rather than an ",[29,1100,1057],{"href":1056},[29,1102,1035],{"href":1060}," number.",[21,1105,1107],{"id":1106},"bloch-sphere","Bloch sphere",[12,1109,1110,1111,1113,1114,1116,1117,176],{},"And that’s really it. That’s what makes a mathematical qubit. But with that last-minute addition of ",[29,1112,94],{"href":1060}," above, we can no longer visualize a qubit as a two-dimensional ",[29,1115,979],{"href":1030},". Instead we must map our two complex values onto a three dimensional graph known as a ",[29,1118,1107],{"href":1119},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBloch_sphere",[1121,1122],"bloch-visualizer",{"state":1123},"|+⟩",{"title":108,"searchDepth":109,"depth":109,"links":1125},[1126,1127,1128,1129,1130,1131,1132,1133],{"id":660,"depth":109,"text":661},{"id":729,"depth":109,"text":730},{"id":752,"depth":109,"text":753},{"id":797,"depth":109,"text":798},{"id":892,"depth":109,"text":893},{"id":237,"depth":109,"text":949},{"id":1023,"depth":109,"text":1024},{"id":1106,"depth":109,"text":1107},[116,117,118,396],[],{"username":7,"name":121,"role":122,"avatar":108},"Like bits in classical computing, qubits are the fundamental containers for storing value in a quantum circuit. These stored values can be altered by applying quantum gates to them.","Like classical bits, qubits are the fundamental containers that store a value in a quantum circuit. That value changes when you apply quantum gates.",{"image":1140,"alt":396},"\u002F_content\u002Fimages\u002Fqubits\u002Fhero.webp",{},{"slug":1143,"title":1144,"desc":1145},"\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fgates","5 · Quantum logic gates","Quantum logic gates are the means of “getting work done” on a quantum computer. They perform computation by altering the values of quantum bits…",4,"24 min read",[],{"title":1150,"description":1138},"Qubits (quantum bits) · Quantum foundations","blog\u002Flearn\u002Fquantum-foundations\u002Fqubits",[],"SJQROSQQ9X1Yw56NvxtYeTi_6OsKDy6rH8tks-EMbag",{"id":1155,"title":400,"authors":1156,"body":1157,"breadcrumb":1567,"builders":1568,"byline":1569,"challenge":123,"courseAuthor":123,"courseLead":123,"dek":1570,"description":1570,"draft":125,"extension":126,"eyebrow":123,"finish":1571,"fork":123,"hero":1572,"heroAlt":123,"heroCta":123,"heroImage":123,"kind":129,"lessonCount":130,"meta":1574,"navigation":132,"newsItems":123,"next":1575,"ogImage":123,"order":130,"outcomes":123,"path":1143,"publishDate":139,"readingTime":1579,"related":1580,"relatedProjects":123,"seo":1581,"stem":1583,"tags":1584,"track":146,"trackName":118,"__hash__":1585},"blog\u002Fblog\u002Flearn\u002Fquantum-foundations\u002Fgates.md",[7],{"type":9,"value":1158,"toc":1549},[1159,1164,1168,1183,1201,1208,1227,1230,1269,1273,1277,1280,1283,1302,1306,1317,1321,1337,1341,1363,1367,1382,1385,1389,1400,1404,1408,1414,1418,1437,1441,1487,1492,1503,1507,1513,1517,1539,1543],[12,1160,1161,1162,176],{},"We’ll learn how quantum gates can act on a single qubit or multiple qubits in order to compute. While there’s no need to memorize the exact values that each gate uses to perform its operations, understanding the effect of some basic quantum gates is a solid foundation for understanding (and coding your own) ",[29,1163,1019],{"href":166},[21,1165,1167],{"id":1166},"matrices-all-the-way-down","Matrices, all the way down",[12,1169,1170,1171,1173,1174,1177,1178,1182],{},"A quantum computer is just a collection of ",[29,1172,285],{"href":81},". These qubits hold probability values for resolving to either 0 or 1. A quantum computer is able to calculate things by changing the value of its qubits over time. We tell the computer exactly how it should change the value of a qubit by instructing it to “walk through” a series of ",[29,1175,725],{"href":1176},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate",". As the qubit ",[29,1179,1181],{"href":1180},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FThe_Gates","“walks through” each gate"," its value is changed based on the type of gate it is passing through.",[12,1184,1185,1186,1188,1189,1191,1192,1195,1196,1200],{},"Contrary to what pop-science might tell you, there is nothing random or unpredictable about this process. Mathematically, a ",[29,1187,667],{"href":81}," is just a ",[29,1190,32],{"href":281},". Similarly, a gate is also just a matrix. To apply a gate to a qubit is to ",[16,1193,1194],{},"multiply"," these matrices together. To demonstrate this, let’s begin with a ",[29,1197,1199],{"href":1198},"\u002Flearn\u002Fquantum-foundations\u002Fqubits#named-couples","“Horizontal” qubit",", commonly thought of as representing “zero” or “off.” It has the following matrix form:",[12,1202,1203,1204,1207],{},"We would like to flip the value of this qubit from “off” to “on.” The result will be a ",[29,1205,1206],{"href":1198},"“Vertical” qubit"," with the following matrix form:",[12,1209,1210,1211,1213,1214,1216,1217,1221,1222,1226],{},"By looking at the pair of numbers that represent each qubit, you can see that a ",[29,1212,784],{"href":1198}," is the inverse (or “flipped”) version of a ",[29,1215,788],{"href":1198},". In order to “flip” from one to the other we must apply a ",[29,1218,1220],{"href":1219},"#pauli-x-gate","Pauli X gate"," to our qubit. Because Pauli X gates have the effect of “flipping” the value of a qubit, they are often thought of as the quantum equivalent of a ",[29,1223,1225],{"href":1224},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FInverter_(logic_gate)","classical “NOT” gate",". Pauli X gates have the following matrix form:",[12,1228,1229],{},"We can now apply the Pauli X gate to the Horizontal qubit by multiplying their matrices together. It’s okay if your matrix multiplication is rusty, that’s what computers are for! The important part is just to recall that both qubits and quantum gates can be represented by matrices, and so can be multiplied together.",[12,1231,1232,1233,1235,1236,1239,1240,1243,1244,1246,1247,1251,1252,1255,1256,1259,1260,1255,1262,1264,1265,1268],{},"As anticipated, the resulting product matrix represents a ",[29,1234,788],{"href":1198},". Note how the gate’s matrix is the ",[16,1237,1238],{},"first"," factor (all the way to the left) and the qubit’s matrix is the ",[16,1241,1242],{},"second"," factor (second in from the left, with the resulting product to the right of the equals sign). This order matters because matrix multiplication is ",[340,1245,220],{}," ",[29,1248,1250],{"href":1249},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FCommutative_property#Commutative_operations_in_mathematics","commutative",". With plain numbers (that is, numbers not contained within matrices), the order of the factors does not change the product outcome. a × b = b × a But with matrices, a different order yields a different outcome. ",[1253,1254,29],"span",{}," × ",[1253,1257,1258],{},"b"," ≠ ",[1253,1261,1258],{},[1253,1263,29],{}," See ",[29,1266,1267],{"href":720},"matrix multiplication"," for an in-depth explanation.",[21,1270,1272],{"id":1271},"single-qubit-gates","Single-qubit gates",[185,1274,1276],{"id":1275},"indentity-gate","Indentity gate",[12,1278,1279],{},"An Identity gate has no effect on the value of the qubit it operates on; equivalent to multiplying a value by one. (Generally when a circuit is created from text or another source, any included identity gates are ignored. It is included here for completeness.)",[185,1281,1220],{"id":1282},"pauli-x-gate",[12,1284,505,1285,1288,1289,1292,1293,1296,1297,1301],{},[29,1286,1220],{"href":1287},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Pauli-X_gate"," represents a rotation on the ",[29,1290,1107],{"href":1291},"\u002Flearn\u002Fquantum-foundations\u002Fqubits#bloch-sphere"," around the ",[340,1294,1295],{},"X","-axis by π radians. It is the quantum equivalent of the ",[29,1298,1300],{"href":1299},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FInverter%3C\u002Fem%3E(logic_gate)","classical NOT gate"," in that it maps | 0 ⟩ to | 1 ⟩ and | 1 ⟩ to | 0 ⟩ .",[185,1303,1305],{"id":1304},"pauli-y-gate","Pauli Y gate",[12,1307,505,1308,1288,1311,1292,1313,1316],{},[29,1309,1305],{"href":1310},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Pauli-Y_gate",[29,1312,1107],{"href":1291},[340,1314,1315],{},"Y","-axis by π radians. It maps | 0 ⟩ to i | 1 ⟩ and | 1 ⟩ to -i | 0 ⟩ .",[185,1318,1320],{"id":1319},"pauli-z-gate","Pauli Z gate",[12,1322,505,1323,1288,1326,1292,1328,1331,1332,1336],{},[29,1324,1320],{"href":1325},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Pauli-Z_gate",[29,1327,1107],{"href":1291},[340,1329,1330],{},"Z","-axis by π radians. It is a special case of a ",[29,1333,1335],{"href":1334},"#phase-shift-gates","Phase shift gate"," where ϕ = π, and is therefore sometimes referred to as a “phase-flip” gate. It leaves the basis state | 0 ⟩ unchanged and maps | 1 ⟩ to - | 1 ⟩ .",[185,1338,1340],{"id":1339},"hadamard-gate","Hadamard gate",[12,1342,1343,1344,1348,1349,1351,1352,1354,1355,1358,1359,1362],{},"Applies a ",[29,1345,1347],{"href":1346},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Hadamard_(H)_gate","Hadamard transform"," to a single qubit. For the basis qubit states of | 0 ⟩ and | 1 ⟩ this has the effect of putting a qubit into ",[29,1350,237],{"href":236},". It represents a rotation on the ",[29,1353,1107],{"href":1291}," around the Z-axis by π radians, followed by a rotation around the Y-axis by π ÷ 2 radians. This maps the basis state | 0 ⟩ to | 0 ⟩ + | 1 ⟩ 2 (also referred to as | + ⟩ or ",[29,1356,1357],{"href":903},"“ket plus”",") and | 1 ⟩ to | 0 ⟩ - | 1 ⟩ 2 (also referred to as | - ⟩ or ",[29,1360,1361],{"href":903},"“ket minus”",").",[185,1364,1366],{"id":1365},"phase-shift-gates","Phase shift gates",[12,1368,1369,1373,1374,1376,1377,1292,1379,1381],{},[29,1370,1372],{"href":1371},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Phase_shift_gates","Phase gates"," are a family of quantum gates that employ the variable ϕ (phi) to represent tracing a horizontal arc (a line of latitude) of ϕ radians around the ",[29,1375,1107],{"href":1291},". They leave the basis state | 0 ⟩ unchanged and map | 1 ⟩ to eiφ | 1 ⟩ . The probability of measuring a | 0 ⟩ or | 1 ⟩ is unchanged after applying a phase shift gate, however modifying the phase of a quantum state (thankfully) does have implications within a quantum algorithm. The example form shown here represents a rotation on the ",[29,1378,1107],{"href":1291},[340,1380,1330],{},"-axis of π ÷ 2 radians.",[12,1383,1384],{},"Remember that ϕ (phi) is a variable here. You can substitute whatever values you would like for ϕ without changing the gate’s properties as described above.",[185,1386,1388],{"id":1387},"t-gate","T gate",[12,1390,1391,1392,1396,1397,1399],{},"The T gate is also known as the “π÷8” gate and is a special case of a Phase shift gate where the ϕ (phi) variable is set to π÷4. (But why is it called “π÷8” when it actually divides π by 4? ",[29,1393,1395],{"href":1394},"https:\u002F\u002Fwww.quora.com\u002FWhy-is-the-quantum-T-gate-called-pi-8-gate-as-it-only-adds-a-phase-difference-of-pi-4-instead-of-pi-8-to-the-state-vector-1","It’s a little mathy",".) Like all phase shift gates, it represents a rotation on the Bloch sphere around the ",[340,1398,1330],{},"-axis.",[21,1401,1403],{"id":1402},"multi-qubit-gates","Multi-qubit gates",[185,1405,1407],{"id":1406},"swap-gate","Swap gate",[12,1409,505,1410,1413],{},[29,1411,1407],{"href":1412},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Swap_(SWAP)_gate"," swaps the value of two qubits. It is defined here with respect to the bases | 00 ⟩ , | 01 ⟩ , | 10 ⟩ , and | 11 ⟩ .",[185,1415,1417],{"id":1416},"squareroot-swap-gate","Squareroot swap gate",[12,1419,505,1420,1424,1425,1428,1429,1431,1432,1436],{},[29,1421,1423],{"href":1422},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Square_root_of_Swap_gate_(%E2%88%9ASWAP)","√Swap gate"," performs ",[16,1426,1427],{},"half"," of a swap between two qubits. It is ",[16,1430,220],{}," maximally entangling. More than one application of it is required to produce a ",[29,1433,1435],{"href":1434},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBell_state","Bell state"," from its product states. As with the Swap gate, is defined here with respect to the bases | 00 ⟩ , | 01 ⟩ , | 10 ⟩ , and | 11 ⟩ .",[185,1438,1440],{"id":1439},"controlled-gates","Controlled gates",[12,1442,1443,1446,1447,850,1450,1453,1454,1458,1459,1463,1464,1468,1469,775,1472,1475,1476,1479,1480,1482,1483,1486],{},[29,1444,1440],{"href":1445},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FQuantum_logic_gate#Controlled_gates"," act on two or more qubits, where one qubit acts as the “target” of the operation and the remaining qubits act as “controls” determining ",[16,1448,1449],{},"if",[16,1451,1452],{},"how"," that target qubit is operated upon. In its most elementary form (a ",[29,1455,1457],{"href":1456},"#controlled-not-gate","CNOT gate","), a controlled gate operation acts as a sort of ",[29,1460,1462],{"href":1461},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FConditional_(computer_programming)","“if” statement",", operating on the target qubit only when that “if” statement is satisfied, or to the degree with which it is satisfied. (Because qubits represent probabilities, they are not limited to strict ",[29,1465,1467],{"href":1466},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBoolean_algebra","Boolean values"," of ",[803,1470,1471],{},"YES",[803,1473,1474],{},"NO",". You might imagine the “if” statement being ",[16,1477,1478],{},"partially"," satisifed, and thus ",[16,1481,1478],{}," operating on the target qubit.) Through this process, controlled gates have the ability to ",[29,1484,1485],{"href":240},"entangle"," and disentangle qubits.",[1488,1489,1491],"h4",{"id":1490},"controlled-not-gate","Controlled NOT gate",[12,1493,1494,1495,1499,1500,1502],{},"The foundational example of a controlled gate is the ",[29,1496,1498],{"href":1497},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FControlled_NOT_gate","Controlled-Not (CNOT) gate",". The CNOT gate accepts two qubits as input, a control qubit and a target qubit, only operating on the target qubit according to the state of the control qubit. If the control qubit’s state is | 0 ⟩ (“off”) the target qubit remains untouched. However, if the control cubit’s state is | 1 ⟩ (“on”) then the target qubit’s state will be inverted by a ",[29,1501,1220],{"href":1219},". Of course, a qubit’s state is not limited to | 0 ⟩ or | 1 ⟩ and therein lies the fun. Its matrix representation is akin to an identity matrix and an inversion matrix globbed together:",[1488,1504,1506],{"id":1505},"controlled-swap-fredkin-gate","Controlled Swap (Fredkin) gate",[12,1508,505,1509,1512],{},[29,1510,1506],{"href":1511},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FFredkin_gate"," operates on three qubits, using one as a control and two as targets. True to its name, it swaps the states of the two target qubits according to the state of the control bit. As we can see here, more qubits means more matrix values.",[1488,1514,1516],{"id":1515},"toffolli-ccnot-gate","Toffolli (CCNOT) gate",[12,1518,505,1519,1523,1524,1528,1529,1531,1532,1534,1535,1538],{},[29,1520,1522],{"href":1521},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FToffoli_gate","Toffolli gate"," is also known as the CCNOT gate, a “controlled-controlled-not” gate. Like the ",[29,1525,1527],{"href":1526},"#controlled-swap-fredkin-gate","Controlled-swap “Fredkin” gate",", it operates on 3 qubits. Here we use ",[16,1530,686],{}," control qubits to apply a ",[29,1533,1220],{"href":1219}," to a ",[16,1536,1537],{},"single"," target qubit.",[21,1540,1542],{"id":1541},"ungated","Ungated",[12,1544,1545,1546,176],{},"Now that you’ve had a crash course in quantum gates, it’s probably a good time to step away from the screen, take a walk, and let some of this sink in. When you’re ready when can begin to explore ",[29,1547,1548],{"href":166},"coding quantum circuits",{"title":108,"searchDepth":109,"depth":109,"links":1550},[1551,1552,1561,1566],{"id":1166,"depth":109,"text":1167},{"id":1271,"depth":109,"text":1272,"children":1553},[1554,1555,1556,1557,1558,1559,1560],{"id":1275,"depth":137,"text":1276},{"id":1282,"depth":137,"text":1220},{"id":1304,"depth":137,"text":1305},{"id":1319,"depth":137,"text":1320},{"id":1339,"depth":137,"text":1340},{"id":1365,"depth":137,"text":1366},{"id":1387,"depth":137,"text":1388},{"id":1402,"depth":109,"text":1403,"children":1562},[1563,1564,1565],{"id":1406,"depth":137,"text":1407},{"id":1416,"depth":137,"text":1417},{"id":1439,"depth":137,"text":1440},{"id":1541,"depth":109,"text":1542},[116,117,118,400],[],{"username":7,"name":121,"role":122,"avatar":108},"Quantum logic gates are the means of “getting work done” on a quantum computer. They perform computation by altering the values of quantum bits (“qubits”).","That’s Quantum foundations, start to finish.",{"image":1573,"alt":400},"\u002F_content\u002Fimages\u002Fgates\u002Fhero.webp",{},{"slug":1576,"title":1577,"desc":1578},"\u002Fblog\u002Flearn\u002Fbuilding-your-first-qollab-project\u002Fpython-setup","Building your first Qollab project","Set up Python and Qiskit, run your first circuit on real IonQ hardware, then publish your project to Qollab.","19 min read",[],{"title":1582,"description":1570},"Quantum logic gates · Quantum foundations","blog\u002Flearn\u002Fquantum-foundations\u002Fgates",[],"lj0dFuGB70GbmrrYMH9tGLvx_mN6vH9iiLvjJs5j3_w",1785631563495]