Single-Qubit Explorer
Explore quantum states, gates and Bloch-sphere transformations.
Bloch sphere
θ = 0° · φ = 0°Drag to orbit the visualization. The orientation does not change the quantum state.
Rotation axis, sense of rotation and path of the selected step · state before it
Circuit
History
Select any step to inspect it; the sphere, state and probabilities show the state after that step. New gates and measurements are always added at the end.
Gate inspector
Try it
Short guided experiments. Make a prediction first, then check it against the simulation.
Global phase and relative phase
Global phase: not observable
eiγ|ψ⟩ ≃ |ψ⟩
Multiplying the whole state by eiγ changes nothing physical. Every probability is |eiγα|² = |α|², and the Bloch coordinates depend only on α*β and |α|², |β|², in which the factor cancels. So eiγ|ψ⟩ and |ψ⟩ are the same physical state, even though they are different vectors. We write “≃” for this equivalence and keep “=” for exact equality.
Relative phase: observable
α|0⟩ + eiφβ|1⟩
A phase on one amplitude only is different. It leaves P(0) and P(1) unchanged, but it is the Bloch azimuth φ and it changes interference. For example H(|0⟩ + eiφ|1⟩)/√2 gives P(0) = cos²(φ/2): 100% for φ = 0, 50% for φ = 90°, 0% for φ = 180°.
Rz separates the two
Rz(φ) = e−iφ/2 · diag(1, eiφ)
Rz(φ)(α|0⟩ + β|1⟩) = e−iφ/2 (α|0⟩ + eiφβ|1⟩). The factor e−iφ/2 in front is a global phase and is invisible; the factor eiφ on |1⟩ is a relative phase and turns the Bloch vector by φ about Z.
Why Rz(φ)|0⟩ does not move the Bloch vector
Rz(φ)|0⟩ = e−iφ/2|0⟩. The state vector really does change (its amplitude acquires the phase e−iφ/2), but β = 0, so there is no second amplitude for a relative phase to act on: the only change is a global phase. Geometrically, |0⟩ is the north pole, which lies on the Z axis, and a rotation never moves points on its own axis. Compare Rz(φ)|+⟩, where the vector moves around the equator.
Why a 2π rotation gives −|ψ⟩
The rotation matrices depend on θ/2: Rn(θ) = cos(θ/2) I − i sin(θ/2) n·σ. At θ = 2π this is cos(π) I − i sin(π) n·σ = −I, so Rn(2π)|ψ⟩ = −|ψ⟩ = eiπ|ψ⟩. That is a global phase π: the probabilities and the Bloch vector are exactly as before, so it is the same physical state, but not the same vector. The state vector itself returns to +|ψ⟩ only after 4π. (Within this single-qubit lab the sign is unobservable; it can become observable when a rotation is applied conditionally, controlled by another qubit.)
Each demonstration replaces the current circuit. Watch the state vector, the global phase γ and the relative phase φ in the State vector panel.
Gate reference
Each gate is a 2×2 unitary matrix acting on (α, β), and a rotation of the Bloch sphere (up to an unobservable global phase). Rx, Ry and Rz take an angle θ in radians.
| Gate | Matrix | Bloch rotation | Bloch coordinates | Amplitudes | What it does |
|---|
What are you seeing?
Every pure single-qubit state maps to a point on the Bloch sphere. The north pole is |0⟩, the south pole is |1⟩, and equatorial states are equal-probability superpositions. The vector encodes the relative phase as well as the measurement probabilities.
Try H → S and observe the rotation from the +X direction to the +Y direction. Try H → T → T for the same effect. You can also change θ and φ directly using the sliders.
For the parameterized rotations, try Ry(90°) from |0⟩ (the same state as H|0⟩), then Rz(90°), and finally Rx(360°): the Bloch vector returns, while the state vector picks up a factor −1.
Then try Y from |0⟩: the gate inspector shows Y|0⟩ = i|1⟩. The factor i is a global phase. It appears in the state vector, but the Bloch vector and probabilities are exactly those of |1⟩. Compare with H → Z, where the minus sign is a relative phase that moves the Bloch vector from +X to −X.
Two-qubit circuit
History
Basis order: |q0 q1⟩, so |10⟩ means q0 = 1 and q1 = 0. Amplitudes are listed as α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩, and a gate on q0 acts as U ⊗ I, on q1 as I ⊗ U.
Each qubit on its own
A two-qubit state cannot be drawn on one Bloch sphere. Each sphere below shows one qubit's reduced state ρ₀ = Tr₁(|ψ⟩⟨ψ|) or ρ₁ = Tr₀(|ψ⟩⟨ψ|), with Bloch vector (Tr ρX, Tr ρY, Tr ρZ). It describes that qubit alone, not the whole system: correlations between the qubits are not shown. An entangled qubit's vector shrinks inside the sphere; for a Bell state it sits at the centre.
Two-qubit inspector
Bell states
The four Bell states are the standard maximally entangled two-qubit states (C = 1). Each can be prepared from |00⟩ with a few gates. Preparing one replaces the current circuit.
Try it
Make a prediction first, then check it against the simulation.
Product states and entangled states
A two-qubit state is separable (a product state) when it can be written as |a⟩ ⊗ |b⟩: one state for q0 and one for q1. Then each qubit has a definite state of its own, both reduced Bloch vectors lie on their sphere's surface, and C = 0. Example: H on q0 gives (|00⟩ + |10⟩)/√2 = |+⟩ ⊗ |0⟩. q0 is in a superposition, but the state is still separable.
A state that cannot be written that way is entangled. For |ψ⟩ = α|00⟩ + β|01⟩ + γ|10⟩ + δ|11⟩, the test is αδ − βγ: a product (a₀|0⟩ + a₁|1⟩) ⊗ (b₀|0⟩ + b₁|1⟩) always has αδ = a₀b₀a₁b₁ = βγ. The concurrence C = 2|αδ − βγ| therefore measures entanglement: 0 for every product state, 1 for the Bell states.
In an entangled state the qubits have no individual states. Each one alone is mixed: its reduced density matrix ρ₀ or ρ₁ is not a pure state, and its Bloch vector lies inside the sphere, with length √(1 − C²). What the qubits do have is correlation: in |Φ+⟩ each qubit alone gives 0 or 1 at random, but the two outcomes always agree. Local gates on one qubit, and SWAP, never change C; a two-qubit gate such as CNOT or CZ can.
Superdense coding
Alice wants to send Bob two classical bits by sending him one qubit. This works only because they already share an entangled Bell pair: q0 is Alice's qubit and q1 is Bob's. The protocol uses up that pair.
- classical Alice's two bits: ordinary information, written b0 b1
- quantum the two-qubit state |ψ⟩ of q0 and q1
- resource the shared Bell pair |Φ+⟩ = (|00⟩ + |11⟩)/√2
Start
Encoding table
Convention: Alice acts on q0 only. “XZ” is the operator X·Z, so Z acts first and then X. The order Z·X would give the same state times −1, a global phase that no measurement can detect.
State evolution
Did we send two classical bits through one qubit?
Alice physically sends one qubit, and Bob learns two bits. But that is not the whole account: before the protocol, Alice and Bob already shared an entangled pair, and the protocol consumes it. Two bits are delivered by one transmitted qubit plus one pre-shared Bell pair.
Entanglement alone carries no message. Before q0 arrives, Bob's qubit q1 is maximally mixed (ρ₁ = I/2) whatever Alice does to q0: her four encodings leave his local statistics identical. Nothing Bob can measure on q1 alone reveals her bits, so nothing travels faster than light. The information arrives with the qubit Alice sends.
Why two bits fit. On its own, one qubit can carry at most one classical bit (Holevo's theorem). Here Alice's four operations turn the shared pair into four orthogonal Bell states of the two qubits together. Once Bob holds both qubits he can distinguish all four perfectly, so he reads two bits. Without the shared pair (Experiment 5) the same operations collapse onto two distinguishable states, and only one bit gets through.
Protocol experiments
Experiments 1–4 run the whole protocol for one message and show it in the protocol panel. Experiment 5 removes the entanglement resource.
Three-qubit circuit
History
Basis order |q0 q1 q2⟩ with index 4·q0 + 2·q1 + q2: |101⟩ means q0 = 1, q1 = 0, q2 = 1. q0 is the top wire, and a gate on q0 acts as U ⊗ I ⊗ I.
Each qubit on its own
One Bloch sphere cannot show a three-qubit state. Each sphere shows one qubit's reduced state ρ_q (the other two traced out): length 1 means that qubit is unentangled, length 0 means it is maximally entangled with the rest.
Two-qubit reduced states ρ01, ρ02, ρ12
Three-qubit inspector
Measurement
Three kinds of three-qubit states
Product: |a⟩ ⊗ |b⟩ ⊗ |c⟩. Every qubit has its own state, and every reduced Bloch vector has length 1.
Bipartite entanglement: for example a Bell pair on q0 q1 with q2 separate. Only two qubits are entangled; the third has length 1.
Entanglement among all three qubits can look very different. Two canonical examples: GHZ = (|000⟩ + |111⟩)/√2: all three qubits agree, each qubit alone is I/2, and no two-qubit pair is entangled on its own (ρ01 is a classical mixture of |00⟩ and |11⟩). The three-tangle is τ = 1. W = (|001⟩ + |010⟩ + |100⟩)/√3: exactly one qubit is 1, the entanglement is spread in pairs, and τ = 0. Measuring one qubit of GHZ destroys all the entanglement; measuring one qubit of W and finding 0 leaves the other two in a Bell state. GHZ and W cannot be turned into each other by local operations, even with classical communication and some probability of failure.
The Entanglement panel's one-tangles τ_q and three-tangle τ are teaching diagnostics for pure states. They distinguish the canonical examples used here (product, a Bell pair plus a separate qubit, GHZ and W); they are not a complete classification of every three-qubit state.
Quantum teleportation
Alice holds a qubit q0 in an unknown state |ψ⟩ = α|0⟩ + β|1⟩. She and Bob share a Bell pair: q1 is Alice's half and q2 is Bob's. Using the pair, one joint measurement and two classical bits, Alice transfers |ψ⟩ onto Bob's qubit q2, without sending q0 and without ever learning α and β.
- quantum the three-qubit state of q0, q1, q2
- resource the shared Bell pair on q1, q2
- classical Alice's measured bits m0, m1, sent by ordinary communication
Start
Alice's four possible results
Convention: Bob applies X if m1 = 1, then Z if m0 = 1. This undoes exactly what each branch did to |ψ⟩, so Bob ends with |ψ⟩ itself.
Teleportation does not copy
The no-cloning theorem says no process can turn an unknown |ψ⟩ into two copies. Teleportation obeys it: Alice's measurement collapses q0 to |0⟩ or |1⟩, so the original state on her side is destroyed at the moment it becomes available to Bob. At no time do two copies exist.
Nothing material moves. Bob's qubit q2 was with him all along; what is transferred is the quantum state, by consuming the shared Bell pair and two classical bits.
Is this faster than light?
No. Right after Alice measures, Bob's qubit is in one of four states, Xm1 Zm0 |ψ⟩, each equally likely. Until Alice's two bits arrive, Bob cannot know which correction to apply: averaged over the four possibilities his qubit is I/2, and his fidelity is exactly 1/2 for every |ψ⟩, the same as a random guess (Experiment 5 shows this). The bits travel by ordinary classical communication, at most at the speed of light, so the state cannot arrive any faster.
Teleportation experiments
Experiments 1–4 run the whole protocol and show it above (Alice's result is random each time). Experiment 5 removes Bob's corrections.
The Deutsch problem
You are given a function f : {0,1} → {0,1} as a black box (an oracle) and a promise: f is either constant (f(0) = f(1)) or balanced (f(0) ≠ f(1)). Which is it? Classically you must look at both f(0) and f(1). Deutsch's algorithm decides with a single query, by letting the two branches of a superposition interfere.
- classical the function f and its truth table
- oracle U_f |x, y⟩ = |x, y ⊕ f(x)⟩ on q0 (input x) and q1 (ancilla y)
- quantum the two-qubit state of q0 and q1
1 · Define the function
The oracle U_f
Result
The classical strategy
A deterministic classical algorithm evaluates f(0), then f(1), and compares them. One value alone cannot decide: f(0) = 0 is consistent with both the constant function f₀ and the balanced function f₂. So in the worst case, and in fact always, it needs 2 queries. Deutsch's algorithm needs 1.
For one input bit this is a saving of a single query, not an exponential speed-up. Its value is the idea: the Deutsch–Jozsa generalization to n bits needs 1 quantum query against 2^(n−1) + 1 deterministic classical queries in the worst case.
Did the quantum computer evaluate both f(0) and f(1) and read both answers?
No. The single query acts on a superposition of x = 0 and x = 1, so both values affect the state, but they end up only as signs (−1)f(0) and (−1)f(1) on the two branches. A measurement can never read out both values: measuring q0 straight after the query would give 0 or 1 at random and reveal nothing about f.
What the algorithm extracts is a single global property, whether the two signs are equal or opposite, f(0) ⊕ f(1). The final Hadamard turns “equal” and “opposite” into |0⟩ and |1⟩ by interference. You learn constant versus balanced, and nothing else: not which constant or which balanced function it is.
Exercise: build the oracle
The Deutsch–Jozsa problem: a promise problem
You are given a function f : {0,1}² → {0,1} as a black box (an oracle) and a promise: f is either constant (all four outputs equal) or balanced (exactly two outputs are 0 and two are 1). Functions that are neither are excluded by the promise. Which kind is f? A deterministic classical algorithm may need 3 queries; the Deutsch–Jozsa algorithm needs 1, by letting all four inputs interfere.
- classical the function f and its truth table f(00) f(01) f(10) f(11)
- oracle U_f |x, y⟩ = |x, y ⊕ f(x)⟩ with x = q0 q1 (input register) and y = q2 (ancilla)
- quantum the three-qubit state |q0 q1 q2⟩
1 · Choose the promised function
The oracle U_f (8 × 8)
Result
Why the outcome 00 is special
After the final Hadamards, the amplitude of |00⟩ is the plain sum of the four phase-tagged branches: A(00) = (1/4) Σ_x (−1)f(x). Every branch enters with a + sign, so nothing but f's own signs decides the result.
If f is constant, all four signs agree: they add up (constructive interference) to A(00) = ±1, and the register is certainly 00. If f is balanced, two signs are + and two are −: they cancel completely (destructive interference), A(00) = 0, and 00 can never be measured. This is the heart of the Deutsch–Jozsa algorithm.
Deeper view: the Walsh–Hadamard transform
H on both input qubits is the Walsh–Hadamard transform: it compares the phase pattern (−1)f(x) with each of the four patterns (−1)s·x, where s·x = s₀x₀ ⊕ s₁x₁, and A(s) is (1/4) × (number of matches − number of mismatches). Outcome 00 uses the all-+ pattern, which is why it measures “all signs equal”.
For n = 2 every balanced phase pattern matches one of the non-zero patterns exactly (up to an overall sign), so that outcome has probability 1. Comparing a phase pattern with these sign patterns is also the idea behind Bernstein–Vazirani and Simon's algorithm, and a first step towards the quantum Fourier transform.
The classical strategy: 3 queries in the worst case
A deterministic classical algorithm asks for f(x) one input at a time. If two answers differ, f is balanced and it can stop. But after two equal answers, say f(00) = f(01) = 0, f could still be the constant 0000 or the balanced 0011. A third query settles it: three equal outputs are impossible for a balanced function, which has only two of each. So the worst case is 2^(n−1) + 1 = 3 queries for n = 2 (not 4, the size of the truth table). The quantum algorithm uses 1.
This is a comparison in the oracle (query) model, for exact deterministic answers, under the promise. For general n the classical worst case 2^(n−1) + 1 grows exponentially while the quantum count stays 1; a randomized classical algorithm that may err with small probability needs only a few queries. It is not a claim that quantum computers speed up every problem.
Does the measurement reveal the truth table?
No. The single query puts all four values f(00) … f(11) into the state, but only as signs on the branches, and no measurement can read them all out. The algorithm extracts one global property promised in advance: constant or balanced.
For a balanced function the register gives some non-zero string, such as 10. That string is not “the value of f” and not the truth table: different balanced functions give different strings, and it is enough to know that the string is not 00.
Exercise: classical query complexity
Unstructured search with N = 4 items
Four items, 00, 01, 10 and 11, and exactly one is marked. You cannot look inside; you can only ask an oracle about the items. Grover’s algorithm finds the marked item by amplitude amplification: the oracle marks the answer with a phase, and the diffusion operator turns that phase difference into a large measurement probability. For N = 4 a single oracle query is enough.
- classical the marked item m, one of 00, 01, 10, 11
- oracle O_m |x⟩ = −|x⟩ if x = m, |x⟩ otherwise, on q0 and q1
- quantum the two-qubit search register |q0 q1⟩
1 · Choose the marked state
The oracle O_m and the diffusion D
Result
Does the oracle tell us which item is marked?
No. The oracle only multiplies the marked state’s amplitude by −1. Nothing about that is visible to a measurement on its own: |−1/2|² = |+1/2|². It is the diffusion operator that uses interference, the reflection of every amplitude about their mean, to amplify the marked amplitude and suppress the others.
Why not just measure after the oracle?
Because immediately after the oracle all four probabilities are still exactly 1/4. A measurement at that point gives each item with probability 1/4, a pure guess. (Step 5 lets you try this with 1,000 shots.) The diffusion step is what converts the phase information into a probability advantage.
How Grover scales
Searching N unsorted items with one marked item, a deterministic classical algorithm needs Θ(N) oracle queries. Querying the items in a fixed order, and using the promise that exactly one is marked, it needs N − 1 in the worst case (after N − 1 “unmarked” answers the last item is known without a query) and (N − 1)(N + 2)/(2N) on average: 3 and 2.25 for N = 4. Grover’s algorithm needs O(√N) oracle queries, about (π/4)√N. That is a quadratic speed-up in the unstructured-search oracle model, not an exponential one, and it is known to be optimal for quantum algorithms in this model.
N = 4 is a special teaching case: one iteration lands exactly on the marked state, with certainty. For other N the success probability after r iterations is sin²((2r + 1)θ) with θ = arcsin(1/√N). It is high for the right r but generally not 100%, and doing too many iterations makes it fall again.
Deeper view: Grover as a rotation
Write every state as cos φ |rest⟩ + sin φ |m⟩, where |rest⟩ is the equal superposition of the unmarked items. The start |s⟩ has sin θ = 1/√N = 1/2, so θ = π/6 (30°). The oracle reflects the state across |rest⟩ (φ → −φ) and the diffusion reflects it across |s⟩; two reflections make a rotation by 2θ = π/3 (60°). After one iteration the angle is 3θ = π/2 (90°): exactly |m⟩.
Exercise: the phase oracle
Exercise: inversion about the mean
The Quantum Fourier Transform
The QFT is the discrete Fourier transform applied to the amplitudes of an n-qubit state: QFT|x⟩ = (1/√N) Σ_k e2πi·xk/N |k⟩ with N = 2ⁿ. It turns a basis state into an equal-magnitude superposition whose phases advance in steps of 2πx/N, and it turns such phase patterns back into basis states. It is built from Hadamards, controlled phase rotations and SWAPs.
- classical the input x, written in binary on q0 … q(n−1)
- circuit H, controlled R_m = diag(1, e2πi/2^m), SWAP
- quantum the register |q0 q1 …⟩: magnitudes and phases
1 · Choose register size and input
The QFT matrix
The QFT circuit
Bit order in this lab
As everywhere in Quantum Learning Lab, q0 is the top wire and the most significant bit: |q0 q1⟩ is x = 2·q0 + q1, and |q0 q1 q2⟩ is x = 4·q0 + 2·q1 + q2. Input x and output k use the same convention, and the SWAPs at the end make the circuit equal to the QFT matrix exactly. Many textbook figures omit those SWAPs and instead read the output wires in reverse order; that is the same transform with the output bits relabelled, not a different one.
What the QFT does, and what it does not
The QFT changes the representation: information carried by which basis state is occupied becomes information carried by how phases advance across all basis states, and back. Periodic or phase structure in a state becomes something interference can turn into a measurable bit string.
It does not let you read out the Fourier coefficients. A measurement returns one basis state, with probability |amplitude|². After QFT|x⟩ every outcome has probability 1/N, so measuring right away reveals nothing about x. The QFT on its own gives no speed-up; it is a building block whose value appears inside algorithms such as quantum phase estimation, order finding and Shor's factoring algorithm, which prepare a phase pattern first and use the (inverse) QFT to read it.
Quantum Phase Estimation
A unitary U has eigenstates |ψ⟩ with U|ψ⟩ = e2πiφ|ψ⟩. Quantum phase estimation estimates the phase φ. Controlled powers of U write φ into the phases of a counting register, and the inverse QFT turns that phase pattern into a binary number that can be measured. Here: two counting qubits (q0 most significant, q1 least significant) and a target q2 prepared in the eigenstate |1⟩ of U_φ = diag(1, e2πiφ).
- classical the phase φ and the measured estimate 0.b0b1
- circuit X, H, controlled U and U², inverse QFT
- quantum the three-qubit state |q0 q1 q2⟩
1 · Choose the phase φ
Result
The unitary, its eigenstate and the controlled powers
Inside the QFT⁻¹ block
Does QPE directly measure the eigenvalue matrix?
No. QPE estimates the phase φ of one eigenvalue e2πiφ of a unitary U, and only when the target register is prepared in (or close to) the corresponding eigenstate. It never reads out U or its matrix entries, and the result is φ to a fixed number of bits.
Why do we need the inverse QFT?
After the controlled powers, φ is stored only in the relative phases e2πikφ across the counting register, and every outcome still has probability 1/4. That phase pattern is exactly what the QFT produces from a basis state, so the inverse QFT converts it into a computational-basis bit string that a measurement can read.
Finite precision
With t counting qubits, QPE can return only multiples of 1/2^t. Here t = 2, so the estimates are 0, 1/4, 1/2 and 3/4. Phases that are exact multiples give that answer with certainty. Others, such as φ = 1/3 (binary 0.0101…), give a random result concentrated on the nearest estimates; more counting qubits sharpen it.
Noise, decoherence and mixed states
Every other lab simulates an ideal quantum computer. Real qubits interact with their environment. Here you prepare a pure state, apply one noise channel, and compare. Noise changes more than measurement probabilities: it destroys coherence and purity, producing mixed states that no single ket can describe. A density matrix ρ describes them correctly, and each channel acts as ρ → Σk Ek ρ Ek† with Kraus operators Ek.
- ideal the pure input state |ψ⟩ and ρ = |ψ⟩⟨ψ|
- channel bit flip, phase flip, depolarizing, amplitude damping, phase damping
- noisy the output density matrix, possibly mixed
Ideal vs noisy
Bloch vector: on the surface or inside?
ρ = (I + rxX + ryY + rzZ)/2 with rx = 2 Re ρ₀₁, ry = −2 Im ρ₀₁, rz = ρ₀₀ − ρ₁₁. Pure states have |r| = 1 and sit on the surface; mixed states have |r| < 1 and sit inside. The centre, |r| = 0, is the maximally mixed state I/2 with purity 1/2.
The selected channel
3 · Measurement: ideal vs noisy
Compare all channels
The same input and strength through every channel. Not all noise behaves the same way.
Phase flip vs phase damping
Both leave P(0) and P(1) unchanged and shrink the coherence. A phase flip models a discrete Z error that happens with probability p; at p = 1 it is a definite Z, so |+⟩ becomes |−⟩, still pure. Phase damping models a gradual loss of phase information to the environment; at λ = 1 the coherence is gone completely, and it never turns |+⟩ into |−⟩. For λ in [0, 1], phase damping has the same effect on ρ as a phase flip with p = (1 − √(1 − λ))/2 ≤ 1/2. They describe different physical processes, and only the phase flip reaches the coherent error Z.
Some noise is invisible in the computational basis
Phase damping or a phase flip on |+⟩ leaves P(0) = P(1) = 1/2 exactly as before, yet the state has changed: its coherence, and with it the X-basis probabilities, are gone. Characterizing a quantum state (state tomography) therefore needs measurements in several bases, here Z, X and Y, which together give rz, rx and ry.
Errors, noise and decoherence
An error usually means a specific event, such as an X or Z acting on a qubit. A noise channel models our uncertainty about which errors happened, or the effect of an interaction with an environment we do not track; it is a probability-weighted (Kraus) description, not a single event.
Decoherence is the loss of phase relationships (coherence) between basis states caused by that interaction. It is not just random bit flipping: phase damping destroys coherence without moving any population, and amplitude damping removes energy and coherence together.
Why quantum error correction?
Quantum information is fragile. An unknown state cannot be copied (the no-cloning theorem), so it cannot simply be backed up; measuring it to check for errors generally disturbs it; and two independent kinds of error matter, bit flips and phase flips, plus everything in between. Coupling to the environment causes decoherence continuously.
Quantum error correction encodes one logical qubit into several physical qubits so that errors can be detected indirectly, by measuring parities (syndromes) that reveal which error occurred without revealing, and so destroying, the encoded state. The simplest codes protect against single bit flips or single phase flips; codes such as Shor's 9-qubit code and surface codes protect against both.
Coming soon
Until then, the protocols use the same ideas this algorithm needs: superposition, entanglement and interference. Try Superdense Coding or Quantum Teleportation.