State. n = 4 qubits are described by 24 = 16 complex amplitudes ax, with P(x) = |ax|² (Born rule). Every gate is a unitary matrix acting on the vector: H = (1/√2)[[1,1],[1,−1]], X (NOT), Y, Z (phase flip), S = diag(1,i), T = diag(1,eiπ/4), and CNOT flips the target when the control is |1> (here the target is the qubit below the control, wrapping around).
Entanglement. For each qubit the reduced density matrix ρ has eigenvalues λ± = (1 ± √((p0−p1)² + 4|ρ01|²))/2 and the entropy S = −∑ λ log2 λ. S = 0 means the qubit is in a pure state of its own; S = 1 bit means it is maximally entangled with the rest (Bell pair, GHZ).
Shots. A real machine only gives samples. With N shots each frequency has binomial scatter √(p(1−p)/N); the χ²/dof readout should hover near 1 for an ideal device.
Honest simplifications. Ideal noiseless gates and instant measurement; no decoherence, crosstalk or connectivity limits; only 4 qubits — the classical state-vector memory doubles with every extra qubit, which is why this method cannot scale to 50+ qubits. Checks: unitarity, a hand-derived Bell state, H·H = I and T8 = I computed with separate arithmetic.