Home

2-Qubit Quantum Circuit Simulator

Build and test simple quantum algorithms interactively. See how superposition and entanglement instantly affect complex amplitudes and measurement probabilities. See the Application User Guide.

Gate Palette

H
X
H
X
C
T

Quantum Circuit

|q₀⟩
|q₁⟩

Results (State Vector & Measurement)

About This Interactive Quantum Circuit Simulator

This is a lightweight, client-side 2-qubit quantum circuit simulator, built to help users understand the fundamental principles of quantum computing. Unlike classical bits, which are strictly 0 or 1, the qubits simulated here can exist in a superposition of both states simultaneously. This interactive tool demonstrates how applying quantum gates modifies the system's state vector, which is composed of complex amplitudes rather than simple binary values. Observing these changing amplitudes is key to grasping quantum mechanics.

The core of the simulation relies on simple JavaScript to perform the necessary linear algebra—specifically, matrix multiplication of unitary matrices (the gates) against the 4-dimensional state vector. The final measurement probabilities for the basis states $|00\rangle, |01\rangle, |10\rangle,$ and $|11\rangle$ are calculated from the squared magnitude of these complex amplitudes, providing a clear visual link between the theoretical quantum state and the observable classical outcome.

Application User Guide and Sample Scenarios

Operating this interactive simulation is straightforward. Simply drag a gate from the Gate Palette onto an empty slot in the Quantum Circuit. You can remove an existing gate by dragging it off the track.

  1. Hadamard (H) Gate: The H gate is crucial for creating superposition. Drag an 'H' onto the $|q_0\rangle$ track in the first moment. The initial state $|00\rangle$ is transformed into a state where both $|00\rangle$ and $|10\rangle$ have a 50% probability (amplitude $\approx 0.707$).
  2. Pauli-X (X) Gate: This is the quantum equivalent of a classical NOT gate. Drag an 'X' onto $|q_1\rangle$. If the initial state is $|00\rangle$, it transforms to $|01\rangle$ (100% probability for the $|01\rangle$ state).
  3. Creating Quantum Entanglement (Bell State): This is the most famous two-qubit scenario.
    • Step 1: Apply an Hadamard gate (H) to the first qubit ($|q_0\rangle$).
    • Step 2: In the next moment, drag the Control (C) component onto $|q_0\rangle$ and the Target (T) component onto $|q_1\rangle$. This forms a CNOT gate.
    The resulting state is the Bell state $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$, where the two qubits are perfectly correlated. You will see 50% probability for $|00\rangle$ and 50% for $|11\rangle$, and 0% for the other two. This perfectly demonstrates quantum entanglement.

Experiment with different sequences of Hadamard gate, Pauli-X gate, and CNOT gate to explore complex quantum mechanics concepts through hands-on interactive simulation.