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 into an equal superposition of and , and turns into the same superposition with the sign of 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 name the basis states and rotations are described on the Bloch sphere; the qubits lesson introduces both.
Call
| Where | Call |
|---|---|
| Python | qc.h(qubit) |
| JS | circuit.h(qubit) |
| Qiskit class | HGate |
Matrix
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
| Input | Output |
|---|---|
| , written | |
| , written | |
Measured straight after H, a qubit that started in or reads 0 or 1 with equal probability. The sign difference between and does not show in a measurement; it decides how later gates interfere.
Inverse
H is its own inverse: . 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.
Related
Stay in the loop.
Get the latest tutorials, demos, and project showcases straight to your inbox. No noise, just the good stuff.
Gates