# Hadamard gate **Hadamard gate** (or **H gate**) is a single-qubit gate that maps the computational basis states $\lvert 0\rangle$ and $\lvert 1\rangle$ to equal superpositions. It is the most commonly used gate for creating superposition and appears at the start of most quantum algorithms. $$H = \frac{1}{\sqrt{2}}\begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix}$$ The gate maps the computational basis to the Hadamard basis and back: $$H\lvert 0\rangle = \frac{\lvert 0\rangle + \lvert 1\rangle}{\sqrt{2}} = \lvert +\rangle \qquad H\lvert 1\rangle = \frac{\lvert 0\rangle - \lvert 1\rangle}{\sqrt{2}} = \lvert -\rangle$$ The Hadamard gate is its own inverse: $H^2 = I$, so $H = H^\dagger = H^{-1}$. On the [[bloch-sphere|Bloch sphere]], $H$ is a $\pi$ rotation about the axis halfway between $x$ and $z$, which swaps the $z$-axis with the $x$-axis. ## Creating superposition over $n$ qubits Applying $H$ to each of $n$ qubits initialized to $\lvert 0\rangle$ creates an equal superposition over all $2^n$ computational basis states: $$H^{\otimes n}\lvert 0\rangle^{\otimes n} = \frac{1}{\sqrt{2^n}}\sum_{x=0}^{2^n - 1}\lvert x\rangle$$ This is the standard initialization step for Deutsch's algorithm, the Deutsch-Jozsa algorithm, [[grover|Grover's algorithm]], and the [[qft|quantum Fourier transform]]. ## List of code implementations - [[h-gate-qiskit|Hadamard gate (Qiskit)]] - [[h-gate-custatevec|Hadamard gate (cuStateVec)]] - [[h-gate-cudaq|Hadamard gate (CUDA-Q)]]