Represent a qubit
Interpret amplitudes, probabilities, relative phase, normalization, and positions on the Bloch sphere.
Interactive quantum computing studio
Explore qubits, superposition, interference, entanglement, gates, measurement, algorithms, and noise in one self-contained teaching workspace. Every simulation runs locally in this HTML file.
A quantum computer is not simply a faster conventional computer. It represents and transforms complex probability amplitudes, then uses interference and measurement to extract useful information. This lab builds that idea gradually and lets you test each concept.
Vocabulary, expectations, and the mathematical language used throughout the page
Quantum computing is a model of computation that stores information in quantum states and manipulates those states with controlled physical operations. A useful quantum algorithm arranges amplitudes so that unwanted answers interfere destructively while useful answers are made more likely.
A quantum processor does not inspect every possible answer and return the whole list. Measurement produces classical outcomes, so an algorithm must be designed to concentrate probability on information that can be recovered with a practical number of measurements.
Think of a quantum program as an experiment: prepare a state, transform its amplitudes, entangle systems when useful, measure, and repeat enough times to estimate a distribution.
Most circuit-model tutorials use this sequence. Different hardware platforms implement the physical details differently, but the abstract circuit description is broadly shared.
Interpret amplitudes, probabilities, relative phase, normalization, and positions on the Bloch sphere.
Distinguish a coherent superposition from a classical mixture and connect phase to interference.
Identify Bell states, examine joint outcomes, and understand what correlations do and do not imply.
Apply common one- and two-qubit gates and inspect the resulting two-qubit state vector.
Use the Born rule, estimate sampling uncertainty, and see how finite shots affect observed counts.
Relate decoherence, gate errors, connectivity, and error correction to practical quantum computing.
Comfort with vectors, complex numbers, trigonometry, probability, and basic matrices is helpful. The simulations provide numerical results so students can begin conceptually and revisit the formalism later.
| Idea | Notation | Meaning in this lab |
|---|---|---|
| Complex number | z = a + bi | Amplitudes can have both magnitude and phase. The imaginary unit satisfies i2 = -1. |
| Magnitude squared | |z|2 = a2 + b2 | Converts a complex amplitude into a nonnegative probability contribution. |
| Column vector | [α, β]T | Stores amplitudes associated with computational-basis states. |
| Matrix-vector product | |ψ'〉 = U|ψ〉 | Describes how a quantum gate transforms a state. |
| Tensor product | |a〉 ⊗ |b〉 | Combines the state spaces of multiple quantum systems. |
| Inner product | 〈φ|ψ〉 | Measures overlap between states and appears in probability calculations. |
A normalized two-dimensional quantum state with amplitude and relative phase
A classical bit is described as 0 or 1. A pure qubit is described by two complex amplitudes associated with basis states |0〉 and |1〉. Before measurement, both amplitudes participate in later transformations.
|ψ〉 = α|0〉 + β|1〉, where |α|2 + |β|2 = 1When measured in the computational or Z basis, the probability of 0 is |α|2 and the probability of 1 is |β|2. The amplitudes themselves are not ordinary probabilities because they may be negative or complex and can interfere.
The polar angle θ controls the balance between 0 and 1. The azimuthal angle φ controls relative phase. A global phase multiplying the entire state cannot be observed directly.
Move around the Bloch sphere, inspect amplitudes, and take measurements
The arrow shows the state; bars show the latest finite-shot experiment
Enter any nonzero pair of complex numbers and convert them into a valid qubit
The states |ψ〉 and eiγ|ψ〉 predict the same measurement statistics in every experiment. By contrast, changing only the phase of β changes the relative phase, which can change interference after another gate.
The Bloch sphere visualizes the abstract state of an ideal two-level quantum system. It is not necessarily the physical path traced by an electron, photon, ion, or superconducting circuit.
Why phase-sensitive amplitudes are more powerful than ordinary probability weights
A state is in a superposition relative to a chosen basis when it is expressed as a nontrivial linear combination of basis states. For example, |+〉 = (|0〉 + |1〉)/√2 is an equal superposition in the Z basis but is a definite state in the X basis.
The phrase “the qubit is both 0 and 1” can be a useful first metaphor, but it is incomplete. A coherent superposition carries relative phase, and later operations can recombine its amplitudes to produce interference. A classical 50/50 mixture lacks that phase relationship.
The Hadamard gate changes between Z-basis and X-basis descriptions. Applying H twice returns the original state because H2 = I.
Amplitudes with aligned phase add, increasing the probability of the associated outcome.
Amplitudes with opposite phase cancel, decreasing or eliminating an outcome.
A state definite in one measurement basis may be a superposition in another.
Simulates the circuit |0〉 → H → Rz(φ) → H → measure
The marker follows your phase; lower visibility models loss of coherence
Both |+〉 and a 50/50 classical mixture of |0〉 and |1〉 produce equal Z-basis outcomes. Apply H before measurement, however, and |+〉 becomes |0〉 with certainty while the mixture still gives a 50/50 distribution. Interference reveals coherence.
Many quantum algorithms encode information in relative phase and then use a transform to convert phase differences into measurable probability differences. Tracking only probabilities would miss the mechanism.
Joint quantum states that cannot be reduced to independent states of their parts
Two qubits are separable when their joint state can be written as a tensor product |a〉 ⊗ |b〉. They are entangled when no such factorization exists. In an entangled state, the complete system has a well-defined state even though each qubit by itself may not have a pure state.
The Bell state |Φ+〉 = (|00〉 + |11〉)/√2 is created by applying H to the first qubit and then a CNOT controlled by that qubit. Measuring both in the Z basis produces 00 or 11 with equal probability, never 01 or 10 in the ideal model.
Bell states can show perfect correlation or anticorrelation in selected bases. The pattern is stronger than any local hidden-variable description can reproduce across appropriately chosen settings.
A local measurement outcome is random. Entanglement becomes evident only when classical records from both locations are later compared, so it cannot be used by itself to transmit a controllable message instantaneously.
Select a Bell state and local Pauli measurement bases
Outcomes use + and - eigenvalue labels for the selected bases
| Outcome | Ideal probability | Observed count |
|---|
Uses the singlet-state prediction E(a,b) = -cos(a-b) for axes in one plane
The classical local-hidden-variable threshold is |S| ≤ 2
| Setting | Ideal E | Sampled E |
|---|
These settings produce |S| = 2√2, which exceeds the classical CHSH bound.
Reversible unitary transformations, controlled operations, and two-qubit state vectors
In the circuit model, a quantum gate is represented by a unitary matrix U satisfying U†U = I. Unitary evolution preserves normalization and is reversible. Measurement is shown separately because it is not an ordinary unitary gate on the measured system.
Single-qubit gates rotate or phase-shift a Bloch vector. Multi-qubit gates condition one operation on another qubit and can create entanglement. A universal gate set can approximate any finite quantum computation to arbitrary accuracy.
| Gate | Action | Selected relationships | Typical use |
|---|---|---|---|
| X | Bit flip; rotation by pi about X | X|0> = |1>, X|1> = |0> | Prepare or invert a computational-basis value. |
| Y | Bit and phase flip; rotation about Y | Y|0> = i|1>, Y|1> = -i|0> | General rotations and Pauli measurements. |
| Z | Phase flip; rotation about Z | Z|+> = |-> | Change relative phase without changing Z probabilities. |
| H | Hadamard basis change | H|0> = |+>, H|+> = |0> | Create or recombine equal superpositions. |
| S | Quarter turn about Z, up to global phase | S = diag(1,i) | Clifford circuits and phase control. |
| T | Eighth turn about Z, up to global phase | T = diag(1,e^(i*pi/4)) | Non-Clifford resource for universal fault-tolerant circuits. |
| CNOT | Flips target when control is 1 | CNOT(H|0> tensor |0>) = |Phi+> | Entanglement, arithmetic, and error correction. |
| SWAP | Exchanges two qubit states | SWAP|01> = |10> | Route quantum information across limited connectivity. |
Apply gates from left to right; q0 is the most significant displayed bit
Single-qubit gates on q0
Single-qubit gates on q1
Two-qubit operations
Amplitudes are complex; bars show computational-basis probabilities
| Basis | Amplitude | Phase | Probability |
|---|
For a pure two-qubit state with amplitudes a, b, c, and d, concurrence is C = 2|ad - bc|. C = 0 indicates a separable pure state; C = 1 indicates maximal two-qubit entanglement. It does not replace the broader theory of mixed-state entanglement.
There is no unitary operation that perfectly copies an arbitrary unknown quantum state. Known classical basis values can be copied with CNOT, but an arbitrary superposition cannot be cloned without violating linearity.
Born probabilities, finite-shot uncertainty, collapse, tomography, and classical simulation cost
Measurement converts quantum information into a classical outcome. For a state |ψ〉 measured with projector Pm, the Born rule gives p(m) = 〈ψ|Pm|ψ〉. After an ideal projective measurement yielding m, the state is updated consistently with that outcome.
Because individual results are probabilistic, quantum experiments are normally repeated. Each repetition is called a shot. Counts approximate the underlying probabilities, with sampling fluctuations that shrink roughly as 1/√N.
This simple interval describes ideal independent sampling. Real hardware can add readout bias, drift, correlations, leakage, and other nonideal effects.
A basis defines which alternatives the instrument distinguishes. Rotating before a Z measurement implements X, Y, or other basis measurements.
One shot gives one bit string. Many shots estimate a probability distribution or expectation value.
Measurements in multiple settings can reconstruct an estimated density matrix, but the number of required settings grows rapidly.
Estimate statistical uncertainty for a binary measurement
Near p = 0 or p = 1, or with very few shots, a normal approximation can be poor. Exact or score-based intervals may be preferable for formal analysis.
See why exact classical simulation becomes difficult as qubit count grows
Specialized simulators can exploit sparsity, stabilizer structure, tensor networks, symmetry, approximate truncation, and distributed memory. The full dense state-vector estimate is still a useful scaling baseline.
| Statement | Better interpretation |
|---|---|
| “Measurement merely reads a value that was already present.” | For general quantum observables, the theory predicts outcome distributions and post-measurement states; experiments rule out broad classes of simple local preassigned-value models. |
| “One measurement reveals the amplitudes.” | A single shot returns one outcome. Amplitude information requires many preparations and measurements, often in multiple bases. |
| “More shots remove hardware error.” | More shots reduce random sampling uncertainty but do not automatically eliminate systematic bias, decoherence, or calibration error. |
| “A zero count means zero probability.” | With finite sampling, a rare event may simply not appear. Confidence bounds depend on the shot count and model assumptions. |
How structure, interference, and measurement can reduce particular computational costs
A quantum advantage comes from an algorithm-problem-hardware combination, not from superposition alone. An algorithm must prepare a useful state efficiently, exploit mathematical structure through coherent operations, and produce an answer that survives measurement with favorable resource scaling.
Complexity claims should specify the task, input model, error tolerance, success probability, and the cost of data loading and readout. Some celebrated speedups require fault-tolerant machines, while near-term approaches often seek useful approximations or scientific simulations.
A teaching algorithm that distinguishes constant from balanced oracle functions with one quantum query under a promise, illustrating interference and query complexity.
Finds a marked item in an unstructured search space using on the order of the square root of N oracle calls, rather than order N classically.
Estimates an eigenphase of a unitary operator. It supports Shor's algorithm and many quantum simulation and chemistry methods.
Uses period finding to factor integers in polynomial time in the ideal fault-tolerant circuit model, threatening widely used public-key schemes at sufficient scale.
Models quantum systems using quantum degrees of freedom, a motivation extending from Feynman's early arguments to chemistry and materials research.
Alternate parameterized quantum circuits with classical optimization. They are flexible, but trainability, noise, benchmarking, and classical competition matter.
Track success probability as the Grover iterate rotates toward marked states
Grover's algorithm assumes an oracle that identifies marked states coherently. Oracle construction, reversible implementation, and error-correction overhead can dominate a practical application.
Too many iterations rotate amplitude away from the target again
The selected iteration count is close to the first high-probability peak.
| Problem / method | Classical reference scaling | Quantum scaling or role | Important qualification |
|---|---|---|---|
| Unstructured search | O(N) | O(sqrt(N)) oracle queries | Quadratic, not exponential; coherent oracle implementation is required. |
| Integer factoring | No known classical polynomial-time algorithm | Polynomial-time quantum algorithm in the standard ideal model | Cryptographically relevant instances require large fault-tolerant resources. |
| Quantum-system dynamics | Generic state descriptions can grow exponentially | Quantum hardware naturally represents quantum state space | Preparation, observables, precision, and fault-tolerant cost determine usefulness. |
| Optimization by QAOA / annealing | Problem-dependent heuristics | Quantum heuristic or sampling approach | No blanket speedup; compare solution quality, runtime, energy, and classical baselines. |
| Linear systems (HHL family) | Classical numerical linear algebra | Potential exponential dependence improvement under assumptions | Returns a quantum state and relies on sparsity, conditioning, state preparation, and limited observables. |
Why real qubits lose information and how fault-tolerant computation protects logical states
Physical qubits interact imperfectly with controls, neighboring qubits, and their environment. These interactions can change populations, erase relative phase, leak outside the intended two-level subspace, or corrupt measurement. Quantum noise is commonly modeled with channels acting on density matrices.
T1 characterizes energy relaxation toward the ground state in a simple exponential model. T2 characterizes loss of transverse phase coherence. Gate fidelity, crosstalk, connectivity, leakage, readout error, calibration drift, and correlated errors also shape circuit performance.
These exponentials are educational approximations. Actual decay may be nonexponential or depend on pulse sequence, noise spectrum, operating point, and device architecture.
Energy exchange drives an excited state toward a lower-energy state, changing Z-basis populations.
Random phase accumulation reduces coherent off-diagonal terms and weakens interference.
The measurement apparatus may report the wrong classical label or disturb neighboring qubits.
Driving one qubit can unintentionally affect other qubits or couplers.
Compare energy relaxation and phase-coherence decay over circuit time
Selected time is marked on normalized T1 and T2 exponentials
The condition T2 ≤ 2T1 holds for common Markovian relaxation-plus-dephasing models. Entering T2 above 2T1 is allowed for exploration, but the page will flag that simplified-model inconsistency.
Ancilla-assisted measurements reveal information about errors without directly measuring the encoded logical state.
A classical decoder interprets syndrome history and selects a likely correction or updates a tracked Pauli frame.
Fault-tolerant protocols constrain error propagation while implementing computation on encoded information.
If physical operations are sufficiently accurate and noise satisfies the code's assumptions, increasing code distance can suppress logical error rates. The required overhead depends strongly on hardware, code, decoder, target algorithm, and error model.
Mitigation techniques estimate or extrapolate less noisy observables without fully encoding a logical qubit. They can help small experiments but usually add sampling or modeling cost and do not by themselves create arbitrarily reliable long computations.
| Approach | Core idea | Tradeoff |
|---|---|---|
| Dynamical decoupling | Pulse sequences average selected low-frequency noise during idle periods. | Adds pulses and depends on timing, calibration, and noise spectrum. |
| Zero-noise extrapolation | Run at several effective noise levels and extrapolate an observable toward zero noise. | Sampling overhead and extrapolation bias can grow rapidly. |
| Probabilistic error cancellation | Represent an ideal operation as a signed combination of noisy operations. | Requires noise characterization and can have severe sampling overhead. |
| Quantum error detection | Discard runs whose syndrome indicates an error. | Reduces accepted data and does not correct every error. |
| Quantum error correction | Encode logical information across many physical qubits and repeatedly extract syndromes. | Large qubit, control, decoding, and fault-tolerant gate overhead. |
Guided investigations for individual work, lab reports, or classroom discussion
State the question, make a prediction, identify variables, record parameter values and results, explain the quantum concept, distinguish ideal-model behavior from hardware behavior, and identify one limitation or follow-on experiment.
Question: How do theta and phi separately affect computational-basis measurement?
Question: What information is lost as visibility approaches zero?
Question: How can local randomness coexist with strong joint structure?
Question: Which gate sequence creates a Bell pair, and can it be reversed?
Question: How rapidly do observed frequencies approach a model probability?
Question: Why is there an optimal stopping time?
Notes are saved locally in this browser and can be exported as a text file
No notebook changes saved in this session.
Twelve questions covering the conceptual and mathematical foundations
1. For |psi> = alpha|0> + beta|1>, which condition makes the state normalized?
2. Which feature distinguishes a coherent equal superposition from a classical 50/50 mixture?
3. What does the Hadamard gate do to |0>?
4. Which state is entangled?
5. Why can entanglement not be used alone for faster-than-light communication?
6. Which property must an ideal closed-system quantum gate have?
7. Starting from |00>, which sequence creates Phi+?
8. Increasing a binary experiment from N to 4N shots changes the standard error by approximately what factor?
9. A dense n-qubit state vector contains how many complex amplitudes?
10. What happens if Grover iterations continue far beyond the first optimum?
11. In a simple exponential model, T1 primarily describes what?
12. Which statement best distinguishes error mitigation from full quantum error correction?
Core vocabulary used in introductory quantum information science
Official tutorials, browser tools, open learning paths, and algorithm references
The page itself operates offline. The links below open third-party educational sites and may require internet access, accounts, or acceptance of separate terms. Resource availability and interfaces can change over time.
An accessible overview of qubits, superposition, entanglement, interference, and the role of measurement.
A concise public-facing explanation of quantum information science and why it matters for scientific computing.
A structured course on the mathematical formulation of quantum information, circuits, entanglement, and protocols.
Conceptual and mathematical treatment of qubit states, measurement probabilities, and Bloch-sphere coordinates.
A hands-on tutorial that creates and measures entangled qubits using the Q# development environment.
Documentation and tutorials for an open-source Python framework for writing, simulating, and running quantum circuits.
A browser-based drag-and-drop circuit simulator that immediately visualizes state and gate behavior.
A quantum-computing platform with educational materials and access to simulation or supported backends.
An interactive essay and spaced-repetition approach to learning quantum computation and quantum mechanics.
A curated collection of learning resources covering mathematics, programming, algorithms, and hardware.
A catalog of quantum algorithms organized by application area and computational speedup.
Code examples that can support follow-on programming exercises and classroom demonstrations.
Eigenvalues, spectral decompositions, Kronecker products, density operators, partial trace, and operator norms.
Mixed states, channels, entropy, fidelity, trace distance, teleportation, superdense coding, and no-cloning.
Build circuits in Qiskit, Cirq, Q#, PennyLane, or another framework; compare ideal and noisy simulation.
Phase estimation, amplitude estimation, quantum walks, Hamiltonian simulation, variational eigensolvers, and cryptanalysis.
Superconducting circuits, trapped ions, neutral atoms, photons, spins, topological approaches, controls, and cryogenics.
Stabilizer formalism, CSS codes, surface codes, thresholds, lattice surgery, magic-state distillation, and resource estimates.
Use the left learning path, top jump menu, or in-page buttons. The active section is highlighted as you scroll.
Every simulator is implemented in the embedded JavaScript. Seed fields make most finite-shot samples repeatable, which is helpful when students compare results.
Mark sections complete after reviewing them. Completion state, lab checkboxes, theme choice, and notebook text are stored in local browser storage only.
Export Notes or Download Notebook creates a plain-text lab record. Print produces a classroom-friendly version of the explanatory material.
Models are educational and idealized. They are not substitutes for a hardware vendor's compiler, calibrated noise model, formal statistical analysis, or validated resource estimate.