QuantumCore
← QuantumCore

Circuit Lab

Build a circuit on up to 12 qubits and watch the statevector update after every edit. Qubit q0q_0 is the top wire and the most significant bit, so the basis ket ∣q0q1⋯qn−1⟩\lvert q_0 q_1 \cdots q_{n-1}\rangle has index k=∑jqj 2 n−1−jk=\sum_{j} q_j\,2^{\,n-1-j}. The simulator applies each column's gates to ∣0⋯0⟩\lvert 0\cdots0\rangle:

∣ψ⟩=UL⋯U2U1∣0⋯0⟩,P(k)=∣⟨k∣ψ⟩∣2.\lvert\psi\rangle = U_L\cdots U_2U_1\lvert 0\cdots 0\rangle,\qquad P(k)=\lvert\langle k\vert\psi\rangle\rvert^2 .

The starting circuit prepares the Bell state. With H∣0⟩=12(∣0⟩+∣1⟩)H\lvert0\rangle=\tfrac{1}{\sqrt2}(\lvert0\rangle+\lvert1\rangle) and CNOT∣a,b⟩=∣a, a⊕b⟩\mathrm{CNOT}\lvert a,b\rangle=\lvert a,\,a\oplus b\rangle:

CNOT (H⊗I)∣00⟩=CNOT 12(∣00⟩+∣10⟩)=12(∣00⟩+∣11⟩)=∣Φ+⟩.\mathrm{CNOT}\,(H\otimes I)\lvert00\rangle=\mathrm{CNOT}\,\tfrac{1}{\sqrt2}\big(\lvert00\rangle+\lvert10\rangle\big)=\tfrac{1}{\sqrt2}\big(\lvert00\rangle+\lvert11\rangle\big)=\lvert\Phi^+\rangle .

For the qubit chosen in the results pane you see its reduced state ρq=Tr⁡qˉ∣ψ⟩⟨ψ∣=12 (I+xX+yY+zZ)\rho_q=\operatorname{Tr}_{\bar q}\lvert\psi\rangle\langle\psi\rvert=\tfrac12\,(I+xX+yY+zZ) and its Bloch vector r⃗=(x,y,z)\vec r=(x,y,z). For ∣Φ+⟩\lvert\Phi^+\rangle both reduced states are 12I\tfrac12 I, so r⃗=0\vec r=0 and the purity Tr⁡ρq2=12(1+∥r⃗∥2)=12\operatorname{Tr}\rho_q^2=\tfrac12(1+\lVert\vec r\rVert^2)=\tfrac12: each qubit alone is maximally mixed because the pair is maximally entangled.

Activate a gate in the palette and then a cell (or drag the gate onto the grid). Multi-qubit gates take one click per wire: the control(s) first, then the target. Rotation angles accept expressions such as pi/2 or acos(1/3).

The noise row adds single-qubit Kraus channels E(ρ)=∑jKj ρ Kj†\mathcal{E}(\rho)=\sum_j K_j\,\rho\,K_j^\dagger with ∑jKj†Kj=I\sum_j K_j^\dagger K_j=I: amplitude damping (AD, γ\gamma), phase damping (PD, λ\lambda), depolarizing (DEP, pp), bit flip (BF), phase flip (PF) and thermal relaxation (TR, T1T_1, T2≤2T1T_2\le 2T_1, tt). A noisy state is mixed and has no statevector, so a circuit with a channel runs on the exact density-matrix backend (at most 8 qubits, since ρ\rho has 4n4^n entries) and the results show ρ\rho and its purity Tr⁡ρ2=∑k,j∣ρkj∣2\operatorname{Tr}\rho^2=\sum_{k,j}\lvert\rho_{kj}\rvert^2, which equals 11 only for a pure state. The Noisy Bell pair preset applies depolarizing noise with p=0.1p=0.1 to both qubits of ∣Φ+⟩\lvert\Phi^+\rangle; each channel shrinks the Pauli components by f=1−4p3f=1-\tfrac{4p}{3}, so

ρ=14(I⊗I+f2(X⊗X−Y⊗Y+Z⊗Z)),F=⟨Φ+∣ρ∣Φ+⟩=1+3f24≈0.8133,Tr⁡ρ2=F2+3(1−f24)2≈0.6731.\rho=\tfrac14\big(I\otimes I+f^2(X\otimes X-Y\otimes Y+Z\otimes Z)\big),\qquad F=\langle\Phi^+\vert\rho\vert\Phi^+\rangle=\tfrac{1+3f^2}{4}\approx 0.8133,\qquad \operatorname{Tr}\rho^2=F^2+3\Big(\tfrac{1-f^2}{4}\Big)^2\approx 0.6731 .
Presets:

