|q⟩ Bad Qubits

intermediate · Physics · Hilbert Spaces & Dirac Formalism

Representing States in a Basis

A vector is an abstract object, but to compute with it we pick a basis and write down its components. This lesson makes the bridge between the coordinate-free ket ψ|\psi\rangle and the column of numbers we actually manipulate.

Components are basis-dependent

Fix an orthonormal basis {ek}\{|e_k\rangle\}. Any state expands as

ψ=kckek,ck=ekψ.|\psi\rangle = \sum_k c_k |e_k\rangle, \qquad c_k = \langle e_k | \psi \rangle.

The numbers ckc_k are the components (or coordinates) of ψ|\psi\rangle in that basis. The vector itself does not change when you choose a different basis — only its list of components does. This is the same idea as describing the same arrow by different (x,y)(x, y) pairs after rotating your axes.

The column-vector representation

Collecting the components into a column gives the familiar matrix representation. For a qubit in the computational basis,

ψ=c00+c11    (c0c1),ψ    (c0c1).|\psi\rangle = c_0 |0\rangle + c_1 |1\rangle \;\longleftrightarrow\; \begin{pmatrix} c_0 \\ c_1 \end{pmatrix}, \qquad \langle\psi| \;\longleftrightarrow\; \begin{pmatrix} \overline{c_0} & \overline{c_1} \end{pmatrix}.

Inner products then become ordinary matrix multiplication of a row by a column, and operators become matrices. Choosing a basis is what makes Dirac notation computable.

Changing basis

Suppose we also have a second orthonormal basis {fk}\{|f_k\rangle\}. The components in the new basis are again given by inner products, ck=fkψc'_k = \langle f_k | \psi \rangle. Inserting the completeness relation of the old basis,

ck=fkψ=jfkejejψ=jUkjcj,c'_k = \langle f_k | \psi \rangle = \sum_j \langle f_k | e_j \rangle \langle e_j | \psi \rangle = \sum_j U_{kj}\, c_j,

where Ukj=fkejU_{kj} = \langle f_k | e_j \rangle are the entries of a unitary change-of-basis matrix. The state is fixed; the unitary just rewrites its coordinates. The Hadamard gate, for instance, is exactly the unitary that converts between the computational {0,1}\{|0\rangle, |1\rangle\} basis and the {+,}\{|+\rangle, |-\rangle\} basis.

Real-amplitude states and the RYRY rotation

A useful family of single-qubit states has real, non-negative amplitudes:

ψ(θ)=cos ⁣θ20+sin ⁣θ21.|\psi(\theta)\rangle = \cos\!\frac{\theta}{2}\,|0\rangle + \sin\!\frac{\theta}{2}\,|1\rangle.

These are produced from 0|0\rangle by the rotation gate RY(θ)RY(\theta), whose matrix is

RY(θ)=(cosθ2sinθ2sinθ2cosθ2),RY(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix},

so that RY(θ)0=ψ(θ)RY(\theta)|0\rangle = |\psi(\theta)\rangle. The components depend on the single angle θ\theta, and normalization cos2+sin2=1\cos^2 + \sin^2 = 1 holds automatically.

Worked example

To represent

ψ=120+321|\psi\rangle = \tfrac{1}{2}|0\rangle + \tfrac{\sqrt{3}}{2}|1\rangle

we need cos(θ/2)=1/2\cos(\theta/2) = 1/2, i.e. θ/2=π/3\theta/2 = \pi/3, so θ=2π/3\theta = 2\pi/3. Then sin(θ/2)=sin(π/3)=3/2\sin(\theta/2) = \sin(\pi/3) = \sqrt{3}/2, matching the 1|1\rangle component. The probabilities are c02=1/4|c_0|^2 = 1/4 and c12=3/4|c_1|^2 = 3/4, summing to 1.

Try it

Prepare the state ψ=120+321|\psi\rangle = \tfrac{1}{2}|0\rangle + \tfrac{\sqrt{3}}{2}|1\rangle on one qubit using an RYRY rotation, and return the circuit. The grader checks the full statevector.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.