The CNOT and CZ gates both entangle two qubits, but they act in different bases. Understanding
the relationship between them deepens your intuition for how gate sets can substitute for one
another — a key skill in compiling quantum programs.
CZ versus CNOT
The CZ (controlled-Z) gate applies a Z gate to the target qubit only when the control qubit
is ∣1⟩. In the two-qubit computational basis {∣00⟩,∣01⟩,∣10⟩,∣11⟩}
its matrix is diagonal:
CZ=100001000010000−1.
The only affected state is ∣11⟩, which acquires a phase of −1.
The CNOT (controlled-X) gate flips the target qubit when the control is ∣1⟩:
CNOT=1000010000010010.
Connecting them with Hadamards
The Hadamard gate exchanges the Z-basis eigenstates and the X-basis eigenstates:
H∣0⟩=∣+⟩ and H∣1⟩=∣−⟩. Because X=HZH, applying H to the
target of a CZ converts the controlled-Z action into a controlled-X action. In full:
CNOT=(I⊗H)CZ(I⊗H).
To verify this, trace what happens to each basis state. Take ∣10⟩ as an example:
H on qubit 1: ∣10⟩→∣1⟩⊗H∣0⟩=∣1⟩∣+⟩=21(∣10⟩+∣11⟩).
CZ: the ∣11⟩ component picks up −1, giving 21(∣10⟩−∣11⟩)=∣1⟩∣−⟩.
H on qubit 1: ∣1⟩⊗H∣−⟩=∣1⟩∣1⟩=∣11⟩.
So ∣10⟩→∣11⟩, which is exactly what CNOT does to this state. You can check
∣00⟩→∣00⟩, ∣01⟩→∣01⟩, and ∣11⟩→∣10⟩ in the
same way to confirm the full identity.
Try it
Build the CNOT gate for qubit 0 (control) and qubit 1 (target) using only h and cz. The
grader checks the complete 4×4 unitary matrix, so an empty circuit will not pass.
Run your code to see the quantum state.
Sign in on the full site to ask questions and join the discussion.