
In this tutorial you can learn what a qubit is, why qubits can be in superposition states, where the randomness in quantum mechanics enters, and why quantum computers can do things that classical computers cannot.
This tutorial provides the necessary knowledge to understand all other tutorials and to use our interactive quantum circuit simulator to run simple quantum algorithms on our servers.
Prerequisite Tutorials:
None
Prerequisites
This primer on quantum mechanics & quantum computing targets a general audience with high school equivalent background in physics & mathematics. No academic degree required!
If you have learned about the following concepts, you are ready to go:
- Vectors
- Probabilities
- Trigonometry
- Complex numbers (optional)
The mathematical tools needed to understand and apply quantum mechanics are actually not too complicated. To provide perspective: All required mathematical concepts are taught in the first two semester of a typical study program in physics, mathematics, and even informatics or engineering. Quantum mechanics draws heavily from both analysis (integrals, differential equations, …) and linear algebra (vectors, inner products, linear maps, …). To describe quantum computers on an abstract level (to write “quantum programs”) linear algebra is even sufficient.
Reminder:

Meta-Knowledge
As a layperson (in this context: non-physicists), it is often hard to assess the status of scientific statements: are we talking about speculations, hypotheses, widely accepted theories, or well-tested observations? This “knowledge about knowledge” or “meta-knowledge” is just as important as the knowledge itself. To prevent misconceptions in this regard, here a few “meta-knowledge” facts about the knowledge you can learn in this tutorial:
- The tenets of quantum mechanics, with all their quirks and counterintuitive phenomena, are by now a well-established, extensively tested theory. This is as good as it gets in science. The formalism explained in this tutorial is learned (in a more mathematical fashion) by every undergrad of physics around the globe, just as you learn adding and multiplying numbers at school. From a physicist’s perspective, quantum mechanics is not a fancy or “esoteric” field of study (it is certainly interesting, though). This also means that none of the predictions of quantum mechanics presented here are hypothetical. All of them have been experimentally tested repeatedly. Seemingly “strange” quantum phenomena like superpositions, entanglement, quantum “teleportation”, etc., are by now standard tools in laboratories (some even in advanced lab courses and/or commercial devices). Creating entangled pairs of photons is for an experimental quantum physicist like mixing a salad dressing is for a professional chef: It’s nice that you can produce them, it is certainly useful for your job, but it’s nothing to be excited about.
- Since the predictions based on quantum mechanical laws (in their precise mathematical form) perfectly match experiments, we trust these equations like engineers trusts the laws of classical mechanics to construct airplanes. Consequently, we can use them to engineer “quantum machines” like a quantum computer. So if you ask how a specific quantum phenomenon can be theoretically modeled and explained, you most likely will be given a precise answer.
- The situation is very different if, instead of how, you ask why a certain phenomenon is the way it is. The question why entanglement exists in our universe, and why quantum mechanics is a probabilistic theory, are important and deep questions that should be asked. You will not find answers to these questions here because, as of now, there is no consensus among physicists what the correct answers are. There are hypotheses, untested theories, that draw rough pictures of what quantum mechanics might tell us about reality — but none of them are clearly backed by experiments. In this sense, quantum mechanics is a highly useful theory as it stands, but it might be expanded into another, deeper theory in the future. This does not mean that quantum mechanics is potentially wrong (it is not, it works perfectly in our experiments!). It only means that its range of validity may be restricted; just as Newtonian mechanics has not been “proven wrong” by Einstein’s general theory of relativity (it is the limit of Einstein’s theory for small velocities and small masses.). The bottom line is: There is still fundamental work to be done and new features of our world are waiting to be discovered, but quantum mechanics, as we teach and use it today, will never lose its merits.
- Luckily, an engineer does not need to know a deeper reason for gravity (like the general theory of relativity) to build an airplane; understanding the laws of classical mechanics is completely sufficient. For the same reason, we are not hindered by the fact that we cannot explain why quantum mechanics is the way it is on our quest to build a quantum computer.
From Vectors to Qubits
Note for experts:
In this tutorial we restrict amplitudes to real numbers instead of complex numbers to make it accessible for high school students.
We comment on the role of complex numbers at the end.
Qubits are the elementary carriers of information of a quantum computer. They play the same role as the bits stored on the hard drive of your notebook which are processed by its central processing unit (CPU) to make fun stuff happen (like printing these letters on your screen). Similarly, a quantum computer must be able to store qubits on a “quantum hard drive” (this is called a quantum memory) and to manipulate qubits on some sort of “quantum CPU” (a quantum processor). The goal of the QRydDemo project is to build such a quantum processor, where each qubit is encoded by a single atom and the manipulations are done by hitting these atoms with lasers (see Platform for more details).
When you think about the bits whizzing around in your notebook, you typically do this in an abstract way: they are just “things” with two possible states (1 or 0); you completely ignore what exactly these two states are (like: high/low voltage in wires, or up/down magnetization on the disc of a hard drive). Why? Because it is a useful abstraction for writing programs! The same is true for programming quantum computers: While the “quantum engineers” (that’s us) who build a quantum processor must be aware of how the qubits are implemented, the “quantum programmer” who uses the quantum computer to run “quantum software” can safely ignore these details and think of qubits as abstract pieces of quantum information. In the following, we will speak about qubits and the things we can do with them in this abstract way. This abstract level to talk about quantum mechanical systems is called quantum information theory.
But what is a qubit, abstractly speaking? One often hears that “a qubit is like a classical bit that can be 0 and 1 at the same time” – but what does that actually mean? Whenever words are too vague to explain things, mathematics comes to the rescue:
Let us start with a fancy classical bit. Instead of “0” and “1”, we use the two orthogonal vectors
The most general linear combination of our two “bit vectors” is the vector
The state of a single qubit is described by a two-dimensional vector
This is correct, but we missed one point. The vector that describes the state of a qubit must have length 1 (in mathematics one calls such vectors normalized):
To realize a qubit in the laboratory, one needs a system with two internal states that are then labeled by

