liveBook · Manning

Hadamard gate

As explained in Building Quantum Software with Python

The Hadamard gate is a single-qubit quantum gate that transforms computational-basis states into equal-weight superpositions with relative phase differences.

The Hadamard, or H, gate remixes a single qubit’s two amplitudes. For state [a, b], it produces [(a + b)/√2, (a − b)/√2]. Think of it as computing scaled sum and difference channels rather than merely flipping a bit. The √2 scaling preserves the total probability represented by the pair. section 3.2.2

Figure 3.19 The general form of the effect of the H gate on a pair of amplitudes
figure

The amplitude-pair diagram makes the H gate’s sum-and-difference recombination visible. section 3.2.2

Starting from the default single-qubit state, H gives both outcomes equal amplitude magnitude and therefore equal probability: a uniform two-outcome distribution. A simulator can apply it directly with transform(state, h), then inspect amplitudes or sample outcome frequencies. section 3.4.1 section 3.2.2

Prepare a uniform three-qubit state

Apply H once to every qubit of a default three-qubit register. Each gate recombines amplitude pairs that differ at its target position; after all three gates, all eight outcomes have equal real amplitudes and equal probability. q = QuantumRegister(3) qc = QuantumCircuit(q) for i in range(len(q)): qc.h(q[i]) state = qc.run() section 4.3.4 section 4.5.3

H is also an interface between phase and measurement-visible magnitudes. After phase encoding, another H can translate a phase difference into amplitudes with magnitudes cos(θ/2) and sin(θ/2), allowing sampled outcome frequencies to reveal the encoded angle. section 7.2

This role recurs in quantum Fourier transform workflows: Hadamards help recover binary digits from phase shifts in an inverse QFT, and prepare equal-magnitude amplitudes before phase gates encode a geometric sequence. section 7.4.1 section 8.2

How Building Quantum Software with Python covers it

How deep it goes
Derives the scaled sum-and-difference amplitude rule, visualizes pair recombination, and implements single- and multi-qubit circuits.
Examples
Demonstrates fair-coin sampling, an eight-outcome uniform state, phase encoding of 273.5, and recovery of binary 1101.
What it assumes
Builds from single-qubit amplitudes and probability interpretation before extending the gate to registers and circuits.
What you can do after
Apply it via a simulator circuit to create uniform states and expose phase-encoded angles through outcome probabilities.
How it connects
Connects amplitude pairs, uniform distributions, phase gates, quantum Fourier transform, inverse QFT, and geometric sequence states.

Also explained in

Compare how 2 books explain Hadamard gate →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Quantum Software with Python. The section links point to the parts of the book it draws on.