|q⟩ Bad Qubits

beginner · Programming · Two Qubits & Tensor Products

Checkpoint: Two-Qubit Product States

This module introduced two-qubit states, tensor products, and independent gate application. This checkpoint asks you to synthesise those ideas: given a target product state expressed as ϕ0ϕ1|\phi_0\rangle \otimes |\phi_1\rangle, work out what single-qubit preparation each qubit needs and implement it.

Reviewing the strategy

A product state ϕ0ϕ1|\phi_0\rangle \otimes |\phi_1\rangle can always be prepared by acting on each qubit independently. The recipe is:

  1. Identify the desired state of qubit 0.
  2. Identify the desired state of qubit 1.
  3. Find a gate sequence that takes 0|0\rangle to each target, and apply those sequences to the respective qubits.

No two-qubit gates are needed because the qubits carry no correlation — a product state means the subsystems are separable.

The target state

The target for this challenge is

ψ=+,|\psi\rangle = |{-}\rangle \otimes |{+}\rangle,

where

|{+}\rangle = \frac{1}{\sqrt{2}}\bigl(|0\rangle + |1\rangle\bigr).$$ Expanding the tensor product (qubit 0 is the most significant bit): $$|{-}\rangle \otimes |{+}\rangle = \frac{1}{\sqrt{2}}\bigl(|0\rangle - |1\rangle\bigr) \otimes \frac{1}{\sqrt{2}}\bigl(|0\rangle + |1\rangle\bigr) = \frac{1}{2}\bigl(|00\rangle + |01\rangle - |10\rangle - |11\rangle\bigr).$$ All four basis states are present with equal magnitude $\tfrac{1}{2}$, but $|10\rangle$ and $|11\rangle$ carry a **minus sign** that distinguishes this state from a plain uniform superposition. <Callout type="tip"> The minus sign comes entirely from qubit 0 being in $|{-}\rangle$ rather than $|{+}\rangle$. Measurement probabilities are $|\text{amplitude}|^2$, so all four outcomes are equally likely at $25\%$. The sign only becomes observable if you later interfere this state with another — it is a **relative phase** between the two qubit-0 amplitudes. </Callout> ## Preparing $|{-}\rangle$ Starting from $|0\rangle$, the path to $|{-}\rangle$ has two steps: $$|0\rangle \xrightarrow{X} |1\rangle \xrightarrow{H} H|1\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}} = |{-}\rangle.$$ You can verify this from the Hadamard matrix: $$H|1\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\begin{pmatrix} 0 \\ 1 \end{pmatrix} = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ -1 \end{pmatrix} = \frac{|0\rangle - |1\rangle}{\sqrt{2}}.$$ ## Try it Prepare the state $|{-}\rangle \otimes |{+}\rangle$. The grader checks the full statevector, so the signs matter — applying only one gate per qubit will not pass unless you choose the right gate. <RunnableExample /> After running, inspect the amplitudes: $|00\rangle$ and $|01\rangle$ should each show $+0.500$ while $|10\rangle$ and $|11\rangle$ should show $-0.500$, confirming the product structure and the relative phase from $|{-}\rangle$.

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