# Phase gates **Phase gates** are single-qubit quantum gates that change the relative phase of the $\lvert 1\rangle$ component of a qubit while leaving the $\lvert 0\rangle$ component unchanged. The general phase gate is usually written as $P(\phi)$: $$P(\phi) = \begin{pmatrix}1 & 0\\0 & e^{i\phi}\end{pmatrix}$$ Applied to a qubit in the state $\lvert\psi\rangle = \alpha\lvert0\rangle + \beta\lvert1\rangle$, it produces $$P(\phi)\lvert\psi\rangle = \alpha\lvert0\rangle + e^{i\phi}\beta\lvert1\rangle$$ The phase is not directly visible when the qubit is measured in the computational basis. It becomes observable when the amplitudes interfere, for example after applying a Hadamard gate. ## Common phase gates The most commonly used phase gates are: | Gate | Matrix | Phase $\phi$ | Relationship | | --- | --- | --- | --- | | [[p-gate|P gate]] | $\begin{pmatrix}1 & 0\\0 & e^{i\phi}\end{pmatrix}$ | arbitrary | general phase gate | | [[s-gate|S gate]] | $\begin{pmatrix}1 & 0\\0 & i\end{pmatrix}$ | $\pi/2$ | $S = P(\pi/2)$ | | [[t-gate|T gate]] | $\begin{pmatrix}1 & 0\\0 & e^{i\pi/4}\end{pmatrix}$ | $\pi/4$ | $T = P(\pi/4)$ | | [[z-gate|Z gate]] | $\begin{pmatrix}1 & 0\\0 & -1\end{pmatrix}$ | $\pi$ | $Z = P(\pi)$ | The $Z$ gate is also one of the [[pauli-gates|Pauli gates]]. The $S$ gate is a square root of $Z$ ($S^2 = Z$), while $T$ is a fourth root of $Z$ ($T^4 = Z$). Naming conventions can vary between software libraries. ## Powers and inverses Because phase gates add their angles when multiplied, $$P(\phi_1)P(\phi_2) = P(\phi_1 + \phi_2)$$ Important identities include $$S^2 = Z \qquad S^4 = I$$ $$T^2 = S \qquad T^4 = Z \qquad T^8 = I$$ Their inverse gates subtract the phase: $$S^\dagger = P(-\pi/2) \qquad T^\dagger = P(-\pi/4) \qquad Z^\dagger = Z$$ ## Bloch sphere interpretation On the [[bloch-sphere|Bloch sphere]], $P(\phi)$ rotates the state around the $z$-axis by angle $\phi$, up to a physically irrelevant global phase. Therefore, $S$, $T$, and $Z$ correspond to rotations by $\pi/2$, $\pi/4$, and $\pi$, respectively. ## List of code implementations - [[p-gate-qiskit|P gate (Qiskit)]] - [[p-gate-custatevec|P gate (cuStateVec)]] - [[p-gate-cudaq|P gate (CUDA-Q)]] - [[z-gate-qiskit|Z gate (Qiskit)]] - [[z-gate-custatevec|Z gate (cuStateVec)]] - [[z-gate-cudaq|Z gate (CUDA-Q)]]