# Phase gate **Phase gate** (or **P gate**) is a single-qubit gate that applies a phase shift $\phi$ to the $\lvert 1\rvert$ component of a qubit while leaving the $\lvert 0\rangle$ component unchanged. It is a rotation about the $z$-axis of the [[bloch-sphere|Bloch sphere]]. $$P(\phi) = \begin{pmatrix}1 & 0\\ 0 & e^{i\phi}\end{pmatrix}$$ Applied to a general qubit $\lvert\psi\rangle = a\lvert 0\rangle + b\lvert 1\rangle$, the phase gate multiplies the $\lvert 1\rangle$ amplitude by $e^{i\phi}$: $$P(\phi)\lvert\psi\rangle = a\lvert 0\rangle + e^{i\phi}b\lvert 1\rangle$$ Since only the relative phase between $\lvert 0\rangle$ and $\lvert 1\rangle$ changes, the measurement probabilities $|a|^2$ and $|b|^2$ are unaffected. The phase shift is only observable through interference. ## Special cases Several important single-qubit gates are special cases of $P(\phi)$: $$Z = P(\pi) \qquad S = P\!\left(\tfrac{\pi}{2}\right) \qquad T = P\!\left(\tfrac{\pi}{4}\right)$$ $$Z = \begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix} \qquad S = \begin{pmatrix}1 & 0\\ 0 & i\end{pmatrix} \qquad T = \begin{pmatrix}1 & 0\\ 0 & e^{i\pi/4}\end{pmatrix}$$ The $T$ gate is particularly important in fault-tolerant quantum computing. Together with the [[h-gate|Hadamard gate]] and the [[cx-gate|CX gate]], $T$ forms a universal gate set: any quantum computation can be approximated to arbitrary precision using only $\{H, T, \text{CX}\}$. ## List of code implementations - [[p-gate-qiskit|Phase gate (Qiskit)]] - [[p-gate-custatevec|Phase gate (cuStateVec)]] - [[p-gate-cudaq|Phase gate (CUDA-Q)]]