Skip to content
Current section
The Quantum Computing Enthusiast’s Hub
Saved
All sections

All sections

Saved
Skip Learn navigation
Encyclopedia
Topic

Hadamard gate

A single-qubit unitary that exchanges the computational and X-eigenstate bases.

Also called H gate

Edition released Coverage: Overview · Technical
On this page

Definition and significance

The Hadamard gate maps |0> to |+>=(|0>+|1>)/sqrt(2) and |1> to |->=(|0>-|1>)/sqrt(2). Its importance is not merely that it creates equal-magnitude amplitudes. It also converts a relative phase difference into a difference in measurement outcomes. That makes it central to interference, phase kickback, Fourier sampling and many reference circuits.

The phrase “puts a qubit in both states” hides the gate's dependence on its input. A Hadamard applied to |+> produces |0>, not another balanced superposition. A balanced mixture is also different: applying H to I/2 leaves I/2.

Mechanism and mathematical treatment

In the ordered basis |0>,|1>, H=(1/sqrt(2))[[1,1],[1,-1]]. Matrix multiplication gives H^2=I and H dagger=H. The eigenvalues are +1 and -1, but its eigenvectors are not simply |+> and |->. Conjugation exchanges Pauli X and Z: HZH=X and HXH=Z. It reverses Y: HYH=-Y.

For |psi>=a|0>+b|1>, the output amplitudes are (a+b)/sqrt(2) and (a-b)/sqrt(2). Their interference terms have opposite signs. The normalization identity |a+b|^2/2+|a-b|^2/2=|a|^2+|b|^2 shows explicitly that the gate preserves total probability.

Fully worked reference example

Prepare |0>, apply H, apply Z, then apply H. The first H produces |+>; Z changes the sign of the |1> amplitude and produces |->; the last H produces |1>. The final outcome is therefore 1 with probability one. Omitting Z instead yields |0> with probability one.

For a general phase gate P(phi)=diag(1,exp(i phi)) between the two Hadamards, the final amplitudes are (1+exp(i phi))/2 and (1-exp(i phi))/2. Their squared magnitudes are cos^2(phi/2) and sin^2(phi/2). At phi=pi/2 both outcomes occur with probability 1/2; at phi=pi the second outcome is certain. This is an exact interference calculation, not a statement that a measurement reveals the phase directly.

Limitations and common misconceptions

Equal measurement frequencies alone do not prove a coherent superposition. The state |+><+| and the mixture I/2 both give equal Z-basis outcomes, but a final H distinguishes their X-basis coherence. H is a Clifford gate, so large circuits made only from Clifford operations remain in a class with efficient classical simulation under standard stabilizer assumptions.

Scientific relationships

Hadamards supply binary Fourier basis changes.

A final Hadamard can convert a relative phase into a computational outcome.

Three-bit interference with an explicit nonlinear phase

The tensor product of three Hadamards has matrix elements <y|H tensor 3|x>=(-1)^(x dot y)/sqrt(8), where the dot product is modulo two. This gives an exact finite Fourier transform on bit strings. Its useful content is the signed sum, not merely the equal magnitude of each matrix element. Let f(x0,x1,x2)=x0 x1 XOR x2. Prepare the uniform state, apply the phase (-1)^f(x), and apply three more Hadamards. The final amplitude at y is 1/8 times the sum over x of (-1)^[x0 x1+x2+x0 y0+x1 y1+x2 y2]. All exponents in this calculation are reduced modulo two.

Sum over x2 first. The factor is 1+(-1)^(1+y2), which vanishes when y2=0 and equals two when y2=1. Therefore the final bit y2 is certainly one. For the remaining two bits, evaluate the four signs from x0 x1. Their transform is 1/2 at y0y1 equal to 00, 01 and 10, and -1/2 at 11. The complete output is (|001>+|011>+|101>-|111>)/2. Its four supported outcomes have equal probability, even though one amplitude has the opposite sign.