The white boxes are drawn on top of the image to mark the position of the atoms, so that we know their location even when they are not excited by a laser (they are then dark and invisible). And yes, every glowing blob in the above photograph is a single atom.
Each of these atoms is used to realize a qubit. But what are the two states? From chemistry you know that the electrons of an atom all live in a discrete set of orbitals. Orbitals look like strangely shaped clouds around the nucleus of the atom, and their density tells you the probability to find an electron at that position. Orbitals are the quantum mechanically correct description of the energy levels in the simpler (and outdated) Bohr model. Their existence and shape are a direct consequence of quantum mechanics, but here we simply want to use them as our two states! Thus we pick two specific orbitals of Strontium, let us call them

An atom with electrons in orbital
Now you know how we realize qubits in our laboratory. But why single atoms, you might ask? Isn’t it very complicated to work with single atoms? (It is!) Why not larger objects that are easier to control? This is a good question and it has to do with our next topic: measurements. You will see below that in quantum mechanics obtaining information about the state of a qubit changes the state itself. But this means that if something (say, an air molecule or a single photon) bumps into your qubit and carries away information about its state, this interaction perturbs the qubit. For a qubit to be useful, one must therefore be able to shield it almost perfectly from all possible environmental influences. This shielding is much easier for atoms in vacuum than for larger (“macroscopic”) objects that very easily spread information about their state into the environment. So yes, controlling single atoms is hard, but we are rewarded with qubits that preserve their quantum states long enough so that one can hope to do useful computations with them.
Let us now return to our abstract description of qubits and discuss how measurements are described in quantum mechanics.
- The state of a qubit is described by a two-dimensional vector of length one. A qubit is not a classical bit that is in an unkown state 0 or 1.
- The state vector can be constructed as a linear combination of two orthogonal basis vectors; these linear combinations are called superpositions.
- The components of the vector are called amplitudes and can be negative. Their potential negativity is a crucial feature of quantum mechanics and allows for interference, a phenomenon that underlies the speedup of quantum computers.
- The QRydDemo project realizes qubits by single Strontium atoms that are trapped by lasers. The states of a qubit correspond to the states of the electrons in the shell of a Strontium atom.


