Officina Turini · Educational freeware · C++14 / Qt5 · v0.16.0
A classical computer manipulates bits. A quantum processor controls physical states described by complex amplitudes. QuantumLab is not a quantum processor: your PC simulates those amplitudes, so you can pause an experiment and inspect information that cannot be directly read from real hardware.
Lessons 01–04: observe. 05–14: build and check. 15–21: discover algorithms. Afterwards use the parametric lab to change oracles, secrets and iteration counts.
For one ideal qubit we write |ψ⟩ = α|0⟩ + β|1⟩. The amplitudes α and β may be complex; the probabilities are |α|² and |β|² and sum to one.
With n qubits the computational basis has 2n states. The simulator holds 2n complex amplitudes; this does not allow you to read 2n answers in one measurement.
QuantumLab numbers q0 as the least significant bit on the right. In two qubits, |10⟩ means q1=1 and q0=0. X(q0) applied to |00⟩ gives |01⟩; X(q1) gives |10⟩.
Multiplying the entire state by eiφ changes no observable predictions. Changing just one amplitude’s sign can change later interference. Challenges therefore use fidelity, invariant under global phase but sensitive to relative phase.
Measurement draws an outcome and collapses the simulated state. Repeated preparations (10, 100, 1000 or 10000) instead draw independent samples from the same preparation; they are not consecutive measurements of one already-collapsed qubit. A single shot does not validate a probabilistic algorithm.
| Gate | Effect | Try it |
|---|---|---|
| X | Swaps |0⟩ and |1⟩ (computational-basis NOT). | X·X = identity. |
| H | Mixes amplitudes: H|0⟩=(|0⟩+|1⟩)/√2. | H·H = identity. |
| Z | Negates the |1⟩ amplitude; does not instantly change probabilities. | H–Z–H acts as X. |
| P(θ) | Multiplies the |1⟩ amplitude by eiθ. | P(180°)=Z; input is degrees. |
| CNOT | Flips target if the control qubit is 1. | H(q0), CNOT(q0→q1): Bell. |
Before measurement these operations are unitary and reversible. Circuit gates act in time order; CNOT has two distinct qubits, control and target.
Lesson: question, hints, challenge checking. Algorithms: oracle parameters and checkpoints. Editor: gates and qubits. Measurements: prediction, sampling, validation and report.
The circuit viewer supports zoom and step selection; the amplitude/probability table and the Laboratory Notebook sit below. Splitters adjust pane sizes. QSettings remembers the layout.
Advance a gate changes the simulated state. Jump to checkpoint reconstructs an intermediate state without a physical measurement. Measure samples and collapses. The 1000 shots sample many independent preparations.
To modify a prepared lesson create a working copy. Insert or replace gates; old shots are invalidated. Save the circuit as .qlab.json; export predictions, counts and outcomes as a separate JSON result. Unsaved changes are indicated in the title and protected at exit.
The selector switches labels, tooltips, explanations and manual. QSettings under Officina Turini / QuantumLab remembers language and window geometry.
For every exercise: (1) predict an outcome, (2) build or explore, (3) inspect amplitudes, (4) sample repeatedly, (5) explain. A surprising result is useful if you can trace its cause.
Challenges 05–14 start blank. They are graded against the final state, plus teaching constraints when needed (required gates, minimum length). They are not graded on lucky measurements.
An oracle is a reversible circuit exposing a function. In the query model one complete use of Uf counts as one query even if built from many X, H, P and CNOT gates. Always separate queries, elementary gates, RAM and elapsed time.
The one-bit function is promised constant or balanced. A deterministic classical algorithm may need two queries for certainty; Deutsch needs one. Read only data qubit q0: 0=constant, 1=balanced. The ancilla is not the answer.
The oracle returns f(x)=s·x mod 2. For s=101, three classical basis-vector queries recover the three bits; the quantum circuit uses one logical call. Read q2q1q0; q3 is an ancilla and may measure randomly.
Unstructured search has one marked state. The oracle flips its phase, and diffusion converts that phase into increased amplitude. Optimal query complexity scales as O(√N), rather than O(N). The gate cost of constructing oracle and diffusion must be counted separately.
| 3 qubits, target |101⟩ | Ideal probability |
|---|---|
| Uniform preparation | 12.5% |
| 1 iteration | 78.125% |
| 2 iterations | 94.53125% |
| 3 iterations | 33.0078125% |
| 4 iterations | 1.220703125% |
QuantumLab is an ideal state-vector simulator. It stores one complex amplitude per computational basis state. At two double values per amplitude, the state alone needs about 16·2n bytes.
| Qubits | State-vector RAM (complex double) |
|---|---|
| 8 | 4 KiB |
| 20 | 16 MiB |
| 30 | 16 GiB |
| 32 | 64 GiB |
The present editor is deliberately limited to 1–8 qubits; the parametric Grover lab uses 2–3 qubits. Support for 30 qubits is a possible future development, not a current feature.
This software does not fully simulate gate noise, decoherence, actual processor connectivity, error correction or energy costs. Displayed amplitudes are internal information from the numerical model, not quantities directly readable from hardware in one measurement.
The v0.11 scientific suite checks analytical vectors, an independent matrix-based reference, norm conservation, circuit replay and algorithms. The Measurements tab shows PASS/FAIL and exports a JSON report.
A successful test suite does not prove there are no bugs; compilation on another PC still requires verification. When something looks wrong, reduce to a few gates and compare amplitudes, probabilities and checkpoints.
For two normalized pure states |ψ⟩ and |φ⟩, fidelity is F = |⟨φ|ψ⟩|². It remains 1 when the states differ only by global phase. Challenges may also impose required gate types or lengths.
Sampling is random. Theoretical probability does not enforce a fixed quota per experiment.
Z changes relative phase. Add a later H to observe the effect.
It compares the quantum state (including relative phase) and some lesson constraints. Try lessons 11 and 13.
The ancilla remains in superposition; the answer lives in the data qubits only.
It is a rotation; pushing beyond the optimum decreases success probability.
No: the program is a classical computer simulating a quantum circuit. The discussion concerns abstract queries, not CPU simulation time.
Circuits save as .qlab.json; shot data export separately. Remembering language or window layout does not automatically save a modified circuit.
The internal manual is compiled into the application as a resource. If building from source, check that Help/QuantumLabHelp.qrc is processed by Qt RCC.
| Term | Operational meaning |
|---|---|
| Amplitude | Complex number whose squared magnitude is a probability. |
| Computational basis | States indexed by binary strings. |
| Ancilla | Service qubit that need not be part of the answer. |
| Interference | Combination and cancellation of complex amplitudes. |
| Relative phase | Difference in phase between amplitudes that can affect measurements. |
| Global phase | Overall phase factor with no observable effect. |
| Entanglement | Composite state not factorable into independent subsystem states. |
| Fidelity | Squared overlap of two pure quantum states. |
| Oracle | Reversible implementation of a function used by an algorithm. |
| Shot | One preparation followed by one measurement. |
| Checkpoint | Reconstructed intermediate state for inspection, not a physical measurement. |
This material is not a prerequisite: it explains what you have already observed.
H applied to |0⟩ gives (1/√2,1/√2); Z negates the second component; another H gives (0,1). That is the complete calculation behind lesson 04.
Independent qubits form tensor products. The ordered basis is |00⟩, |01⟩, |10⟩, |11⟩; q0 is on the right. CNOT is a four-dimensional unitary.
For p=1/2 and M=1000, the frequency standard deviation is about 1.58 percentage points. Observing 515/485 does not contradict a 50/50 model.
Global phase disappears after taking the squared magnitude. But (|0⟩+|1⟩)/√2 and (|0⟩−|1⟩)/√2 have zero fidelity although both yield 50/50.
For a single marked state, uniform preparation and k ideal iterations. It explains the peak and over-rotation in lessons 20–21.
Each group should formulate a testable hypothesis before pressing Run. The goal is experimental intuition, not memorized gate names.
Add Deutsch, two-qubit Grover, then three qubits with one and two iterations. Each group reports queries, gate count and success probability separately.
Learning lab opens a non-modal window with four tabs. Beginner view in the main window hides numerical details and advanced tabs; turn it off to explore further. Both views share the same simulated state.
Choose activities 1, 2 and 3 (lessons 01, 02 and 04). Before applying gates, choose a distribution: always state 0, always state 1, all outcomes equally likely, or I do not know yet. For multiple qubits the displayed bits refer to the whole register. Write a reason and press Record prediction. After the final gate the program compares it with theory, independently of one random draw. Restarting or editing invalidates the recorded prediction.
Load H/H-Z, H-H/H-Z-H, or Grover with 1/2 or 2/3 iterations; alternatively copy the current circuit to A and B. Copies are independent. Step A and Step B reconstruct unitary circuit prefixes, without intermediate measurements. Gate strings appear above the table; hover over long strings to read them in full. Append H to both is available for two single-qubit circuits.
Arrows show phase direction and amplitude magnitude; numerical phases are in degrees. Zero amplitude has undefined phase. A global phase does not identify a different physical state.
In the main Measurements tab choose 10, 100, 1000 or 10000 preparations. The table separates theoretical probability, count and observed frequency. The notebook records the trial count. A finite series need not split exactly 50/50. Challenges use the stated minimum gate constraints: longer equivalent solutions are accepted unless they use forbidden gates. Feedback detects matching probabilities with different relative phase.
File → Undo circuit edit (Ctrl+Z) and Redo circuit edit (Ctrl+Y) handle insertion, replacement, deletion, movement and qubit count. History retains up to 100 edits, resets on document/session changes, and is distinct from circuit step navigation. An edit invalidates previous circuit measurements and predictions.
Worksheet and session holds the question, reasoning, observations and conclusion. Save session (Ctrl+Alt+S) writes a .session.json containing circuit, lesson, step, measurement, counts, prediction and A/B copies. The random generator is preserved for resuming in the same runtime environment; identical sequences across different C++ libraries are not promised. Window preferences remain separate in QSettings.
Saves are atomic. Loading validates data before replacing the active work. Limits: 1 MiB per session and 32768 characters per text field. Unsaved session changes require Save/Discard/Cancel before closing or replacing the document. Saving only the circuit does not save notes. The .qlab.json circuit format remains compatible.
Export HTML worksheet creates a standalone browser-printable document with question, prediction, reasoning, notes, conclusion, gates, amplitudes, probabilities and frequencies. Its embedded circuit JSON allows reconstruction. Use the session to resume the complete activity. Results JSON export now uses version 2 and includes the circuit and pre-measurement amplitudes.
The fourth tab compares Bell+ with a 50/50 ensemble of 00 and 11. Z/Z probabilities agree; in X/X Bell+ gives 00 and 11 at 50%, while the mixture gives four outcomes at 25%. Bases are ordered q1/q0. Switching to X uses H before readout. The mixture adds branch probabilities, never branch amplitudes. This distinguishes two known preparations, is not a universal entanglement certificate, and does not model noise.
DemonstrationQubits: 1
The question: Start in |0⟩ and apply H(q0). Predict 0 or 1 before measuring.
Try it in the program: Select H, inspect the amplitudes, then run 1000 independent shots without collapsing the displayed state.
Expected observation: P(0)=P(1)=50%. With 1000 shots the counts are close, not necessarily equal.
Why it works: H does not hide an ordinary classical coin: it prepares +1/√2 amplitudes, each with probability 1/2.
Watch out: Do not confuse a single measurement with the full distribution.
DemonstrationQubits: 1
The question: Apply H twice. Does uncertainty double or disappear?
Try it in the program: Pause after the first and second H; inspect amplitudes, not only measurement.
Expected observation: The final state is |0⟩ with 100% probability.
Why it works: H·H=I: the second mixing interferes constructively for |0⟩ and destructively for |1⟩.
Watch out: "More gates" does not necessarily mean "more randomness".
DemonstrationQubits: 2
The question: From |00⟩ produce perfectly matching outcomes, 00 and 11.
Try it in the program: Apply H(q0), then CNOT with control q0 and target q1.
Expected observation: 00 and 11 each have 50%; 01 and 10 never occur.
Why it works: The state (|00⟩+|11⟩)/√2 is entangled and cannot be factored into two single-qubit states.
Watch out: The 00/11 histogram alone does not certify entanglement; measurements in other bases are needed.
DemonstrationQubits: 1
The question: Can a phase change a later outcome while leaving intermediate probabilities unchanged?
Try it in the program: Compare H–H with H–Z–H, inspecting the table just after Z.
Expected observation: After Z it is still 50/50; after the final H, |1⟩ is certain.
Why it works: Z introduces a relative phase of π: the second H converts phase difference into probability.
Watch out: Phase is not negative probability.
ChallengeQubits: 1
The question: Build |1⟩ from |0⟩ using at least one X gate.
Try it in the program: In the Editor tab select X on q0 and insert it into the empty circuit.
Expected observation: The checker should return PASS: amplitude 1 on |1⟩.
Why it works: X acts like a NOT on computational basis states.
Watch out: H produces a superposition, not a certain |1⟩.
ChallengeQubits: 1
The question: Return to |0⟩ using exactly two X gates.
Try it in the program: Insert X(q0), then a second X(q0).
Expected observation: The checker accepts X–X because X²=I.
Why it works: Unitary quantum transformations are reversible.
Watch out: An empty circuit has the same state but does NOT meet the two-X learning constraint.
ChallengeQubits: 1
The question: Prepare (|0⟩+|1⟩)/√2 using at least one H.
Try it in the program: Insert H(q0); compare amplitudes and probabilities.
Expected observation: The amplitudes are both +1/√2; probabilities are 50/50.
Why it works: The distribution alone does not define the state: relative sign matters.
Watch out: Do not confuse this with challenge 13, which requires a different phase.
ChallengeQubits: 2
The question: Start from |00⟩ and prepare exactly |01⟩.
Try it in the program: The rightmost bit is q0: apply X(q0).
Expected observation: P(01)=100% and all others are zero.
Why it works: QuantumLab uses q0 as the least significant bit in the binary index.
Watch out: X(q1) would prepare |10⟩, not |01⟩.
ChallengeQubits: 2
The question: Produce four equal, positive amplitudes.
Try it in the program: Apply H(q0) and H(q1). The order of these two H gates does not matter.
Expected observation: All four amplitudes are +1/2; each outcome has probability 25%.
Why it works: Two qubits have 2²=4 basis states, but one measurement returns just one state.
Watch out: Four amplitudes do not mean four simultaneously readable answers.
ChallengeQubits: 2
The question: Prepare (|00⟩+|11⟩)/√2.
Try it in the program: Insert H(q0), then CNOT(q0→q1).
Expected observation: The checker accepts a coherent superposition of 00 and 11.
Why it works: CNOT can create entanglement if the control is in superposition.
Watch out: A classical 50/50 mixture of 00 and 11 would have the same histogram in this basis.
ChallengeQubits: 1
The question: Reach |1⟩ without X, using at least two H and one Z.
Try it in the program: Try H(q0)–Z(q0)–H(q0).
Expected observation: The checker accepts H–Z–H and also checks the gate constraint.
Why it works: HZH=X: the same action can be implemented very differently.
Watch out: A single X gives the final state but violates the challenge objective.
ChallengeQubits: 2
The question: Prepare (|01⟩+|10⟩)/√2.
Try it in the program: Start with a standard Bell state, then apply X(q0).
Expected observation: Nonzero amplitudes belong to 01 and 10, both +1/√2.
Why it works: A local gate can transform one Bell state into another.
Watch out: Correct probabilities alone are not enough: relative phase must match.
ChallengeQubits: 1
The question: Prepare (|0⟩−|1⟩)/√2 with negative relative sign.
Try it in the program: Use H(q0) followed by Z(q0).
Expected observation: The checker accepts H–Z but rejects H alone, although both show 50/50.
Why it works: State fidelity detects the relative phase difference.
Watch out: Global phase is not observable; relative phase is.
ChallengeQubits: 3
The question: Prepare GHZ=(|000⟩+|111⟩)/√2.
Try it in the program: Apply H(q0), CNOT(q0→q1), CNOT(q1→q2).
Expected observation: Only 000 and 111 have 50% probability, with correct phases.
Why it works: GHZ extends coherent entanglement from two to three qubits.
Watch out: Three classical correlations alone do not certify entanglement.
AlgorithmQubits: 2
The question: Is the function constant or balanced? Here f(0)=f(1)=1.
Try it in the program: Inspect ancilla preparation, the oracle X(q1), and the final H on q0.
Expected observation: The data qubit q0 measures 0 with certainty; q1 does not encode the answer.
Why it works: One query to the reversible oracle identifies the function class.
Watch out: One logical query is not necessarily one physical gate.
AlgorithmQubits: 2
The question: Repeat Deutsch with f(x)=x.
Try it in the program: The oracle is CNOT(q0→q1): observe how information reaches the phase.
Expected observation: q0=1 with certainty; the function is balanced.
Why it works: Preparing the ancilla in |−⟩ enables phase kickback.
Watch out: Do not read q1 to classify the function.
AlgorithmQubits: 2
The question: Same question, now f(x)=1−x. Does the classification change?
Try it in the program: Compare the oracle gate sequence with lesson 16.
Expected observation: q0 is still 1: this function is also balanced.
Why it works: The output captures a property of the function, not its full truth table.
Watch out: Do not infer that the circuit recovered f(0) and f(1) separately.
AlgorithmQubits: 4
The question: An oracle hides s=101: recover it with one logical call.
Try it in the program: Data qubits are q2,q1,q0; q3 is an ancilla in |−⟩. Inspect the oracle CNOT gates.
Expected observation: The data bits are q2q1q0=101 with 100% probability; q3 may be 0 or 1.
Why it works: Interference extracts the s·x mod 2 parity encoded in phase.
Watch out: Do not expect one unique four-qubit result: the ancilla remains random.
AlgorithmQubits: 2
The question: Find |10⟩ among four candidates.
Try it in the program: Inspect uniform preparation, phase marking and diffusion.
Expected observation: After one complete iteration P(10)=100% in the ideal case.
Why it works: Diffusion amplifies the marked answer amplitude through interference.
Watch out: Marking alone changes sign, not probability.
AlgorithmQubits: 3
The question: Search for |101⟩ among eight possibilities using one iteration.
Try it in the program: Visit checkpoints: preparation, oracle, diffusion.
Expected observation: P(101) rises from the initial 12.5% to 78.125% after diffusion.
Why it works: High probability is not certainty yet.
Watch out: One ideal query does not guarantee a correct answer on each measurement.
AlgorithmQubits: 3
The question: Repeat oracle+diffusion for the same target |101⟩.
Try it in the program: Compare checkpoints, then use the parametric lab with three iterations.
Expected observation: After two iterations P(101)=94.53125%; after three it falls to about 33.01%.
Why it works: Grover rotates amplitudes: continuing past the optimum causes over-rotation.
Watch out: More iterations do not always mean a higher success probability.
Now pick an algorithm, change one parameter, and predict the difference before reading the output. If a measurement surprises you, inspect the Notebook and reconstruct the checkpoints.
QuantumLab · Officina Turini · v0.16.0 · EN · UTF-8 · offline