This instance shows how a linear part of a Boolean function can be recovered deterministically while a nonlinear part distributes spectral weight. Measuring once identifies the third-bit contribution but does not reveal a unique two-bit label for the AND term. Hadamards are implementing a transform of a function's sign pattern; they are not asking every function value to appear simultaneously in a classical answer.

Parseval normalization and cancellation

For a general sign function g(x)=(-1)^f(x), define ghat(y)=2^(-n) sum_x g(x)(-1)^(x dot y). Orthogonality of characters gives sum_y (-1)^[(x XOR z) dot y]=2^n when x=z and zero otherwise. Substitute this identity into sum_y |ghat(y)|^2. The double sum over x and z collapses to 2^(-n) sum_x |g(x)|^2=1. This is a direct normalization proof for every phase-oracle output, including nonlinear functions.

The same calculation explains cancellation locally. For any fixed nonzero bit string d, half of all y have d dot y=0 and half have d dot y=1. Pair a y with y XOR e_j, where d_j=1, and the corresponding signs are opposite. A zero amplitude can therefore result from many individually nonzero path contributions. It does not imply that the intervening computational states were absent.

For a second input, take a normalized amplitude vector supported only on |000> and |101>, with equal positive amplitudes. After H tensor 3, the amplitude at y is [1+(-1)^(y0+y2)]/4. Only strings with y0=y2 survive; each surviving amplitude is 1/2. There are four such strings, so the probabilities sum to one. A minus sign between the two initial components switches the surviving condition to y0 unequal to y2. This provides a compact, fully solved way to distinguish a relative phase using a many-qubit basis change.

Classical evaluation and operation costs

A classical reference calculation need not form an eight-by-eight matrix. Start with the eight input amplitudes. At each of three stages, replace pairs (a,b) by ((a+b)/sqrt(2),(a-b)/sqrt(2)); the paired indices differ in the bit assigned to that stage. For the first stage acting on q0, the pairs are indices 0 with 4, 1 with 5, 2 with 6 and 3 with 7. Later stages use q1 and q2. This pairing order follows the leftmost-q0 convention and avoids an accidental reversal of the output labels.

For n qubits, the classical transform uses n 2^(n-1) butterflies and stores 2^n amplitudes. The quantum circuit uses n one-qubit Hadamards per layer and can apply them simultaneously if the control system permits it. These are different output tasks. The classical transform supplies every amplitude; one execution of the quantum transform supplies one sample in the chosen measurement basis. Preparing an arbitrary initial amplitude vector may itself require exponentially many elementary gates, so the compact transform circuit does not make arbitrary Fourier-data loading inexpensive.

A reference implementation should preserve complex arithmetic even though these examples happen to be real. The butterfly identity holds for complex a and b, and treating them as real would silently discard relative phases. Floating-point normalization drift can be checked by summing squared magnitudes after each stage; renormalizing without recording the discrepancy would conceal an implementation defect.

Media reference: The same preparation measured in different bases

Starting from |0>, an ideal Hadamard produces |+>=(|0>+|1>)/sqrt(2). A Z-basis measurement then gives 0 or 1 with equal probabilities, while an X-basis measurement gives the positive outcome with certainty. The minus state (|0>-|1>)/sqrt(2) has the same balanced Z distribution but a deterministic negative X outcome. Operationally, a final Hadamard followed by Z measurement distinguishes plus from minus. These statements specify complete ideal predictions; they do not require running a simulator. The distinction depends on relative phase and measurement basis, not on assigning an extra classical outcome called both.

Sources

  • A. Barenco et al. · · Research paper · Publication status unspecified · arXiv · DOI 10.1103/PhysRevA.52.3457
    Verification scope

    Selected source text checked ·

    Source anchors gate-decomposition conventions. New worked instances are independent mathematical constructions, not reported experiments.

  • Scott Aaronson; Daniel Gottesman · · Research paper · Publication status unspecified · arXiv · DOI 10.1103/PhysRevA.70.052328
    Verification scope

    Selected source text checked ·

    Simulation statements require specified stabilizer inputs, operations and measurement access.