VQE Suite / Physics
State Representations & Measurement
The same statevector that the Convergence tab optimizes also drives the Statevector table, the QSphere, and the Measure button — this page derives what each of those views actually shows.
From θ to amplitudes and probabilities
The ansatz statevector, derived on the Hamiltonian & Ansatz page by tracing the circuit gate-by-gate, is
using this site's basis-index convention (basis index , see src/lib/physics/statevector.ts) — the same convention the Statevector table's BASIS_LABELS and the QSphere's point layout both use. Both amplitudes are always real for this ansatz, so the Statevector table's Phase column only ever reads 0° or 180°, and the QSphere colors points by the sign of the real amplitude (cyan positive, violet negative) rather than a general complex phase.
Measurement probabilities are the squared amplitudes — exactly what probabilitiesOf() in src/lib/physics/measurement.ts computes:
At the VQE-converged : , — the near-certainty of the |01⟩ outcome you see reflected in both the Statevector table and the QSphere's point sizes (point radius , so area encodes probability).
The reduced state of qubit 0, and why it's mixed
reducedDensityMatrixQubit0() partial-traces qubit 1 out of the full 2-qubit state: . For this ansatz only the and amplitudes are nonzero, so every off-diagonal cross-term vanishes and the sum collapses to a diagonal matrix:
purity() then computes , which for a diagonal matrix is just the sum of the squared diagonal entries:
At (the untrained ansatz, exactly ) this gives exactly — qubit 0 is a pure, unentangled product state. At it drops to : the converged ground state is genuinely, if only slightly, entangled across the two qubits — a real property of the H2 ground state this ansatz reaches, not an artifact of the visualization.
Measurement is a real single sample, not an animation
Clicking Measure ▸ on the Statevector tab calls sampleMeasurement(), which draws one Math.random() value and walks the cumulative distribution of until it exceeds the draw (inverse-CDF sampling) — a genuine single projective measurement, not a scripted collapse effect. Run repeatedly, the outcome frequencies converge to the probabilities above; a 20,000-sample check against this exact implementation matched the true probabilities to within statistical error (max deviation ≈0.00074, consistent with the expected sampling noise).
See it running live on the VQE Suite playground — the Statevector, QSphere, and Step-by-Step tabs all read from the same runH2AnsatzStatevector(theta) call.
Source: src/lib/physics/statevector.ts, entanglement.ts, measurement.ts, vqe.ts