Beware:
The vector
Beware:
The glowing blobs in the photograph of 10 atoms stretch over several pixels and give the impression of being “out of focus”. They look a bit like a distant planet viewed through a cheap telescope. This analogy is misleading! If you use a better telescope, the image of a planet becomes sharper and more resolved; eventually, you’ll see its pole caps, mountains and valleys. No matter how good our microscope and our camera are, the blobs will never become “sharp” and show you how an atom really “looks like”. Strontium atoms have a diameter of roughly 0.1 nanometer. The light we use to make the photograph has a wavelength of roughly 500 nanometer! It does not make sense to ask how something “looks to the eye” on this scale. It doesn’t look like anything!
Let that sink in.
Measurements
If you think about it, our hypothesis that the state of a qubit is described by a two-dimensional vector
This rule, which has been confirmed by hundreds of quantum mechanical experiments by now, was formulated by the physicist Max Born and is thus called the Born rule. Let us highlight the three important (and unintuitive!) features of a quantum mechanical measurement:
- The outcome of the measurement is discrete (either
or ) although the quantum state can point in any direction (= is continuous). This emergent discreteness is called quantization and responsible for the name “quantum” in “quantum mechanics”. - The measurement outcomes are probabilistic:
and are measured randomly with probabilities and (which depend on ). This is the famous randomness of quantum mechanics which Albert Einstein didn’t like (see below). - The quantum state is changed by the measurement, i.e., the state changes from
to either or , depending on the measurement outcome. In quantum mechanics, measurements are thus not passive observations (like in classical physics), but affect the system that is observed! This phenomenon is known as wave function collapse.
The Born rule also explains why the vector
There is a very convenient way to parametrize such vectors: They correspond exactly to the points on a circle of radius 1 (a unit circle). But a point on the circle can be described by a single angle
Let us summarize what we learned so far:
The state of a single qubit is described by a two-dimensional vector
If the qubit is measured, it is found either in state
The measurement changes the state of the qubit and is probabilistic.
The change of the qubit state by measuring it — the wave function collapse — is a fundamental principle of quantum mechanics. The fact that the outcome is undetermined until the measurement is performed (and only probabilities can be predicted) makes quantum mechanics an inherently probabilistic theory, a fact that vexed Albert Einstein who exclaimed that “God does not play dice […].” However, in the days since Einstein, experiments of physicists all over the world repeatedly confirmed the predictions of quantum mechanics, and clearly indicate that nature is somewhat of a gambling addict. To fathom the philosophical ramifications of the probabilistic measurement outcomes completely, one must be very clear about the type of randomness we are talking about: If you put a coin in a cup, shake, and put the cup upside down on the table, you have no clue whether the coin landed head or tail until you lift the cup and look. You could say the coin is like a qubit in that you can only predict the probabilities of head and tail when lifting the cup. This analogy is false, though! The difference is that although you do not know whether the coin landed head or tail when the cup hides it, the coin of course landed either head or tail. The probability just reflects your lack of knowledge of the real state of the coin (you could use the X-ray apparatus you happen to have beneath the table to look through the table and check this!). For all we know — and there are ingenious experiments known as Bell tests that support this — the probabilities predicted by quantum mechanics are not consequences of you, the observer, not knowing the “real” state of the qubit before a measurement. The “real” state of the qubit is
At the QRydDemo project, we are no philsophers of science, we are “quantum engineers” who want to build a quantum computer. But still we are affected by this inherent randomness: Whenever a quantum computer performs transformations on its qubits, we have to measure them at the end to extract the outcome of the algorithm. The results we get will be randomly distributed according to some probabilities. This means that quantum algorithms must be run several times (on the order of hundreds to thousands) so that all collected results can be averaged. These averages (which approximate the probabilities predicted by quantum mechanics) are then the real result of the quantum computation. The different runs of the same algorithm to collect data for the averaging are called “shots” in quantum computing parlance.
- Measurements in quantum mechanics are described by the Born rule according to which a qubit is measured in one of two discrete states with probabilies that equal the squares of the amplitudes of its state vector.
- State vectors must be normalized because we interpret the squares of their amplitudes as probabilities.
- Measurements in quantum mechanics modify the state of the object measured. This is called wave function collapse.
- The measurement process makes quantum mechanic a probabilistic theory. For quantum computing this implies that algorithms must be run several times to compute averages.
- The randomness of measurement outcomes is not due to a lack of knowledge of “hidden parameters”.


Beware:
Measuring is often sloppily referred to as “looking at” or “observing” the qubit. However, according to the standard interpretation of quantum mechanics, the measurement process does not have to involve a conscious being (like you) observing the qubit. A measurement in the quantum mechanical sense is any interaction that spreads information about the state of a system into its environment. For instance, pointing a laser at an atom and recording its state with a digital camera counts as measurement (even if you do not look at the taken picture). This also means that a single photon bumping into a qubit can set off an avalance of information about the qubit’s state that spreads into the environment. This makes the realization of qubits so hard because one must prevent these “accidental measurements” that collapse the qubit state at all costs.

There are alternative, less popular interpretations of quantum mechanics that predict the same outcomes as the Copenhagen interpretation but interpret the measurement process and the role of the quantum state differently. For example, hidden-variable theories and of course the quite famous Many-worlds interpretation.
Quantum physics notation
If you previously encountered a text on quantum mechanics, you may wonder why none of the above formula look familiar. The reason is that physicists (more precisely: Paul Dirac) invented a fancy notation for vectors:

Rephrased in this new notation, a point on the unit circle describes the quantum state
To be fair: this change of notation is not just to make quantum mechanics “look fancy.” There is a deep mathematical reason why this is a very convenient notation, but this goes far beyond this tutorial. (The notation is called Dirac- or bra-ket notation; the mathematical reason is known as Riesz representation theorem and has to do with how inner products are calculated in this formalism.)
We will stick to this notation in the following because it makes it easy to generalize quantum states to many qubits.

Beware:
The terms “quantum state” and “wave function” are often used synonymously. The reason is that historically, the first quantum states described where a quantum mechanical particle is located in space. These quantum states are functions and typically have a wave-like nature, hence “wave functions”. The states
Many qubits
So far we only talked about a single qubit. Just as a computer that can store a single bit is useless, a quantum computer with a single qubit is nothing to be proud of. To make quantum computers shine, we need many qubits. Two questions come to mind immediately: How to describe the quantum state of many qubits, and how many is “many” to make a quantum computer useful?
Quantum states of many qubits
To answer the first question, we must let go of the possibility to visualize the different states many qubits can have; the image of a circle motivated above really only works for a single qubit. The mathematical formalism of linear combinations of vectors, however, carries over to as many qubits as we like. If we follow the concept of measurements in quantum mechanics, we should expect that if we measure
Let us consider an example: If we have only
In general, there are
The abstract expressions we are particularly interested in as quantum physicists are linear combinations, of course. After all, that is what quantum mechanics is all about. The most general linear combination of the four basis vectors for
Before we proceed with answering how many qubits we need, let us digress and see how we measure a many-qubit quantum state on the QRydDemo platform. Recall that our qubits are encoded in the electronic states (orbitals) of single Strontium atoms, each trapped by a laser at a fixed position. The two orbitals

