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
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₀⟩.
Returned logical circuit · before transpilation · q0 on top
Connect to code
qc.h(0) qc.z(0)
These operations go inside a circuit-building program. Practice problems provide a complete solve() template.
Check your understanding
First complete the circuit exercise successfully.