Activate a gate in the palette, then a cell to place it, or drag a gate onto the grid. Activate a placed gate to select it.

Statevector backend · 2 qubits · main thread

Measurement probabilities

Probability distribution over 4 basis states of 2 qubits. Most likely: |00⟩ 50.0%, |11⟩ 50.0%00.250.500.751|00⟩: P = 0.5000|00⟩|01⟩: P = 0.0000|01⟩|10⟩: P = 0.0000|10⟩|11⟩: P = 0.5000|11⟩
Exact P(k) = |⟨k|ψ⟩|²
Statevector amplitudes
BasisAmplitude α|α|Phase arg αProbability
|00⟩0.7071
0.7071
0
50.00%
|01⟩0
0.0000
—
0.00%
|10⟩0
0.0000
—
0.00%
|11⟩0.7071
0.7071
0
50.00%

Reduced state of

r = (0.0000, 0.0000, 0.0000), |r| = 0.0000; purity Tr ρ² = 0.5000 (mixed: q0 is entangled with the rest of the register)

Density matrix of 1 qubit, 2 × 2, showing |ρ_ij| (hue = phase)|0⟩|0⟩|1⟩|1⟩ρ[0,0] = ⟨0|ρ|0⟩ = 0.5ρ[0,1] = ⟨0|ρ|1⟩ = 0ρ[1,0] = ⟨1|ρ|0⟩ = 0ρ[1,1] = ⟨1|ρ|1⟩ = 0.5
Tr ρ = 1.0000Purity Tr ρ² = 0.5000 (maximally mixed)Colour: |ρ_ij| (hue = phase), full opacity at 1/2
3D view unavailable (WebGL is not supported in this browser). The Bloch coordinates of the state are listed in the readout.
0.000 (0)
0.000 (0)
r⃗=(0.000, 0.000, 0.000),∥r⃗∥=0.000\vec r = (0.000,\ 0.000,\ 0.000),\quad \lVert\vec r\rVert = 0.000

Bloch vector r = (0.000, 0.000, 0.000), |r| = 0.000; P(0) = 0.500, P(1) = 0.500; mixed state

Density matrix ρ = |ψ⟩⟨ψ|

Density matrix of 2 qubits, 4 × 4, showing |ρ_ij| (hue = phase)|00⟩|00⟩|01⟩|01⟩|10⟩|10⟩|11⟩|11⟩ρ[00,00] = ⟨00|ρ|00⟩ = 0.5ρ[00,01] = ⟨00|ρ|01⟩ = 0ρ[00,10] = ⟨00|ρ|10⟩ = 0ρ[00,11] = ⟨00|ρ|11⟩ = 0.5ρ[01,00] = ⟨01|ρ|00⟩ = 0ρ[01,01] = ⟨01|ρ|01⟩ = 0ρ[01,10] = ⟨01|ρ|10⟩ = 0ρ[01,11] = ⟨01|ρ|11⟩ = 0ρ[10,00] = ⟨10|ρ|00⟩ = 0ρ[10,01] = ⟨10|ρ|01⟩ = 0ρ[10,10] = ⟨10|ρ|10⟩ = 0ρ[10,11] = ⟨10|ρ|11⟩ = 0ρ[11,00] = ⟨11|ρ|00⟩ = 0.5ρ[11,01] = ⟨11|ρ|01⟩ = 0ρ[11,10] = ⟨11|ρ|10⟩ = 0ρ[11,11] = ⟨11|ρ|11⟩ = 0.5
Tr ρ = 1.0000Purity Tr ρ² = 1.0000 (pure)Colour: |ρ_ij| (hue = phase), full opacity at 1/2

Circuit IR (JSON)

{
  "version": 1,
  "numQubits": 2,
  "numClbits": 0,
  "ops": [
    {
      "kind": "gate",
      "gate": "H",
      "targets": [
        0
      ],
      "column": 0,
      "id": "ir-0"
    },
    {
      "kind": "gate",
      "gate": "CNOT",
      "targets": [
        0,
        1
      ],
      "column": 1,
      "id": "ir-1"
    }
  ]
}