FAQ

What is quantum computing, in short?

Quantum Computing is a model of computation whose basic unit is the Qubit, whose state is a vector in a Hilbert space that evolves under unitary gates and is then measured. Three phenomena distinguish it: Superposition, Entanglement, and Interference, which allows the amplitudes of correct answers to be reinforced and those of wrong answers to be weakened.

A quantum computer is not “a computer that is faster at everything”. The advantage is known for specific problems: factoring numbers (Shor), unstructured search with a quadratic speed-up (Grover), simulating quantum systems, and some oracle problems. For many everyday tasks there is no known advantage. Current devices are small and suffer from noise, so most learning, including this lab, takes place on classical simulators.

Full page

What is the difference between a bit and a qubit?

A classical bit is at any moment either 0 or 1. A qubit's state is $|\psi\rangle=\alpha|0\rangle+\beta|1\rangle$, where $\alpha,\beta$ are complex numbers satisfying $|\alpha|^2+|\beta|^2=1$. When measured in the computational basis we get 0 with probability $|\alpha|^2$ or 1 with probability $|\beta|^2$ (the Born rule), and the state collapses to the outcome.

The essential difference is not that the qubit “holds many values”, but that amplitudes can interfere: gates add and subtract amplitudes the way waves combine, and this is what algorithms exploit. Also, $n$ qubits are described by $2^n$ amplitudes and can be entangled, which has no counterpart in $n$ bits. On the other hand, amplitudes cannot be read directly, and an unknown state cannot be copied.

Full page

If qubit amplitudes are continuous, does a qubit store infinite information?

It is true that describing a qubit's state requires two continuous real numbers (the angles $\theta,\phi$ on the Bloch sphere), but this information cannot be read out. Measurement gives only 0 or 1 and changes the state, and an unknown state cannot be copied to measure many copies (the no-cloning theorem).

The precise result is the Holevo Bound: no more than one classical bit can be transmitted per qubit sent without prior entanglement. With prior entanglement two bits can be sent (superdense coding), but this consumes another qubit distributed in advance. To estimate amplitudes experimentally, the state must be prepared and measured many times, and precision improves slowly with the number of shots.

Full page

Does a quantum computer try all solutions at once?

The common phrase “a quantum computer tries every possibility at once” is misleading. It is true that applying an oracle $U_f$ to the superposition $\frac{1}{\sqrt{2^n}}\sum_x|x\rangle$ produces $\frac{1}{\sqrt{2^n}}\sum_x|x\rangle|f(x)\rangle$ in a single step, which is called Quantum Parallelism. But measuring this state gives a single random pair $(x,f(x))$, which is what could be obtained classically by trying a random input.

The real advantage comes from interference: successful algorithms (Deutsch–Jozsa, Simon, Shor, Grover) arrange the gates so that amplitudes interfere constructively at useful answers and destructively elsewhere, and then extract a global property of the function (a period, an order, a marked item) rather than its full table of values. That is why there is no fast quantum algorithm for every problem.

Full page

Why do we need complex numbers in quantum computing?

A quantum amplitude $\alpha=re^{i\varphi}$ has a magnitude $r$, which sets the probability $r^2$, and a phase $\varphi$, which does not appear in the probability of a single measurement but determines the result of interference when amplitudes are added. For example, $|+\rangle$ and $|-\rangle$ have the same probabilities in the computational basis, but $H$ turns the first into $|0\rangle$ and the second into $|1\rangle$.

Unitary gates such as $S$, $T$ and $R_Z$ work by changing the phase alone, and states such as $|{+i}\rangle=\frac{1}{\sqrt2}(|0\rangle+i|1\rangle)$ need imaginary amplitudes. Time evolution in the Schrödinger equation, $e^{-iHt}$, is also inherently complex. Some algorithms can make do with real amplitudes, but the general framework needs complex numbers.

Full page

What is the difference between global and relative phase?

The states $|\psi\rangle$ and $e^{i\gamma}|\psi\rangle$ are physically identical: all probabilities and all expectation values are unchanged because $|e^{i\gamma}|=1$. This is the Global Phase, which is why we say that $R_Z(\lambda)$ and $P(\lambda)$ are “equal up to a global phase”.

The Relative Phase, by contrast, is the difference between the phases of the components: $\frac{1}{\sqrt2}(|0\rangle+|1\rangle)$ and $\frac{1}{\sqrt2}(|0\rangle-|1\rangle)$ are different, and the difference shows up after a Hadamard gate or by measuring in the $x$ basis. On the Bloch sphere the relative phase is the azimuthal angle $\phi$.

Caution: the global phase of a gate becomes a relative phase when the gate is made controlled, which is why $CP(\lambda)\neq CR_Z(\lambda)$. The lab matches Qiskit in global phases too, so amplitudes can be compared directly.

Full page

Why must quantum gates be unitary and reversible?

The condition $\sum_x|\alpha_x|^2=1$ must remain true after every gate, and the linear transformations that preserve the length of every vector are the Unitary matrices: $U^\dagger U=I$. It follows directly from this condition that every gate has an inverse, $U^\dagger$, i.e. quantum computation (before measurement) is reversible.

That is why there is no direct quantum AND gate with two inputs and one output, because it loses information. The solution is reversible computation: the Toffoli gate computes $c\oplus(a\wedge b)$ and keeps both inputs. Oracles are built in the form $|x\rangle|y\rangle\mapsto|x\rangle|y\oplus f(x)\rangle$ so that they are reversible for any function $f$.

Measurement and Reset are not unitary, which is why the lab and Qiskit treat them as separate non-unitary operations.

Full page

What is decoherence and why is it a problem?

A real qubit is not perfectly isolated; its interaction with the environment entangles it with the environment, so its reduced state becomes mixed and the relative phase between $|0\rangle$ and $|1\rangle$ is lost. This is usually described by two times: $T_1$ (energy relaxation from $|1\rangle$ to $|0\rangle$) and $T_2$ (dephasing), with $T_2\le2T_1$.

The practical consequence: every circuit must finish before noise corrupts the state, which limits circuit depth on current devices. The long-term solution is quantum error correction, which encodes one logical qubit in many physical qubits.

In the lab's Bloch-sphere module, a simplified relaxation model ($T_1$, $T_2$) can be enabled to see the Bloch vector shrink and be drawn towards the north pole. The other modules simulate ideal, noise-free circuits.

Full page

Will quantum computers replace classical computers?

The quantum advantage known in theory is confined to specific classes of problems: simulating quantum systems, factoring and discrete logarithms, quadratic speed-ups for some search problems, and some algebraic problems. For most everyday tasks (text editing, databases, training most deep learning models) there is no known advantage, and classical computers are cheaper, faster and more accurate.

Even quantum algorithms themselves are hybrid: setting up and translating circuits, controlling the hardware and processing results (such as continued fractions in Shor, Gaussian elimination in Simon, and the optimiser in VQE) are all classical. The closest picture is quantum processors as specialised accelerators alongside classical computers.

