The Pauli-Z gate

Pauli-Z is the phase flip. It leaves ∣0⟩|{0}\rangle alone and puts a minus sign on ∣1⟩|{1}\rangle. It never changes the odds of measuring 0 or 1, yet it changes the state: it turns ∣+⟩|{+}\rangle into ∣−⟩|{-}\rangle.

On the Bloch sphere, Z turns the whole sphere 180° about z.

A Bloch sphere: Z turns the arrow 180° about z, from where it starts (dashed) along the arc to where it ends.|0⟩|1⟩|+⟩|−⟩|+i⟩|−i⟩
Z turns ∣+⟩|{+}\rangle half a turn about the vertical axis, around the equator to ∣−⟩|{-}\rangle.

The matrix

Z=[100−1]Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}

Z keeps the amplitude of ∣0⟩|{0}\rangle and flips the sign of the amplitude of ∣1⟩|{1}\rangle:

Z (α∣0⟩+β∣1⟩)=α∣0⟩−β∣1⟩Z\,(\alpha|0\rangle + \beta|1\rangle) = \alpha|0\rangle - \beta|1\rangle

The sizes stay the same, so the probabilities do too. Only the relative phase changes, by 180°.

As a rotation

Z=i Rz(180∘)Z = i\,R_z(180^\circ)

The factor ii in front is a global phase: it changes the matrix but not what any measurement sees, so Z and Rz(180∘)R_z(180^\circ) turn the sphere the same way. See rotation gates.

What it does to the six key states

BeforeAfter ZOn the sphere
∣0⟩|{0}\rangle∣0⟩|{0}\ranglestays put
∣1⟩|{1}\rangle−∣1⟩-|{1}\ranglestays put
∣+⟩|{+}\rangle∣−⟩|{-}\rangle+x → −x
∣−⟩|{-}\rangle∣+⟩|{+}\rangle−x → +x
∣+i⟩|{+i}\rangle∣−i⟩|{-i}\rangle+y → −y
∣−i⟩|{-i}\rangle∣+i⟩|{+i}\rangle−y → +y

A factor in front of a result, such as a minus sign or ii, is a global phase: the arrow lands on the named state all the same.

Nothing moves at the poles

∣0⟩|{0}\rangle and ∣1⟩|{1}\rangle lie on the z axis, so Z leaves them in place. Z∣1⟩=−∣1⟩Z|1\rangle = -|1\rangle is the same point as ∣1⟩|{1}\rangle: the minus sign is a global phase. Apply Z to ∣0⟩|{0}\rangle in the app and nothing moves; the Gate panel points out that the qubit is on the rotation axis.

A change you can't measure directly

Because Z keeps the height of the arrow, measuring right after Z gives the same odds as before. To see what Z did, turn the sphere so the phase becomes a height: a Hadamard gate does that. Sandwiched between two Hadamards, Z becomes a bit flip:

H Z H=XH\,Z\,H = X

That's the idea behind many quantum algorithms: work on phases, where gates can make amplitudes add up or cancel, then turn the phases into something a measurement can see.

Try it

See also: S and T · Hadamard · All gates