|q⟩ Bad Qubits

beginner · Programming · Controlled Gates: CNOT, CZ, SWAP

Controlled Phase Gates

The controlled-phase gate CP(λ)CP(\lambda) is a two-qubit gate that leaves every basis state unchanged except 11|11\rangle, which it multiplies by the complex number eiλe^{i\lambda}:

CP(λ)00=00,CP(λ)01=01,CP(λ)10=10,CP(λ)11=eiλ11.CP(\lambda)\,|00\rangle = |00\rangle, \quad CP(\lambda)\,|01\rangle = |01\rangle, \quad CP(\lambda)\,|10\rangle = |10\rangle, \quad CP(\lambda)\,|11\rangle = e^{i\lambda}|11\rangle.

In matrix form (rows and columns ordered 00,01,10,11|00\rangle, |01\rangle, |10\rangle, |11\rangle):

CP(λ)=(100001000010000eiλ).CP(\lambda) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\lambda} \end{pmatrix}.

You can verify it is unitary: the four columns are orthonormal and the determinant has magnitude 1.

Why only 11|11\rangle acquires a phase

The gate is controlled: it acts on the target only when the control is 1|1\rangle. The single-qubit P(λ)P(\lambda) gate adds a phase eiλe^{i\lambda} to 1|1\rangle and leaves 0|0\rangle alone. CP(λ)CP(\lambda) makes that action conditional on the control being 1|1\rangle, so the phase appears exactly on 11|11\rangle — the only basis state where both qubits are 1|1\rangle.

Common special cases

Three frequently used controlled-phase angles have their own shorthand names:

| Angle λ\lambda | Gate name | eiλe^{i\lambda} | |---|---|---| | π/4\pi/4 | CTCT (controlled-TT) | eiπ/4e^{i\pi/4} | | π/2\pi/2 | CSCS (controlled-SS) | ii | | π\pi | CZCZ (controlled-ZZ) | 1-1 |

For example, CZCZ is a special case of CP(π)CP(\pi) and is symmetric: it does not matter which qubit you call "control" and which you call "target," because 11|11\rangle is the only state it changes.

Try it

Apply a controlled-phase of π/2\pi/2 with qubit 0 as the control and qubit 1 as the target. The grader checks the full two-qubit unitary matrix, so doing nothing will not pass.

Run your code to see the quantum state.

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