We can then read off the measured state by checking the boxes: dark boxes correspond to a qubit in state
- When measured,
qubits can be observed in the possible configurations of classical bits. - Each outcome is described by a normalized vector that is orthogonal to all other outcome vectors. A general quantum state of
qubits is therefore a linear combination of these vectors and belongs to a -dimensional vector space. - The quantum state of
qubits cannot be visualized in our three-dimensional world. - The quantum state of
qubits is completely specified by its real amplitudes. - The Born rule generalizes to many qubits. The probabilities for measurement outcomes are still given by the squares of the corresponding amplitudes.
- On the QRydDemo platform, we measure the quantum state of many qubits with a laser of a specific wavelength. Strontium atoms in state
glow, whereas atoms in state remain dark.
Beware:
One might be tempted to think of the state of
How many is “many”?
Now that we know what a “many-qubit quantum state” looks like (abstractly and in reality!), we can finally answer the second question, namely how many qubits are needed to make a quantum computer useful. To this end, let us assume we have a classical computer (right now that’s all we have anyway) and would like to simulate how the quantum state of
We have learned an important lesson: A machine that can store and manipulate around
The next question is of course why we sould be interested in the outputs of such a quantum machine in the first place? Just because a result is hard to compute doesn’t make it useful. What are the tasks that make a quantum computer shine?
- Because the number of amplitudes to describe a quantum state of many qubits is exponentially large in the number of qubits, storing the quantum state of 100 qubits already requires roughly 1018 Terabyte of storage on a classical computer.
- Therefore classical computers cannot be used to simulate quantum systems with many degrees of freedom (e.g. many electrons).
- By contrast, quantum computers can simulate quantum mechanical systems much faster than classical computers.
- The capabilities of a quantum computer with about 100 qubits is already far beyond anything we can (and will ever) simulate on a classical computer.
- While quantum computers can speed up classical problems like integer factorization and database queries, their most important application is the speedup of quantum mechanical simulations, e.g., for drug development and materials science.
Beware:
In our counting of qubits we assumed that these qubits are “perfect”, i.e., not affected by noise. In reality, this is almost impossible to achieve, which is why one has to “merge” several of these noisy “physical” qubits to form a robust “logical” qubit. This procedure is known as quantum error correction and blows up the number of (physical) qubits considerably. This is one of the reasons why building a full-fledged quantum computer is so hard.
What are quantum computers good at?
Quantum computers are good at manipulating qubits without having to store their amplitudes like a classical computer. To store the quantum state of 100 qubits on the QRydDemo platform, we need, well, 100 qubits. Since every qubit is realized by a single Strontium atom, we only require 100 atoms to encode and manipulate a quantum state that, on a classical computer, would require more memory than we can imagine. That’s why quantum computers are so fascinating: they can store and manipulate quantum states without having to pay with staggering amounts of memory like classical computers.
If we take a step back, we catched a glimpse of a much deeper insight:
Quantum computers are good at simulating quantum mechanics.
The first who pointed this out was the famous physicist Richard Feynman who advertised quantum computers as efficient simulators for quantum mechanics, today known as (digital) quantum simulators.
This statement seems tautological. It sounds like “a classical computer is good at simulating electronic circuits”. True! But we also learned that:
Classical computers are really bad at simulating quantum mechanics.
Unfortunately, we know that our world, at the deepest levels, is governed by quantum mechanics. For example, the Standard Model of particle physics that describes quarks and electrons and the like is a quantum mechanical model. And if we want to compute it’s predictions to compare them to measurements made at particle colliders like CERN we somehow must “simulate the theory”, i.e., evaluate its predictions. But this is hard (or even impossible) on classical computers as we just learned. Another example is the simulation of materials like high temperature superconductors (which are used in MRI scanners); their strange (and useful) feature of superconductivity is an effect of many interacting electrons — which are governed by quantum mechanics! Again, physicists have a really hard time to understand (and design) these materials because we would need a machine that can simulate quantum mechanics. We would need a quantum computer! You could also ask why chemists, who develop novel drugs or more efficient solar cells, have to perform expensive and time consuming trial-and-error experiments. Chemistry is, after all, “just” applied quantum mechanics: when you trigger a chemical reaction where electrons and nuclei form new molecules, the equations of quantum mechanics should (and could) tell us what the result will be and which properties it has. Why bother with experiments? Well, because we cannot solve the equations for the very reason explained above: too many amplitudes! A quantum computer could simulate these reactions and considerably speed up materials science.
At this point you may wonder: Wait, isn’t the “killer application” of a quantum computer the famous Shor algorithm that can break the RSA cryptosystem by exponentially speeding up prime number factorization? Or the Grover algorithm that can speed up the search in big databases? Sure, the Shor algorithm certainly is very useful if you happen to work at an intelligence agency, and the Grover algorithm can save you a lot of money if you run a search engine like Google. These algorithms emerged as “poster boys of quantum computing” because their uses are easy to explain and easy to grasp, even without knowledge of quantum mechanics. But now that you do have knowledge of quantum mechanics, it should be clear that speeding up drug development and material science will benefit us in ways that go far beyond speeding up integer factorization and database queries. In a nutshell:
The “killer application” of quantum computing is the
simulation of quantum mechanics.
This statement is of course much harder to sell than “we can break cryptography”.
Beware:
One might be tempted to think of quantum computers as “classical computers with exponentially large amounts of memory”. This is false! Quantum computers cannot magically improve classical algorithms; the famous Shor algorithm for integer factorization is a rare exception, not the rule. The reason that quantum computers can efficiently store quantum states is that they are naturally described by such states, not because they have gigantic amounts of classical memory (they don’t). Imagine you put a few drops of milk in your coffee and observe the intricate patterns that evolve. Physically, this is a problem of fluid dynamics, and simulating this process with high precision on a classical computer requires a lot of ressources (memory, computing time etc.). But you just computed all the answers in your coffee mug! For free! Does this mean we can retire all our supercomputers and henceforth use your “magic mug” to run simulations of high-energy physics? Of course not. Your coffee happens to be good at “simulating” a particular kind of fluid dynamics problem because this is its natural behaviour. It is by no means functionally equivalent to every machine that is able to simulate the same process. Quantum computers are like your coffee: they are extraordinarily good at simulating quantum mechanical problems, but that does not make them good at everything.

