H gate

The Hadamard gate: matrix, effect on |0⟩ and |1⟩, the h() call in Python and JS, and what it becomes on IonQ hardware.

The H gate, the Hadamard, turns ∣0⟩\vert 0 \rangle into an equal superposition of ∣0⟩\vert 0 \rangle and ∣1⟩\vert 1 \rangle, and turns ∣1⟩\vert 1 \rangle into the same superposition with the sign of ∣1⟩\vert 1 \rangle flipped. It acts on one qubit and takes no parameters. The Circuit panel draws it as H. Measured straight after it, a qubit that started as 0 reads 0 or 1 with equal probability.

Kets such as ∣0⟩\vert 0 \rangle name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.

Call

WhereCall
Pythonqc.h(qubit)
JScircuit.h(qubit)
Qiskit classHGate

Matrix

H=12(111−1)H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}

On the Bloch sphere this is a half-turn about the axis midway between X and Z, which exchanges the X and Z axes.

Effect on basis states

InputOutput
∣0⟩\vert 0 \rangle12(∣0⟩+∣1⟩)\tfrac{1}{\sqrt{2}}(\vert 0 \rangle + \vert 1 \rangle), written ∣+⟩\vert + \rangle
∣1⟩\vert 1 \rangle12(∣0⟩−∣1⟩)\tfrac{1}{\sqrt{2}}(\vert 0 \rangle - \vert 1 \rangle), written ∣−⟩\vert - \rangle
∣+⟩\vert + \rangle∣0⟩\vert 0 \rangle
∣−⟩\vert - \rangle∣1⟩\vert 1 \rangle

Measured straight after H, a qubit that started in ∣0⟩\vert 0 \rangle or ∣1⟩\vert 1 \rangle reads 0 or 1 with equal probability. The sign difference between ∣+⟩\vert + \rangle and ∣−⟩\vert - \rangle does not show in a measurement; it decides how later gates interfere.

Inverse

H is its own inverse: HH=IHH = I. Two H gates in a row on the same qubit cancel.

Usage

from qiskit import QuantumCircuit

qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)
import { QuantumCircuit } from 'qiskit';

const circuit = QuantumCircuit(1, 1);
circuit.h(0);
circuit.measure(0, 0);

Over many shots the counts split close to evenly between 0 and 1.

On IonQ hardware

H is not a native gate. Up to a global phase it is a Y rotation by π/2 applied after a Z rotation by π, so one GPi2 pulse is enough, with the Z rotation carried as a virtual Z that costs no physical gate. What runs after IonQ's optimiser can still differ, because the compiler rewrites the whole circuit rather than one gate at a time. See How your circuit is compiled.

Stay in the loop.

Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.