|q⟩ Bad Qubits

beginner · Programming · Single-Qubit Gates I: X, Y, Z

Checkpoint: Build a Target State with Paulis

You have now seen all three Pauli gates: X flips the qubit, Z reflects the phase of 1|1\rangle, and Y does both at once. This checkpoint asks you to chain several of them in sequence and reason about the result before you run the simulator.

Quick reference

Acting on computational basis states:

X0=1,X1=0,X|0\rangle = |1\rangle, \quad X|1\rangle = |0\rangle, Y0=i1,Y1=i0,Y|0\rangle = i|1\rangle, \quad Y|1\rangle = -i|0\rangle, Z0=0,Z1=1.Z|0\rangle = |0\rangle, \quad Z|1\rangle = -|1\rangle.

Because quantum gates are linear, knowing these four values is enough to predict the action of any Pauli on any state.

Composing gates

When you apply gates one after the other, the final state is determined by their product acting on the initial state. For the three-gate sequence YXYY \to X \to Y starting from 0|0\rangle:

Step 1. Y0=i1Y|0\rangle = i|1\rangle.

Step 2. X(i1)=iX1=i0X(i|1\rangle) = i \cdot X|1\rangle = i|0\rangle.

Step 3. Y(i0)=iY0=ii1=1Y(i|0\rangle) = i \cdot Y|0\rangle = i \cdot i|1\rangle = -|1\rangle.

The overall result is 1-|1\rangle. Because 1=eiπ-1 = e^{i\pi} is a global phase factor, 1-|1\rangle is physically identical to 1|1\rangle: no measurement can tell them apart. The statevector grader treats these as equal.

You can also verify the composition algebraically. The matrix product is

YXY=(0ii0)(0110)(0ii0)=(0110)=X,Y X Y = \begin{pmatrix}0 & -i\\i & 0\end{pmatrix} \begin{pmatrix}0 & 1\\1 & 0\end{pmatrix} \begin{pmatrix}0 & -i\\i & 0\end{pmatrix} = -\begin{pmatrix}0 & 1\\1 & 0\end{pmatrix} = -X,

so the three-gate sequence implements X-X — the flip gate up to global phase.

Try it

Implement the gate sequence Y,X,YY, X, Y on qubit 0, verify that the resulting state is 1|1\rangle (up to global phase), then press Check.

Run your code to see the quantum state.

After running, the amplitude on 1|1\rangle should have magnitude 11 and the Bloch vector should point at the south pole — the signature of 1|1\rangle.

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