k›ketwise.
FUNDAMENTALS / 10 / GATES

The Z gate: change phase

Use Z to change relative phase and reveal it with interference.

Intuition

Z leaves the |0⟩ amplitude alone and changes the sign of the |1⟩ amplitude. It changes |+⟩ into |−⟩ without changing their computational-basis probabilities.

Try H then Z, and inspect Statevector. Add another H: the final result is |1⟩. Compare that with H then H, which produces |0⟩. The last H turns a phase difference into a probability difference. Remove it before completing the |−⟩ challenge.

The mathematics

Z=[100−1],Z∣+⟩=∣−⟩,HZH∣0⟩=∣1⟩Z=\begin{bmatrix}1&0\\0&-1\end{bmatrix},\quad Z|+\rangle=|-\rangle,\quad HZH|0\rangle=|1\rangle
Look a little deeper

Z on |1⟩ produces −|1⟩, which differs only by global phase and represents the same physical state. On |+⟩ it changes only one of two nonzero amplitudes, creating an observable relative-phase difference.

Use it

Prepare |−⟩ using H then Z. Verify the negative amplitude rather than relying only on a histogram.

This exercise uses the same server-side state and circuit checks as its linked practice problem.

Build your circuit

Click a gate to append it, or drag it onto a wire. CX uses the selected control; SWAP uses it as the second operand. Basis order: |qₙ … q₀⟩.

q0

Returned logical circuit · before transpilation · q0 on top

0 / 32 gates · terminal measurement of all qubits

Connect to code

qc.h(0)
qc.z(0)

These operations go inside a circuit-building program. Practice problems provide a complete solve() template.

Solve the linked Qiskit problem →

Check your understanding

Does Z turn |1⟩ into |0⟩?

First complete the circuit exercise successfully.