Full page

Why does θ/2 appear in the Bloch-sphere parametrization?

Any pure state of a qubit can be written, up to a global phase, as $|\psi\rangle=\cos\frac\theta2|0\rangle+e^{i\phi}\sin\frac\theta2|1\rangle$ with $0\le\theta\le\pi$ and $0\le\phi<2\pi$, and drawn as a point on the unit sphere with coordinates $(\sin\theta\cos\phi,\sin\theta\sin\phi,\cos\theta)$.

Two states that are orthogonal in Hilbert space (zero inner product) lie at opposite ends of a diameter of the sphere: $|0\rangle$ at the north pole ($\theta=0$) and $|1\rangle$ at the south pole ($\theta=\pi$). If we used $\theta$ instead of $\theta/2$ in the amplitudes, $|1\rangle$ would be at $\theta=\pi/2$, i.e. on the equator. This is also why rotation gates contain $\theta/2$: $R_Y(\theta)=e^{-i\theta Y/2}$ rotates the state by an angle $\theta$ on the sphere, and a full turn of $2\pi$ gives $-I$, i.e. a global phase.

Full page

Can a two-qubit state be shown on two Bloch spheres?

If the state is a product $|\psi\rangle=|a\rangle\otimes|b\rangle$, each qubit can be drawn on its own sphere and the picture is complete. An entangled state such as $|\Phi^+\rangle=\frac{1}{\sqrt2}(|00\rangle+|11\rangle)$ cannot be written in this form; the reduced state of each of its qubits is $\rho=I/2$, whose Bloch vector is zero (the centre of the sphere).

That is why the lab shows a Bloch vector for each qubit computed from its reduced state; its length is 1 for pure product states and less than 1 when the qubit is entangled with others. A shorter vector indicates entanglement (or noise), but the correlations between qubits themselves do not appear on the two spheres and need other tools, such as the amplitude table or correlation measurements.

Full page

Why can't an unknown quantum state be copied?

Suppose there were a unitary operation $U$ such that $U|\psi\rangle|0\rangle=|\psi\rangle|\psi\rangle$ for every $|\psi\rangle$. For two states $|\psi\rangle,|\varphi\rangle$, taking the inner product of both sides gives $\langle\psi|\varphi\rangle=\langle\psi|\varphi\rangle^2$, so the overlap must be 0 or 1. Hence non-orthogonal states cannot be copied; this is the no-cloning theorem (Wootters & Zurek 1982).

Its consequences: amplitudes cannot be “read” by copying the state and measuring the copies; teleportation destroys the original state; and the security of BB84 relies partly on the eavesdropper being unable to copy the qubits. Note that CNOT “copies” the basis states $|0\rangle,|1\rangle$, but with $|+\rangle$ it produces an entangled Bell state, not two copies.

Full page

Can entanglement be used to send information faster than light?

When the two qubits of the Bell state $|\Phi^+\rangle$ are measured in the same basis, the outcomes always agree, whatever the distance. But this does not allow a message to be sent: Alice's outcome on its own is completely random (0 or 1 with probability one half), and this distribution does not change whatever measurement basis Bob chooses or whatever gates he applies to his qubit. Mathematically, the reduced density matrix of Alice's qubit is unaffected by any local operation on Bob's qubit; this is the No-communication Theorem.

The correlation is discovered only when the outcomes are collected and compared, which requires a classical channel limited by the speed of light. That is why teleportation needs two classical bits to be sent, and before they arrive Bob's qubit is in the state $I/2$, which carries no information about the teleported state. You can check this in the entanglement lab: change Bob's basis and observe that Alice's frequencies on their own stay at about 50/50.

Full page

What is quantum entanglement, simply put?

A two-qubit state is said to be Entangled if it cannot be written as a tensor product $|a\rangle\otimes|b\rangle$. The best-known example is the Bell state $|\Phi^+\rangle=\frac{1}{\sqrt2}(|00\rangle+|11\rangle)$: neither of its qubits has a pure state of its own, yet the two qubits together are in a completely definite pure state.

