The Hadamard gate, H, makes equal superpositions. It turns ∣0⟩ into ∣+⟩ and ∣1⟩ into ∣−⟩, and back again. Most quantum algorithms start with it, and it's the gate that switches between the z and x bases.
On the Bloch sphere, H turns the whole sphere 180° about the x+z diagonal.
H turns ∣0⟩ half a turn about the diagonal halfway between x and z, landing on ∣+⟩.
The matrix
H=212121−21
Column 0 is ∣+⟩ and column 1 is ∣−⟩. On any state, H adds and subtracts the amplitudes:
H(α∣0⟩+β∣1⟩)=2α+β∣0⟩+2α−β∣1⟩
As a rotation
H=iRn^(180∘),n^=21(1,0,1)
The factor i in front is a global phase: it changes the matrix but not what any measurement sees, so H and Rn^(180∘) turn the sphere the same way. See rotation gates.
What it does to the six key states
Before
After H
On the sphere
∣0⟩
∣+⟩
+z → +x
∣1⟩
∣−⟩
−z → −x
∣+⟩
∣0⟩
+x → +z
∣−⟩
∣1⟩
−x → −z
∣+i⟩
eiπ/4∣−i⟩
+y → −y
∣−i⟩
e−iπ/4∣+i⟩
−y → +y
A factor in front of a result, such as a minus sign or i, is a global phase: the arrow lands on the named state all the same.
Switching bases
A half turn about the x–z diagonal swaps the x and z axes, and flips y. So H swaps ∣0⟩ with ∣+⟩ and ∣1⟩ with ∣−⟩, and swaps ∣+i⟩ with ∣−i⟩. That makes it a translator between the z basis and the x basis:
HZH=X,HXH=Z
Putting a gate between two Hadamards turns its axis: Z's axis, turned by H, becomes X's. It's also how hardware that only measures along z can measure along x: apply H first.