Manipulating qubits
We already mentioned that a quantum computer is a machine that can store and manipulate the state of many qubits. How the quantum state of many qubits is mathematically described you already know. But what about the “manipulation part”? How do we describe what the quantum computer actually does?
Because of the probabilistic nature of quantum mechanics, a quantum computation must be run several times so that one can average over the outcomes. These runs are called shots and a single shot can be split into three steps:
Let us focus on a single qubit for simplicity (the generalization to many qubits is again mathematically straightforward, but impossible to illustrate). Transformations in the context of quantum computing are called (quantum) gates. The transformation that a gate performs (let us call it
Transformations of quantum states are described by linear maps.
Linear maps play a pivotal role in many fields of physics, mathematics and engineering. For example, most of the work done by the graphics card in your computer to render the frames of a video game can be described by linear transformations. That quantum mechanical transformations are linear maps is a crucial feature of quantum mechanics with far reaching consequences. For example, the fact that arbitrary quantum states cannot be copied perfectly (a mathematical statement known as No-cloning theorem) is a direct consequence of linearity. Also the fact that quantum mechanics cannot be used for faster-than light communication (as warranted by the No-communication theorem), and therefore plays nicely with Einstein’s special theory of relativity, is tightly linked to its linear structure.
Is every linear map
Transformations of quantum states are described by orthogonal maps.
You may not have heard of the term “orthogonal map” but you know what they are! Recall that all we demanded of the linear map was that it transforms vectors of length one into vectors of the same length. It is an easy exercise to show that this is equivalent to the requirement that the map does not change the length of any vector (so a vector of length
- The purpose of quantum computers is to implement quantum algorithms that transform simple quantum states into more complicated ones.
- Operations that change the state of qubits without measurements are called quantum gates.
- Quantum gates are linear maps and completely determined by their action on the basis states.
- Quantum gates can be thought of as rotations and reflections in high-dimensional vector spaces because they do not change the length of vectors. Such transformations are known as orthogonal maps.
- The linearity of quantum mechanical transformations has important consequences, for example, that arbitrary quantum states cannot be copied perfectly. This is known as No-cloning theorem.
- An important example for a single-qubit gate is the Hadamard gate that creates superposition states.
Example: The Hadamard gate
It is time for an example. There are of course infinitely many different gates that one can use to transform a qubit (because there are infinitely many rotations). Some gates that are used repeatedly in many different “quantum algorithms” have been given names and special symbols to refer to them. One of the most important quantum gates that transforms a single qubit from its initial state
Since we now know that

Note that the reflection at the y-axis does not affect the vector

Many gates
The example above showed us an important property of gates in general: multiple gates can be combined to form new gates, and the “recipe” for their combination is simply their concatenation, i.e., one applies the first transformation (above: the reflection), then one applies the next transformation on the result of the first transformation (above: the rotation). The reason why this works is that the concatenation of two orthogonal maps again yields an orthogonal map. Intuitively this is clear: if two maps do not chance the length of vectors, their combination will neither. Let us collect all orthogonal maps in a set and call this set
The set
The specific group
The transformations of a single qubit form the orthogonal group
Let us demonstrate the concatenation of gates again with the Hadamard gate. We start with a geometrical argument and then verify the outcome with abstract algebra. Our goal is to concatenate the Hadamard gate with itself, i.e., to apply it twice to the

Note how the second application leads us back to where we started,
More generally, the calculation illustrates that the application of two (or more) concatenated gates on a state is no rocket science. One applies the gates one after another according to the rules of linear maps discussed earlier. After each application, it is convenient to use the rules of vector algebra to simplify the linear combination until every basis state (
The concatenation of many quantum gates on many qubits to implement a specific target transformation is what quantum computing is all about. Such a sequence of quantum gates is called a quantum algorithm, the quantum analog of a program that runs on a classical computer. But because quantum computers are only useful if they can manipulate many qubits, we should briefly discuss how gates operate on such states.
- Quantum gates can be composed by concatenating their actions.
- The set of all single-qubit gates forms a mathematical structure know as the orthogonal group.
- Groups are important structures used in many fields of physics. Groups have the important property that all their elements have an inverse element that undoes their action.
- The Hadamard gate can be illustrated as the concatenation of a reflection about the y-axis and a clockwise rotation by 45°.
- The Hadamard gate is its own inverse: Applying the Hadamard gate twice restores the original quantum state.
Beware:
Not all gates are their own inverse transformations. This is actually a rather rare property. The Hadamard gate is therefore an exception and not the rule. Consider rotations by some angle
Many qubits
Remember that quantum states of
To define a quantum gate
The Hadamard gate
Let us start again with the Hadamard gate and consider a setup of
Can you write down the transformation rules for
Solution
The transformation rules for the Hadamard gate
The Controlled-NOT gate
Of course there are also gates that take into account the configurations of both qubits (and potentially change these configurations). Such gates are called multi-qubit gates in general and two-qubit gates if they operate on exactly two qubits. A particularly important two-qubit gate is the Controlled-NOT gate
Can you write down the rules for
Solution
The transformation rules for the Controlled-NOT gate
- Quantum gates on many qubits are orthogonal maps (rotations and reflections) in a high-dimensional vector space.
- For
qubits, a quantum gate is specified by the transformation rules of the basis states. - Single-qubit gates like the Hadmard gates must be labeled by an index to indicate on which qubit it is applied.
- The transformation rules of single-qubit gates take into account and modify only the configuration of the qubit that they are applied to.
- Gates that take into account (and potentially change) the configurations of multiple qubits are kown as multi-qubit gates.
- The Controlled-NOT gate is an important example of a two-qubit gate. It flips the state of one qubit (the target) if and only if the state of another qubit (the control) is
.
Many gates & many qubits:
A simple quantum algorithm
As a last example, let us construct a simple quantum algorithm on two qubits with a fascinating output (you’ll see!). Our goal is to concatenate the Hadmard gate
We start with the Hadamard gate on the first qubit:
Note how the second state in the linear combination transformed from
So what? Where is the “fascinating output” that we promised? To cherish the strange properties of the Bell state
But isn’t that strange? Imagine you prepare the Bell state in your laboratory on Earth (using our algorithm above), and then, before measuring, you send one of the two qubits with a spaceship to Mars (you hide both qubits in sealed boxes so that no measurement occurs). Then you open your box on Earth, and, simultaneously, an astronout opens the box on Mars, thereby perfoming a measurement of the qubits. Above we computed that the qubits on Earth and Mars will always be measured in the same random state! As if there was a hidden communication link between them to synchronize their random measurement outcomes, as if they where somehow … entangled. Indeed, the Bell state
By the way, what would you find if you omit the Controlled-NOT gate from our algorithm above and only apply the single-qubit Hadamard gate
Solution
Without the Controlled-NOT gate, we would measure the state
We learn that the single-qubit Hadmard gate alone is not enough to produce entanglement. The two-qubit Controlled-NOT gate was absolutely crucial! One can show that this is a general mathematical fact: Quantum algorithms with only single-qubit gates never produce entangled states. To produce entanglement, multi-qubit gates like
- Concatenations of many gates on many qubits are called quantum algorithms.
- A simple quantum algorithm is the application of a Hadamard gate, followed by a Controlled-NOT gate. The algorithm produces a so called Bell state.
- In a Bell state the two qubits are said to be entangled because measuring one of the qubits determines the measurement outcome of the other qubit.
- Entanglement can only be produced by multi-qubit gates. Single-qubit gates alone are not sufficient.
Entanglement
Now you know what the famous entanglement in quantum mechanics is! You learned even how to produce it with a quantum algorithm. That there seems to be a “hidden communication link” that synchronizes the two qubits instantaneously (in particular: faster than the speed of light!) was disliked by Albert Einstein so much that he referred to it as a “spooky action at a distance” — or at least so the story goes. Historically, the quote goes back to a 1947 letter by Einstein to Max Born (the one with the Born rule); he writes:
I cannot make a case for my attitude in physics which you
Albert Einstein to Max Born, March 3, 1947
would consider at all reasonable. I admit, of course, that there
is a considerable amount of validity in the statistical approach
which you were the first to recognise [..]. I cannot seriously
believe in it because the theory cannot be reconciled with the
idea that physics should represent a reality in time and space,
free from spooky actions at a distance. I am, however, not yet
firmly convinced that it can really be achieved with a continuous
field theory […].
In the letter, Einstein doesn’t mention the term “entanglement” at all (the term has been coined by Erwin Schrödinger more than 10 years earlier). His distress seems to stem from the collapse of the wavefunction that comes along with Born’s statistical approach to the measurement process. Remember that according to the Born rule, the quantum state is updated instantaneously to match the measurement outcome. In our thought experiment above, this update affects the common quantum state of both particles, irrespective of their distance. It is this instantaneous change of a non-local entity (the quantum state) that Einstein was at odds with because it heralds the downfall of local realism. “Local realism” is what Einstein means with “[…] the idea that physics should represent a reality in time and space“, i.e., the state of the world is completely specified at any point in time by local pieces of information. Intuitively, we are all like Einstein (local realists, that is) because the world we perceive in our everyday lives can be modeled in this way. It is actually hard to imagine what a world that is not locally realistic would be like.
Hence it may be discomforting to hear that most modern physisticst are convinced that our world is not locally realistic. This is indeed a consequence of entanglement, but not of the thought experiment we contrived above. When we discussed the measurement results of the two entangled qubits on Earth and Mars, we tricked you into believing that something “strange” is going on. After all, entanglement is supposed to be one of the strangest effects in quantum mechanics, right?! But imagine the following (classical) experiment: Put a blue and a red ball into box that can be separated into two boxes with a slider in the middle. Shake the box and ensure that one ball landed in each half of the box (do this without opening the box by checking that the weight of the box is balanced). Now close the slider and split the box into two sealed boxes, each containing a single ball. One of the boxes again is sent to Mars, one is left untouched in your laboratory. When you open the box, you find a red or a blue ball with equal probability, just like the qubit. But in the same moment, you know with certainty what an astronout on Mars will find in their box! If you find a blue ball, they will find a red one (and vice versa). Is there a “hidden communication link” between the two balls to make the ball on Mars red when yours is blue? Of course not, this is ridiculous! The experiment just illustrates the concept of correlations, and correlations have nothing to do with quantum physics. Our classical world is full of objects that are far apart but “know” things about each other: When you and your friend have the same pencil case and, after school, you rush home to find that you accidentally swapped the cases, you immediately know that your friend currently misses her pen. You didn’t have to call her to know this. You gained information about your friends current experience without any exchange of information, instantaneously! But this is neither surprising, nor “spooky”, and certainly does not violate the theory of relativity, according to which information is not allowed to travel faster than the speed of light. The correlation between your two pencil cases has been established locally (when you swapped them at school), just like the correlation between the two balls has been established locally (when you prepared the box on Earth). Similarly, the observation that the two qubits of our entangled quantum state always have the same value is another example of a correlation that has been setup locally (it is impossible to apply a Controlled-NOT gate on two qubits that are far apart). This implies in particular that quantum entanglement does not violate Einstein’s theory of relativity:
Entanglement cannot be used to send information faster than light!
We discuss this in more detail in our tutorials where you can implement the entanglement-producing algorithm above on our simulator of a quantum computer.
- Entanglement is a special form of correlation in quantum mechanics.
- The correlations of entangled states are stronger than any classical, locally realistic theory allows. This is the statement of Bell’s theorem.
- Local realism is a view, advocated by Albert Einstein, according to which the state of the world is completely specified at any point in time by local pieces of information.
- Experimental Bell tests showed that the predictions of quantum mechanics are correct. This means that our world is not locally realistic.
- Entanglement cannot be used to send information faster than light. Quantum mechanics is consistent with Einstein’s special theory of relativity.

One of the postulates of Einstein’s special theory of relativity is that the speed of light in vacuum
But if entanglement is “just” a type of correlation, why is there so much hype about it among physicists? The reason is that it is a surprisingly strong type of correlation (called quantum correlation) that cannot be explained by theories that adhere to Einstein’s tenet of local realism. This “strength” is already hidden in the entangled Bell state that we prepared with our quantum algorithm above; however, a more sophisticated measurement procedure is needed to unveil it (which is a bit too technical for this tutorial). The upshot is that one can show and quantify mathematically that the correlations of the Bell state cannot be realized by classical systems that are described by local pieces of information (like the color of the two balls or the contents of the two pencil cases). This mathematical statement is known as Bell’s Theorem, an inequality for correlations that is violated by quantum mechanics. Experiments known as Bell tests have demonstrated beyond any reasonable doubt that the Bell inequality is indeed violated, and the predictions of quantum mechanics are correct. This implies that the locally realistic worldview advocated by Einstein does not match reality. It is this result that makes entanglement and quantum mechanics “weird”, or at least unintuitive. In a nutshell:
The “strangeness” of entanglement is not the existence of correlations, but their strength which cannot be explained by locally realistic theories.
Note that Bell’s Theorem was published in 1964 and the first Bell test was performed in 1972 by John Clauser (for which he was awarded the 2022 Nobel Prize in Physics, jointly with Alain Aspect and Anton Zeilinger), long after Einstein died in 1955. It would be fascinating to hear what Einstein had to say about these results.


Relative and Global Signs
There is one last thing about quantum states that we swept under the rug: The role played by the sign of amplitudes. Remember that we introduced the amplitudes
Let us consider exemplarily the following two states which both have at least one negative amplitude:
- That amplitudes can be negative is an important feature of quantum states.
- Pairs of quantum states that yield the same probability distribution for measurement outcomes can yield different measurement results if one applies a quantum gate prior to the measurement.
- Signs that affect only some of the amplitudes are called relative signs. Vectors that differ by relative signs can be experimentally distinguished and correspond to distinct quantum states.
- Pairs of quantum states which differ only in a global sign (that affects all amplitudes) cannot be distinguished by any combination of gates and measurements. Such vectors describe the same quantum state. We say that quantum states are equivalence classes of vectors.
For a start, let us take the Hadamard gate
The fact that probability amplitudes can become negative is important.
In particular, quantum states are more than mere probability distributions.
The phenomenon of interference in quantum mechanics can only be explained with the negativity of probability amplitudes. The fact that amplitudes can be positive or negative allows for cancellations that supress the probability for certain measurement outcomes. For example, the famous double-slit experiment demonstrates the interference of the wave function of single particles (like electrons); in regions where the probability to find particles vanishes, positive and negative amplitudes cancel. The role played by interference in quantum computing is explored in one of our tutorials.
While this statement is true, it is missing a very important “but”. To understand why, let us focus on the other pair or of states
Yes, they are; but only if they are relative signs, i.e., signs that affect some but not all amplitudes of a linear combination. By contrast, global signs affect all amplitudes in the same way and these signs cannot be measured. Our two examples illustrate this difference, which is formally reflected in the following two (in)equalities:
What we just showed above for the special case of
Vectors that differ in relative signs describe different quantum states.
Vectors that differ in global signs describe the same quantum state.
Therefore:
Quantum states are equivalence classes of of the form
The fact that global signs do not influcence the outcomes of arbitrary sequences of gates and measurements is a direct consequence of the linearity of quantum gates. The example illustrates this: the global minus sign in

The Bloch Circle
What a bummer! It seemed that we can visualize the state space of a single qubit nicely by our circle of unit vectors, but now we have to concede that this is not exactly right: Since the antipodes on the circle correspond to the equivalence classes
We would like to find a space where every point can be mapped one-to-one to a pair of antipodes

This means that there is a one-to-one correspondence between rays and quantum states (If I give you a ray, you know which quantum state
This is all very nice, but let’s be honest: imagining a space made out of “rays” is somewhat strange. Intuitively, spaces should be made out of “points” of some sort. Is there a way to construct a space where every point corresponds to exactly one ray through the origin (and therefore to one quantum state)? Yes! Just attach an infinite real line

Every ray defines one point on this line, and, vice versa, every point on the line defines a ray. Perfect! Wait, every ray? No, every ray but the horizontal one that corresponds to the quantum state

Note that there is really only one point “
Great, you say, we got rid of the rays but now we have a point “
- In mathematics, spaces made out of equivalence classes are called quotient spaces.
- An example is the space of the equivalence classes that describes all possible quantum states of a single qubit. This particular quotient space is called the real projective line.
- The real projective line can be illustrated as a unit circle, known as the “Bloch circle”.

Finally! The state space of a single qubit is the real projective line
Since we cannot directly linear combine equivalence classes
Beware:
You may wonder: How is it possible that we start from a unit circle, merge all points with their antipodes into one point, and again end up with a unit circle (the Bloch circle)? Shouldn’t the new circle be “half as big”? Well, no. Which of the two intervals
Beware:
Despite being aware of these mathematical concepts, physicists (including us) are not used to think in terms of “projective spaces” and “rays” because it is not a very useful concept for what we do. It is also not a very intuitive concept, you might add, and most physicists would agree. Hence we actually prefer to stick with the picture of vectors and just keep in mind that global signs are not important. Physicists also tend to be sloppy in their nomenclature: We don’t distinguish between vectors and states, i.e., we refer to the vector
If you followed the tutorial up to this point, you can give yourself a pat on the back. By now you have a basic understanding of the formalism of quantum mechanics that is almost on par with the knowledge of an undergrad student of physics after their first course in quantum mechanics. In paticular, you are equipped with all the tools needed to understand a variety of simple quantum algorithms that can be run on a quantum computer.

One last thing …
There is a last confession to be made: You should never tell a physicist that the state space of a qubit is the Bloch circle. In the best-case scenario, they look at you with blank eyes; in the worst case, they snigger. The reason is that the true state space of a single qubit is not described by a circle but by a sphere:
The state space of a single qubit is the Bloch sphere.
The reason goes back right to the beginning of this tutorial where we argued that the amplitudes
In reality, probability amplitudes are complex numbers
Complex numbers can be thought of as a “superset” of real numbers (equivalently:
Apart from that:
- The amplitudes of quantum states are actually complex numbers.
- Complex numbers are a superset of real numbers. All equations we wrote down remain valid in the full formalism but can be extended to complex numbers.
- The full set of single-qubit gates is the unitary group.
- The state space of a single qubit is the complex projective line and can be illustrated by the Bloch sphere.

after the physicist Felix Bloch.
You are now ready to program a quantum computer!
The complete picture (Optional)

Ⓒ2023 Tutorial by Nicolai Lang, Institute for Theoretical Physics III, University of Stuttgart