The striking property is that the correlation appears in any matching basis, not only in the $z$ basis, and that the strength of these correlations violates a Bell inequality (such as CHSH): any “local hidden-variable” theory gives $|S|\le2$, while quantum mechanics gives up to $2\sqrt2$, and experiments have confirmed this (including Aspect's 1982 experiments and the loophole-free experiment of Hensen et al. 2015).

Entanglement is a computational and communication resource: it is used in teleportation, superdense coding and many algorithms; but it does not allow information to be sent faster than light.

Full page

How does entanglement differ from ordinary classical correlation?

Imagine two gloves, one right and one left, placed in two boxes and sent far apart. Opening one tells you at once about the other; this is a classical correlation caused by information fixed in advance. If we measure a Bell state only in the $z$ basis, the results look similar.

The difference appears when measuring in different bases. In the CHSH test each party chooses between two measurements, and we compute a combination of correlations $S$. Any model in which the outcomes are fixed locally in advance satisfies $|S|\le2$, while a Bell state with a suitable choice of angles gives $2\sqrt2\approx2.83$. The entanglement lab's CHSH mode lets you compute $S$ from simulated samples.

Caution: the classical simulation reproduces these numbers because it computes quantum mechanics directly with knowledge of the whole state; a genuine violation of the inequality can only be demonstrated by physical experiments between two separated parties.

Full page

Does quantum teleportation move matter or beat the speed of light?

Teleportation transfers the quantum state $\alpha|0\rangle+\beta|1\rangle$ from Alice's qubit to a qubit that Bob already has; no particles or energy travel. The protocol requires a shared entangled pair set up in advance, a measurement by Alice of two qubits, and then sending the result (two bits) over a classical channel.

Before the two bits arrive, Bob's qubit is in the maximally mixed state $I/2$, regardless of the state being sent, so he cannot extract any information. Once they arrive, he applies a correction with Pauli gates and obtains the state. Alice's state is destroyed by the measurement, so the no-cloning principle is not violated.

In the lab's algorithms module you can choose $\theta,\phi$ and see that the four outcomes of Alice's measurement are roughly equally likely, and that the fidelity of Bob's final state is 1 in the ideal simulation.

Full page

How do I create an entangled state in the lab?

The simplest way: start from $|00\rangle$ and apply a Hadamard to $q_0$, so the state becomes $\frac{1}{\sqrt2}(|00\rangle+|01\rangle)$; then a CNOT with $q_0$ as control and $q_1$ as target gives $\frac{1}{\sqrt2}(|00\rangle+|11\rangle)$. In the circuit builder, choose the ready-made “bell” example, or add the two gates by hand.

To get the other Bell states: add $X$ on $q_1$ before the Hadamard to get $|\Psi^+\rangle=\frac{1}{\sqrt2}(|01\rangle+|10\rangle)$, or $X$ on $q_0$ before the Hadamard to get $|\Phi^-\rangle=\frac{1}{\sqrt2}(|00\rangle-|11\rangle)$. For a three-qubit GHZ state, add a second CNOT from $q_1$ to $q_2$.

When you measure, you will see only 00 and 11, in proportions close to 50/50 (the exact numbers depend on the seed and the number of shots). In the entanglement lab you can change the measurement basis for each party to see the correlation in the $x$ and $y$ bases as well.

Full page

What is the difference between superposition and entanglement?

Superposition is relative to a particular basis: $|+\rangle=\frac{1}{\sqrt2}(|0\rangle+|1\rangle)$ is a superposition in the $z$ basis, but a basis state in the $x$ basis. A single qubit can be in superposition without any entanglement.

Entanglement needs at least two qubits and does not depend on the choice of local basis. The state $|+\rangle|+\rangle=\frac12(|00\rangle+|01\rangle+|10\rangle+|11\rangle)$ is a superposition of four basis states but is not entangled, because it is a product of two states. By contrast, $\frac{1}{\sqrt2}(|00\rangle+|11\rangle)$ is entangled.

A quick test for two qubits: write the amplitudes in a $2\times2$ matrix $\begin{pmatrix}a_{00}&a_{01}\\a_{10}&a_{11}\end{pmatrix}$; the state is a product if and only if its determinant is zero. Single-qubit gates cannot create entanglement; a two-qubit gate such as CNOT or CZ is needed.

Full page

Why do measurement results differ from run to run?

The state $\alpha|0\rangle+\beta|1\rangle$ does not determine the measurement outcome, only its probabilities: $P(0)=|\alpha|^2$ and $P(1)=|\beta|^2$. So we repeat the circuit many times (Shots) and count the frequencies. With 1000 shots of the state $|+\rangle$ you might get 489 and 511, and in another run 507 and 493; the difference is normal statistical fluctuation, with standard deviation $\sqrt{p(1-p)/N}$ in the proportion, about 1.6% here.

In the lab the randomness is produced by a pseudo-random number generator; if you fix the seed, the counts repeat exactly, and if you leave it empty, they change. On real hardware, noise and readout errors are added on top. The lab also shows the exact probabilities because it has the state vector, which is not available on real hardware.

Full page

What happens to the state after measurement?

In a Projective Measurement in the computational basis, if the outcome is 0 the qubit's state becomes $|0\rangle$, and if it is 1 it becomes $|1\rangle$. A second measurement straight afterwards gives the same outcome. That is why one cannot “look” at the state without changing it.

In a system of several qubits, measuring one qubit projects the overall state onto the part consistent with the outcome and then renormalises it. For example, in $\frac{1}{\sqrt2}(|00\rangle+|11\rangle)$, if we measure $q_0=1$ the state becomes $|11\rangle$. This does not allow information to be sent, because the outcome is random.

The lab supports Mid-circuit Measurement, reset and classical conditions, and simulates them by tracking each shot separately, as in the teleportation circuit.

Full page

How many shots do I need for a good estimate?

Each shot is a Bernoulli trial, so the estimate $\hat p=n/N$ has standard deviation $\sqrt{p(1-p)/N}$, which is largest at $p=0.5$, where it equals $0.5/\sqrt N$. Examples: 100 shots give a typical error of about 5%, 1000 about 1.6%, and 10000 about 0.5%.

For expectation values such as $\langle Z\rangle=P(0)-P(1)$, the error is roughly twice the probability error. In variational algorithms (VQE, QAOA, VQC) the number of measurements multiplies, because each term of the Hamiltonian needs an independent estimate, and this is repeated at every optimisation step.

In the lab you can set the number of shots and compare the counts with the exact probabilities to see how the difference shrinks as $1/\sqrt N$. Note that each module has a maximum number of shots set by the administrator.

Full page

How do I measure a qubit in the x or y basis?

Hardware and simulators usually measure only in the computational ($z$) basis. To measure in another basis, we apply a gate that maps that basis to the computational basis and then measure:

  • The $x$ basis: $H$ maps $|+\rangle\to|0\rangle$ and $|-\rangle\to|1\rangle$; so outcome 0 means “+”.
  • The $y$ basis: $S^\dagger$ then $H$ map $|{+i}\rangle\to|0\rangle$ and $|{-i}\rangle\to|1\rangle$.

Example: the state $|+\rangle$ gives 0 or 1 equally in the $z$ basis, but always gives 0 in the $x$ basis. In the lab's measurement module, choose the basis (z, x or y) and the appropriate rotation is added automatically. This rotation is also what is used to estimate the expectation values of Pauli strings such as $\langle X\rangle$ and $\langle Y\rangle$.

Full page

What is the difference between exact probabilities and counts in the lab?

The lab is an exact state-vector simulator: it computes all amplitudes in Float64 precision, including the exact probabilities of every bit string. This is “privileged” information available only in simulation; a real device never provides it.

Counts are what we get by repeating the circuit $N$ times and taking a sample each time. They approximate the probabilities, improve as shots increase, and change between runs unless the seed is fixed.

When interpreting results: if you want to understand the theory, look at the probabilities; if you want to estimate what you would see on a real device (ignoring noise), look at the counts. In Qiskit the equivalent is Statevector.probabilities_dict() versus get_counts() from StatevectorSampler or AerSimulator.

Full page

What is readout error and how does the lab simulate it?

On real hardware a qubit may be in $|0\rangle$ yet be recorded as 1, or vice versa, because of the limits of the readout hardware and qubit relaxation during measurement. Usually the $1\to0$ error is larger than $0\to1$, because $|1\rangle$ may relax during measurement.

In the lab's measurement module, readout can be added with two parameters: $p_{01}$, the probability of reading 0 as 1, and $p_{10}$, the probability of reading 1 as 0, applied to every bit of every shot after sampling. This is a simplified classical model: it does not represent gate errors or correlations between qubit errors.

To correct this type of error, Measurement Error Mitigation techniques are used, which estimate the confusion matrix from calibration circuits and then approximately invert it.

Full page

What is ⟨Z⟩ and how is it computed from measurements?

The expectation value of an observable $O$ in the state $|\psi\rangle$ is $\langle O\rangle=\langle\psi|O|\psi\rangle$. The operator $Z$ has two eigenvalues: $+1$ for the state $|0\rangle$ and $-1$ for $|1\rangle$, so $\langle Z\rangle=P(0)-P(1)$. Example: $R_Y(\theta)|0\rangle$ gives $\langle Z\rangle=\cos\theta$.

For Pauli strings on several qubits, such as $Z_0Z_1$, each outcome $b_1b_0$ is given the value $(-1)^{b_0\oplus b_1}$ (i.e. by the parity of the bits) and then we take the mean. To measure $\langle X\rangle$ or $\langle Y\rangle$ we rotate the basis first.

These quantities are what variational algorithms work with: VQE minimises $\langle H\rangle$, and the lab's VQC classifier reads $\langle Z_0\rangle$ and converts it into the class probability $P(1)=(1-\langle Z_0\rangle)/2$. In Qiskit they are computed with StatevectorEstimator and SparsePauliOp.

Full page

Which problems have a known quantum advantage?

The list known in theory is limited and specific:
- Factoring and discrete logarithms: Shor's algorithm is polynomial, while the best known classical algorithm is sub-exponential. There is no proof that no fast classical algorithm exists.
- Unstructured search and amplitude amplification: Grover, a quadratic speed-up proven to be optimal.
- Simulating quantum systems (chemistry and materials): expected to be among the most important applications, using phase estimation on fault-tolerant devices.
- Oracle problems (Deutsch–Jozsa, Bernstein–Vazirani, Simon): a proven separation in the query model, without a direct practical application.

Variational algorithms (VQE, QAOA, QML) are heuristic, and there is as yet no general proof of their advantage. All of the above generally assume large, fault-tolerant computers.

Full page

Can a quantum computer break RSA today?

Shor's algorithm factors $N$ in time polynomial in its number of bits, which breaks RSA in theory. But the RSA keys used in practice are thousands of bits long, and running Shor on them requires thousands of error-corrected logical qubits, i.e. far more physical qubits, and very deep circuits. Current devices are far from that.

Published experiments have factored numbers such as 15 (Vandersypen et al. 2001), often with simplified circuits that exploit knowledge of the answer. Our lab simulates Shor only for $N\in\{15,21,33,35\}$, and builds the modular multiplication by classical computation, so it is a teaching tool, not evidence of any ability to break encryption.

Even so, the security community takes the threat seriously because of the risk of “harvest now, decrypt later”, which is why a transition to quantum-resistant encryption algorithms (Post-quantum Cryptography) is under way.

Full page

What is an oracle, and why do some algorithms seem to know the answer in advance?

In the Query Model we assume that the function $f$ is available only through a gate $U_f|x\rangle|y\rangle=|x\rangle|y\oplus f(x)\rangle$, or in phase form $|x\rangle\mapsto(-1)^{f(x)}|x\rangle$, and we count the number of calls. This allows a precise comparison between quantum and classical algorithms.

In the lab and in the Qiskit examples we build the oracle from knowledge of the secret ($s$ in Bernstein–Vazirani, or the marked item in Grover), because we need a concrete function to experiment with. This does not mean the algorithm “cheats”: if you gave the oracle to someone else without telling them how it was built, the algorithm would extract the answer from the calls alone.

In real applications the oracle is a circuit that computes a function whose formula is known but whose property is unknown, such as the modular multiplication in Shor, or a function that checks whether a solution to a problem is correct.

Full page

Why does the Shor lab only accept N ∈ {15, 21, 33, 35}?

The lab uses $L=\lceil\log_2(N+1)\rceil$ work qubits and $t=2L$ counting qubits, i.e. $3L$ qubits. For $N=15$: $L=4$ and 12 qubits ($2^{12}$ amplitudes). For $N=35$: $L=6$ and 18 qubits ($2^{18}\approx2.6\times10^5$ amplitudes). Each larger number adds about three qubits per bit, so memory and time grow exponentially in the browser.

These values were chosen because they are odd composite numbers that are not prime powers, which is the case needed for the reduction from factoring to order finding; even numbers are factored directly by dividing by 2.

Important reminder: the modular multiplication in the lab is implemented as a permutation built by classical computation, so the simulation explains the algorithm's mathematics and offers no evidence of a speed-up.

Full page

What is query complexity and why is it used to compare quantum algorithms?

Proving that a problem is classically hard in the general model of computation is very difficult (it is tied to open questions such as P versus NP). But in the query model strict lower bounds can be proven. That is why many results are stated in this form: Deutsch–Jozsa (1 versus $2^{n-1}+1$ deterministically), Bernstein–Vazirani (1 versus $n$), Simon ($O(n)$ versus $\Omega(2^{n/2})$), Grover ($\Theta(\sqrt N)$ versus $\Theta(N)$).

Caution is needed when translating this into an application: the cost of building the oracle itself may be large, and a separation in the oracle model does not imply a separation for a practical problem with an explicit description. Shor is an example of an algorithm that carried an oracle idea (period finding) over to an important explicit problem.

Full page

Why does Grover's success probability drop with too many iterations?

A Grover iteration (oracle + diffuser) rotates the state in a two-dimensional plane by an angle of $2\theta$, where $\sin\theta=\sqrt{M/N}$. The probability after $k$ iterations is $\sin^2((2k+1)\theta)$, and it peaks near $k\approx\frac{\pi}{4\theta}-\frac12$. If we keep iterating, the state overshoots the marked item and moves away from it, so the probability falls and then rises again periodically.

Example: $N=8$ with one item: the probabilities for $k=0,1,2,3$ are $0.125, 0.781, 0.945, 0.330$. That is why the lab computes the optimal number $\lfloor\pi/(4\theta)\rfloor$ by default, and plots the probability against $k$ from both the simulator and the formula. If $M$ is not known, a randomised strategy for choosing $k$ is used (Boyer et al. 1998).

Full page

Is the QFT exponentially faster than the FFT?

The FFT takes $N=2^n$ numbers and gives $N$ explicit coefficients in $O(N\log N)$ operations. The QFT applies the transform to the amplitudes of an $n$-qubit state with $O(n^2)$ gates. But: (1) a general vector of $N$ numbers cannot be loaded into a quantum state at a cost below $O(N)$ in the general case; (2) the resulting coefficients cannot be read out, because measurement gives a single random index with distribution $|\tilde a_y|^2$.

So the QFT does not replace the fast Fourier transform in signal processing. Its usefulness lies inside algorithms where the input state is prepared efficiently and we need only the hidden “period” or “phase”, as in phase estimation and Shor. In the lab you can see that transforming a basis state gives exactly equal probabilities, and that all the information is in the phases.

Full page

What does quantum advantage mean, and has it been achieved?

The term is used in several senses, so always ask: an advantage at which task? Against which classical algorithm? And by which measure (time, energy, accuracy)?

In theory, an advantage has been proven in certain models (the oracle model, and some sampling problems under complexity-theoretic assumptions). Experimentally, demonstrations have been published for sampling tasks from random circuits designed to be classically hard, and some were followed by improvements in classical simulation that narrowed the gap; these tasks have no direct useful applications.

An advantage on practically useful problems (chemistry, optimisation, machine learning) has not yet been conclusively demonstrated, and much of it is thought to require error correction. The results of any classical simulation, including this lab, cannot by their nature show a quantum advantage.

Full page

Do the QML results in this lab demonstrate a quantum advantage?

Everything in the quantum machine learning module is computed on your classical computer: quantum kernels, variational classifiers and hybrid models. If the simulation is feasible in a browser, the task itself is feasible classically, and that alone rules out an advantage at these sizes.

In addition, the datasets (Iris, moons, circles, XOR, blobs) are small and easy, and simple classical models reach high accuracy on them; that is why the lab shows classical baselines (RBF kernel, linear kernel, logistic regression) for comparison. The results are sensitive to the choice of feature map, parameters and seed; for example, on Iris we observed that the angle-encoding kernel reached a test accuracy of 100% while ZZ (reps=2) reached 73%, and this must not be generalised.

In the literature, an advantage in QML is an open question: there are results showing that classical data can make classical models competitive (Huang et al. 2021), and that quantum kernels can suffer from exponential concentration (Thanasilp et al. 2024).

Full page

What is quantum machine learning?

Quantum Machine Learning covers several directions. The most common on current hardware:
- Variational Models: encode the data with a circuit (a feature map), then apply a trainable parameterised circuit, then measure an expectation value used as the prediction; the parameters are trained with a classical optimiser (Mitarai et al. 2018; Schuld et al. 2020).
- Kernel Methods: the quantum feature map defines a kernel $k(x,x')=|\langle\phi(x)|\phi(x')\rangle|^2$ that is used in a classical support vector machine (Havlíček et al. 2019; Schuld & Killoran 2019).

There are also algorithms that assume fault-tolerant computers and quantum memory, and learning from quantum data produced by physical experiments. Known challenges: data loading, barren plateaus, kernel concentration, noise, and the difficulty of proving an advantage over strong classical methods.

Full page

What is a quantum kernel, and is it better than an RBF kernel?

A quantum feature map $x\mapsto|\phi(x)\rangle=U(x)|0\rangle$ defines the fidelity kernel $k(x,x')=|\langle\phi(x)|\phi(x')\rangle|^2$, which is estimated on a quantum device and then passed to a classical SVM. In the lab it is computed exactly from the state vector, and the ZZ map matches Qiskit's zz_feature_map.

Is it better? There is no general answer. Synthetic examples have been designed in which quantum kernels outperform under complexity-theoretic assumptions, but for typical real data, RBF kernels and classical models are highly competitive (Huang et al. 2021). As the number of qubits grows, kernel values may concentrate around a fixed value, so that a huge number of measurements is needed to distinguish them (Thanasilp et al. 2024). The lab shows the spread of the off-diagonal values as a diagnostic for this, and compares with RBF and linear kernels on the same data.

Full page

What are barren plateaus?

McClean and colleagues (2018) showed that in sufficiently deep random parameterised circuits, the variances of the gradients are exponentially small in the number of qubits. This means that the gradient at a random starting point is very close to zero, and estimating it accurately enough requires an exponential number of measurements.

Factors linked to the phenomenon: circuit depth and expressivity, Global Cost functions that measure all qubits, excessive entanglement, and noise. Proposed strategies include local cost functions, shallow or problem-tailored circuits, and smart parameter initialisation; there is no general solution.

In the lab you can explore the loss function's “landscape” in the landscape experiment, but the small sizes possible in the browser are not enough to see the phenomenon at full strength.

Full page

Why use the parameter-shift rule instead of backpropagation?

Backpropagation needs the intermediate values of each layer to be stored, which is impossible on a quantum device because the state cannot be read without destroying it. For a gate of the form $e^{-i\theta P/2}$, where $P$ is a Pauli string (such as $R_X$, $R_Y$, $R_Z$), the parameter-shift rule gives the exact gradient:
$$\frac{\partial\langle O\rangle}{\partial\theta}=\tfrac12\Big[\langle O\rangle_{\theta+\pi/2}-\langle O\rangle_{\theta-\pi/2}\Big].$$

This is not an approximate finite difference; the shift is large and the result is exact, though on hardware shot error remains. The cost is two runs per parameter, i.e. $2p$ runs for $p$ parameters. In simulation, backpropagation on the state vector can be used and is faster, but it is not available on hardware. The lab uses the shift rule in VQE and the variational classifier to match what happens on a real device.

Full page

What is the data-loading problem in QML?

There are several encoding methods: Angle Encoding places each feature in a rotation angle on a qubit, needing one qubit per feature and a small depth; Amplitude Encoding places $2^n$ values in the amplitudes of $n$ qubits, but generally needs deep circuits whose cost is of the order of the number of values; and feature maps such as ZZ introduce interactions between features.

Two important points: first, many algorithms that promise exponential speed-ups assume that the data are already loaded into a quantum state or into QRAM, which is a strong assumption. Second, the encoding determines the space of functions the model can represent (Schuld & Killoran 2019); that is why results vary greatly between feature maps.

In the lab you can compare angle encoding and the ZZ map on the same datasets, after scaling the features to the range $[0,\pi]$.

Full page

Why do feature maps give different accuracies on Iris in the lab?

In an experiment on Iris (setosa versus versicolor, features 0 and 2 after scaling to $[0,\pi]$), we observed in the lab that the angle-encoding kernel reached a test accuracy of 100% while the ZZ kernel with two repetitions (reps=2) reached about 73%. One possible explanation, which we have not proven, is that the ZZ map introduces oscillating terms between features, making the kernel “sharper” than necessary for simple, nearly linearly separable data.

The correct conclusions: the choice of feature map and its parameters (such as the number of repetitions and feature scaling) has a strong effect; a more complex map is not necessarily better; and one should always compare with classical baselines. The wrong conclusion: that angle encoding is generally better than ZZ; this is a result for a single case with a specific data split and seed.

Full page

Why don't `execute` or `from qiskit import Aer` work in old examples?

Qiskit's interface changed a great deal with version 1.0. The execute function was removed, Aer moved to a separate package qiskit-aer, BasicAer, qiskit.opflow and QuantumInstance were removed, and c_if was replaced by the with qc.if_test(...) construct.

The modern alternative: import from qiskit_aer import AerSimulator, create sim = AerSimulator(seed_simulator=1), then counts = sim.run(transpile(qc, sim), shots=1000).result().get_counts(). Or use the reference primitives: StatevectorSampler(seed=...) for sampling and StatevectorEstimator for expectation values with SparsePauliOp. All the site's examples are written for Qiskit 1.0 and later, and have actually been run on Qiskit 2.6.2 and qiskit-aer 0.18.4.

Full page

How do I install Qiskit to run the site's examples?

The method recommended in the Qiskit documentation is to use a virtual environment to avoid package conflicts: create it with python -m venv qenv, then activate it (source qenv/bin/activate on Linux and macOS, or the activation script in the Scripts folder on Windows), then install the packages with pip install qiskit qiskit-aer scipy.

Then check with python -c "import qiskit; print(qiskit.__version__)". The site's examples were tested on Qiskit 2.6.2 and qiskit-aer 0.18.4, and use the Qiskit ≥ 1.0 interface. The PennyLane examples need pip install pennylane.

If you want to experiment without installing anything, you can use Jupyter notebooks on cloud services, or the site's own lab, which exports Qiskit code for the circuit you build.

Full page

Will Qiskit give the same counts as the lab with the same seed?

The lab matches Qiskit in amplitudes and probabilities (including global phase), and this has been tested on many random circuits. But sampling depends on a pseudo-random number generator: the lab uses a small generator (mulberry32), while Qiskit Aer and StatevectorSampler use their own generators. A seed makes each tool repeat its own results, not those of the other tool.

So when comparing: compare the exact probabilities (they should match up to numerical rounding errors), and expect the counts to differ by statistical amounts of order $\sqrt{Np(1-p)}$. On the algorithm pages, the outputs shown under the Qiskit code are actual outputs from running Qiskit with the seeds given in the code.

Full page

How do I export a lab circuit to Qiskit or OpenQASM?

From the circuit builder, choose export and you will get three formats:
- Qiskit code that builds a QuantumCircuit with the same gates and the same qubit order.
- OpenQASM 2.0 with include "qelib1.inc";, which can be loaded into Qiskit with qiskit.qasm2.loads.
- OpenQASM 3.0 with include "stdgates.inc";, loaded with qiskit.qasm3.loads (it needs an extra package for parsing).

OpenQASM is a tool-independent circuit description language (Cross et al. 2017 for version 2, and 2022 for version 3), so it is useful for moving circuits between software. Note that gates keep their standard names (cx, rz, cswap, rzz…), and that the qubit order in the code is the same as the lab's.

Full page

What is the difference between Qiskit and PennyLane?

Qiskit from IBM: a package for building circuits (QuantumCircuit), operators (SparsePauliOp), transpiling to the hardware's native gates (transpile), and primitives (Sampler and Estimator), with a high-performance simulator (Qiskit Aer) and access to IBM devices.

PennyLane from Xanadu: a library for differentiable quantum programming; a circuit is defined as a Python function (a QNode) that returns expectation values, its gradients can be computed automatically (including with the parameter-shift rule), and it can be integrated with PyTorch, JAX or TensorFlow (Bergholm et al. 2018). It supports several devices and simulators through plugins.

The choice depends on the goal: for general circuits, hardware and understanding transpilation, Qiskit is a natural choice; for quantum machine learning experiments and hybrid training, PennyLane is very convenient. The site's examples use both.

Full page

What is the difference between Statevector, StatevectorSampler and AerSimulator?
  • Statevector(qc) from qiskit.quantum_info: computes the exact state vector of a circuit without measurements, and from it probabilities_dict() and expectation values. Useful for learning and verification, but it does not simulate mid-circuit measurement.
  • StatevectorSampler(seed=...) and StatevectorEstimator: reference primitives with the unified Sampler/Estimator interface; the first returns counts, the second expectation values of SparsePauliOp operators. The same interface is used with real devices.
  • AerSimulator(seed_simulator=...) from qiskit_aer: a fast simulator with several methods (state vector, density matrix, stabilizer for Clifford circuits, matrix product states), supporting noise models, mid-circuit measurement and conditional operations.

The site's examples use all three as needed; for example, BB84 uses method="stabilizer" because it contains only $X$ and $H$ gates and measurements.

Full page

Why is qubit 0 printed on the far right?

In the lab and in Qiskit, qubit 0 is the Least Significant Bit. So the printed string "011" means $q_2=0,\ q_1=1,\ q_0=1$, and corresponds to the binary index $3$. The advantage of this convention is that the index of a basis state is directly $\sum_k q_k2^k$.

Many textbooks (including Nielsen and Chuang) write the first qubit on the left, so the same state appears in reversed order. Example: after x(0) on two qubits the lab prints "01", while some textbooks would write it as $|10\rangle$.

Watch out for this when: reading the results of Bernstein–Vazirani (the secret $s$ is written $s_{n-1}\dots s_0$), decoding a superdense coding message, and reading two-qubit gate matrices. The lab displays two-qubit gate matrices in the textbook form (control first, i.e. most significant) and notes this.

Full page

Why does the CNOT matrix in Qiskit differ from textbooks?

In textbooks, the CNOT matrix in the basis $|00\rangle,|01\rangle,|10\rangle,|11\rangle$ (control first) is
$$\begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&0&1\\0&0&1&0\end{pmatrix}.$$
Qiskit's Operator for cx(0,1), however, orders the basis as $|q_1q_0\rangle$, with the control $q_0$ as the least significant bit, so the matrix appears as
$$\begin{pmatrix}1&0&0&0\\0&0&0&1\\0&0&1&0\\0&1&0&0\end{pmatrix}.$$
It is the same gate; the difference is a reordering of rows and columns. The lab displays two-qubit gate matrices in the textbook form (control first) because it is the most common in teaching, while the simulator applies gates in the little-endian convention that matches Qiskit; the results are identical.

Full page

What does the seed do in the lab?

Exact computations in the lab (amplitudes and probabilities) are always deterministic. Randomness enters only in sampling (shots), mid-circuit measurement, some experiments such as BB84, parameter initialisation in VQE and QML, and some optimisers such as SPSA.

When a numeric seed is set (for example 42), the lab uses a pseudo-random generator (mulberry32) that starts from that seed, so it gives the same results every time and on every device. This is useful for teaching (all students see the same numbers), for reproducing an experiment, and for comparing two settings with the randomness held fixed.

But do not base a conclusion on a single seed: change the seed several times to see how much the results fluctuate, especially in machine learning experiments, where accuracy may change from one seed to another. The generator is for teaching and is not suitable for cryptography.

Full page

How many qubits can be simulated in the browser?

A state-vector simulator stores $2^n$ complex amplitudes, each of which is two Float64 numbers (16 bytes), i.e. $16\cdot2^n$ bytes per vector. Examples: 12 qubits ≈ 64 kilobytes, 16 qubits ≈ 1 megabyte, 20 qubits ≈ 16 megabytes, 30 qubits ≈ 16 gigabytes. Time also grows with $2^n$ for each gate.

That is why the lab sets a default limit of 16 qubits, which the administrator can change, and warns above 12, so that the browser stays fast on modest devices and phones. The simulation runs in a Web Worker so that the page does not freeze.

For comparison, specialised simulators on servers go beyond 30–40 qubits for state vectors, and use other methods (stabilizer, tensor networks) for special circuits with larger numbers. This same exponential growth is the reason for interest in quantum computers.

Full page

Does the lab support mid-circuit measurement and classical conditions?

Circuits that contain only final measurements are simulated once: we compute the state vector and then sample from it, which is fast. But if there is a measurement or reset mid-circuit, or a gate conditioned on a classical result, the lab simulates each shot separately: it measures the qubit randomly according to its probabilities, projects the state, applies the conditional gates, and then continues.

This is slower (the cost multiplies with the number of shots), so the lab may limit the number of shots in this mode. The typical example is teleportation, where $X$ and $Z$ are applied to Bob's qubit according to Alice's measurements.

In modern Qiskit, conditions are written with with qc.if_test((creg, 1)): instead of c_if, which has been removed, and AerSimulator supports them.

Full page

What is the difference between simulation and running on real quantum hardware?

A simulator, such as this lab or Qiskit Aer, stores the entire state vector and applies gate matrices. Its strengths: exact results, visibility of amplitudes, probabilities and the Bloch sphere, reproducibility with a seed, and no noise unless a noise model is added. Its fundamental weakness: a memory cost of $O(2^n)$, so state-vector simulation does not go beyond a few dozen qubits.

A real device: gives only measurement samples; suffers from gate errors, readout errors and decoherence; has a native gate set and limited connectivity between qubits, so it needs Transpilation and extra SWAPs; and its performance may vary from day to day because of calibration. But it does not suffer the exponential cost of representation.

The upshot: simulation is excellent for learning and verification, but it is not quantum execution and shows no quantum advantage. Results on hardware will be less clean than the lab's.

Full page

What does the NISQ era mean?

NISQ stands for Noisy Intermediate-Scale Quantum. Devices at this stage are large enough that some of their circuits are hard to simulate classically, but gate errors make deep circuits unreliable, and error-corrected logical qubits are not available in sufficient numbers.

So the algorithms of this stage focus on shallow circuits and hybrid loops (VQE, QAOA, variational classifiers), with Error Mitigation techniques instead of error correction. Preskill himself cautioned that obtaining practical value from NISQ devices is not guaranteed, and that major applications such as Shor's algorithm need fault-tolerant computation.

The field is moving fast, and early demonstrations of error-corrected logical qubits are appearing; so the term is sometimes used today to describe a transitional stage.

Full page

Does the lab simulate noise?

The core engine is an ideal state-vector simulator: gates are exact, and there is no decoherence between gates. This is intentional, because the goal is to understand the algorithms first.

But the lab offers simplified models for understanding the effect of noise:
- In the Bloch-sphere module: energy relaxation ($T_1$) and dephasing ($T_2$, with $T_2\le2T_1$) applied to the Bloch vector over time, so you see the vector shrink and be drawn towards $|0\rangle$.
- In the measurement module: independent readout errors for each bit, with probabilities $p_{01}$ and $p_{10}$.

The lab does not simulate two-qubit gate errors, Crosstalk between qubits, or connectivity constraints. For more realistic noise modelling, the noise models in Qiskit Aer can be used. And remember that results on a real device will be less accurate than what you see here.

Full page

Why is simulating quantum computers hard for classical computers?

The general state of $n$ qubits is a superposition of $2^n$ basis states, and in general it cannot be compressed, because entanglement prevents describing it qubit by qubit. So state-vector simulation needs $16\cdot2^n$ bytes in double precision: 50 qubits means about 16 petabytes.

Not all circuits are hard: Clifford circuits (H, S, CNOT and measurement) can be simulated in polynomial time (the Gottesman–Knill theorem), which is why we used Qiskit's stabilizer method to simulate BB84 with a thousand qubits. And weakly entangled circuits are simulated efficiently with tensor networks and matrix product states.

This difficulty is what inspired the idea of quantum computing in the first place: if nature “computes” these states, let us use it for computation. At the same time, improvements in classical simulation methods raise the bar for what counts as a quantum advantage.

Full page

What is quantum error correction and why do we need logical qubits?

Qubits cannot simply be copied for redundancy (the no-cloning theorem), nor measured directly without being destroyed. The solution is quantum error-correcting codes: the information is spread over an entangled state of several physical qubits, and “Syndromes” are measured via ancilla qubits that reveal the type and location of an error without revealing the logical state; the error is then corrected.

The Threshold Theorem states that if the errors of physical operations are below a certain threshold, the error of the logical computation can be made as small as we like at a polylogarithmic overhead. The price is high: each logical qubit may need tens to thousands of physical qubits, depending on the code and the error rate.

That is why the requirements of Shor's algorithm for numbers of cryptographic size are estimated at very large numbers of physical qubits. The lab does not simulate error correction; its qubits are ideal.

Full page

Does QAOA beat classical algorithms on Max-Cut?

QAOA is a heuristic algorithm. Farhi and colleagues (2014) proved that depth $p=1$ guarantees an approximation ratio of at least 0.6924 on 3-regular graphs, while the classical Goemans–Williamson algorithm (1995), based on semidefinite programming, guarantees about 0.878 for any graph. As $p$ increases QAOA improves, but the circuits become deeper and optimisation becomes harder.

In practice, classical heuristics such as local search and simulated annealing (Kirkpatrick et al. 1983) are very strong. The optimisation lab shows the comparison directly: the exact brute-force solution, local search, simulated annealing and QAOA; on the small graphs available, the classical methods find the optimum instantly.

The open research question is whether there are classes of problems and sizes for which QAOA (or its variants) gives a practical advantage; the answer is not yet settled.

Full page

What is the difference between quantum annealing and gate-based quantum computing?

In Quantum Annealing, the system starts in the ground state of a simple “transverse field” Hamiltonian $-\sum X_i$, and the Hamiltonian is then changed slowly towards the problem's Ising Hamiltonian. If the change is slow enough, the system stays close to its ground state (Kadowaki & Nishimori 1998). Specialised devices for this model target optimisation problems written in Ising or QUBO form.

The Gate Model is general: it can run Shor, Grover and phase estimation, and approximately simulate annealing itself. QAOA can be seen as a “discretised” version of adiabatic evolution with a finite number of layers.

There is no general evidence that quantum annealing outperforms classical simulated annealing or the best classical solvers on practical problems. The optimisation lab simulates only the gate model (QAOA) and compares it with classical simulated annealing.

Full page

Why are optimization problems written as Ising models?

Many combinatorial optimisation problems (maximum cut, graph colouring, scheduling, knapsack) can be written as the minimisation of a quadratic function of binary variables (QUBO), which is equivalent to an Ising model via the substitution $z_i=(1-s_i)/2$ with $s_i=\pm1$. Lucas (2014) collected Ising formulations of many NP problems.

The quantum benefit: each variable becomes a qubit, and $s_i$ becomes the operator $Z_i$, so the Hamiltonian becomes diagonal, with values equal to the cost values of each bit string. The evolution $e^{-i\gamma H_C}$ decomposes into $R_{ZZ}$ and $R_Z$ gates, which is what QAOA and quantum annealing use.

The Max-Cut example: $C=\sum_{(i,j)}w_{ij}\frac{1-Z_iZ_j}{2}$. In the optimisation lab you can display the Ising formulation of each graph and check that the cut value equals $(W-E)/2$, where $W$ is the total weight and $E$ the Ising energy.

Full page

Where should I start learning quantum computing?

A suggested step-by-step path:
1. Mathematical foundations: vectors, matrices, inner products, eigenvalues, complex numbers and the tensor product.
2. The “Fundamentals” path in this lab: the qubit, superposition, measurement, Dirac notation, unitary gates, entanglement, decoherence.
3. Circuits and gates in practice: build Bell and GHZ states in the circuit builder, export them to Qiskit and run them.
4. Algorithms: Deutsch, Bernstein–Vazirani and Grover, then the QFT, phase estimation and Shor.
5. Specialisation: quantum machine learning, optimisation, or error correction and hardware.

Reliable references: Nielsen and Chuang's book (a standard reference), the free IBM Quantum Learning courses, and the Qiskit and PennyLane documentation. Most important is practice: work through small examples by hand, then check them in the simulator.

Full page

I work in AI; how do I move into quantum machine learning?

Your strengths: gradient-based optimisation (Adam, SPSA), kernel methods and SVMs, model evaluation and baselines, all of which are used in QML. What you need to add:
1. Fundamentals of qubits, gates, measurement and entanglement (the lab's Fundamentals path).
2. Parameterised circuits, data encoding and the parameter-shift rule.
3. The lab's quantum machine learning path: feature maps, quantum kernels, the variational classifier and hybrid models, with comparison against classical baselines.
4. Reference reading: Schuld & Petruccione (2021), the review by Biamonte et al. (2017), and the papers by Havlíček (2019) and Schuld & Killoran (2019), then the critical papers: Huang et al. (2021), McClean et al. (2018) and Thanasilp et al. (2024).
5. Tools: PennyLane with PyTorch, and Qiskit.

An important contribution you can make: a rigorous experimental methodology (strong baselines, multiple seeds, held-out test data), which is exactly what the QML literature needs.

Full page

Do I need a physics degree to work in quantum computing?

Quantum computing is a multidisciplinary field. Building and controlling qubits usually requires a background in physics or electrical engineering. But algorithms, compilers, software, theoretical error correction and quantum machine learning involve many specialists in mathematics and computer science.

What is indispensable on every path: a solid command of linear algebra, probability, complex numbers, and a good understanding of the circuit model. Introductory quantum mechanics is very useful, but you usually do not need a physicist's full background, because the qubit model is abstract and mathematically clean.

Practical advice: build small projects you can show (implementing an algorithm, a careful experimental comparison, a contribution to an open-source library), as they demonstrate skill more than a qualification alone.

Full page

Can I run a circuit on a real quantum computer?

The general steps with IBM Quantum: create an account on their platform, get an access key, install qiskit-ibm-runtime, then choose a device and run the circuit through the Sampler or Estimator primitives. The exact details and free-tier limits change, so rely on the current IBM Quantum documentation.

Before running: export the circuit from the lab to Qiskit code, test it on the simulator, then transpile it for the device with transpile and see how much the depth and the number of two-qubit gates have grown. Expect results less clean than the lab's: for a Bell state, for example, a small proportion of 01 and 10 will appear because of noise.

Use it sparingly: start with small circuits and a reasonable number of shots, because run time on devices is limited and shared among users.

Full page

What mathematics do I need for quantum computing?

The minimum to get started:
- Complex numbers: the polar form $re^{i\varphi}$, the conjugate, and the magnitude.
- Linear algebra: vectors, inner products, matrices and their multiplication, unitary and Hermitian matrices, eigenvalues and eigenvectors, and the tensor product.
- Probability: discrete distributions, expected value and variance.

For the intermediate and advanced levels: the discrete Fourier transform (QFT), elementary number theory (modular arithmetic, greatest common divisor, continued fractions for Shor), linear algebra over $\mathrm{GF}(2)$ (Simon), the basics of optimisation (VQE, QAOA, QML), and density matrices and the partial trace for understanding noise and entanglement.

Tip: Dirac notation looks strange at first but is just shorthand for vectors; translate each expression into small matrices until you get used to it.

Full page

Why do we use Dirac (bra-ket) notation?

In Dirac notation, a state vector is written as a “ket” $|\psi\rangle$, and its Hermitian conjugate as a “bra” $\langle\psi|=(|\psi\rangle)^\dagger$. The inner product $\langle\varphi|\psi\rangle$ is a complex number, and the outer product $|\psi\rangle\langle\varphi|$ is a matrix. For example $|0\rangle=\begin{pmatrix}1\\0\end{pmatrix}$ and $|1\rangle=\begin{pmatrix}0\\1\end{pmatrix}$, and the projector onto $|0\rangle$ is $|0\rangle\langle0|=\begin{pmatrix}1&0\\0&0\end{pmatrix}$.

Its advantages: compact notation for multi-qubit states ($|01\rangle=|0\rangle\otimes|1\rangle$), and a natural way to express probabilities ($P(x)=|\langle x|\psi\rangle|^2$), expectation values ($\langle\psi|O|\psi\rangle$) and operators ($CX=|0\rangle\langle0|\otimes I+|1\rangle\langle1|\otimes X$). It is also basis-independent, so you can reason about a state without choosing a specific matrix representation.

Full page

Why is the lab's VQE result so close to the exact energy?

In the lab, $E(\theta)=\langle\psi(\theta)|H|\psi(\theta)\rangle$ is computed directly from the state vector, so there is no statistical error and no gate noise. The gradients from the parameter-shift rule are exact. The Ising model for two or three qubits is small, and its ground state has real amplitudes, so layers of $R_Y$ and CNOT can represent it well. The exact energy is computed classically by diagonalising the matrix for comparison, which is possible only for small systems.

On a real device: each term of the Hamiltonian is estimated with a finite number of shots, so the energy and the gradient become noisy; noise raises the measured energy; as the size grows, local minima and barren plateaus appear; and the exact energy is not available for comparison. So nothing should be concluded from the lab's success about VQE's performance on large systems.

Full page

Why isn't the BB84 error rate exactly 25% with an eavesdropper?

In the intercept-resend attack, each sifted bit is wrong with probability $\tfrac14$, independently of the others, so the number of errors in $m$ sifted bits follows a binomial distribution, and the standard deviation of the rate is $\sqrt{0.25\times0.75/m}$. With $n=64$ about 32 bits are sifted, so the deviation is about 7.7%, meaning that values between 15% and 35% are perfectly normal. With $n=1000$ (about 500 sifted bits) the deviation drops to about 2%.

An actual example from the Qiskit code on the BB84 page: with 64 bits the rate was 0.367, and with 1000 bits it was 0.249. In real applications a sufficient sample of bits is sacrificed to estimate the rate with confidence, and it is compared with a threshold before continuing. Without an eavesdropper the lab gives 0% because it does not model channel noise, whereas in reality there is always a background error rate.

Full page