# Z gate **Z gate** (or **Pauli-Z gate**, or **phase flip gate**) is a single-qubit gate that applies a phase flip to the $\lvert 1\rangle$ state while leaving $\lvert 0\rangle$ unchanged. It is the third [[pauli-gates|Pauli gate]] and a special case of the [[p-gate|phase gate]] with $\phi = \pi$. $$Z = \begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix}$$ The gate leaves the computational basis states $\lvert 0\rangle$ and $\lvert 1\rangle$ as eigenstates, and swaps the Hadamard basis states: $$Z\lvert 0\rangle = \lvert 0\rangle \qquad Z\lvert 1\rangle = -\lvert 1\rangle$$ $$Z\lvert +\rangle = \lvert -\rangle \qquad Z\lvert -\rangle = \lvert +\rangle$$ The phase flip does not change measurement outcomes in the computational basis — $|-1|^2 = 1$ — but it changes interference patterns, making it observable in rotated bases. On the [[bloch-sphere|Bloch sphere]], $Z$ corresponds to a $\pi$ rotation about the $z$-axis. The $S$ and $T$ gates are the square root and fourth root of $Z$ respectively: $S^2 = Z$ and $T^2 = S$. ## List of code implementations - [[z-gate-qiskit|Z gate (Qiskit)]] - [[z-gate-custatevec|Z gate (cuStateVec)]] - [[z-gate-cudaq|Z gate (CUDA-Q)]]