1. Home
  2. Quantum Computing
  3. Quantum Logic Gates: Hadamard, CNOT and Pauli Explained
Quantum Computing

Quantum Logic Gates: Hadamard, CNOT and Pauli Explained

Published on November 15, 2026 · by Qubira 8 min read
Quantum Logic Gates: Hadamard, CNOT and Pauli Explained

Three gates do most of the work in the quantum programs you’ll meet as a beginner. Hadamard puts a qubit into superposition, CNOT ties two qubits together, and the Pauli gates (X, Y and Z) flip a qubit in different ways. Learn what those do and you can read most introductory circuits, including the famous Bell state we build in our first Qiskit circuit. The rest of this guide explains each gate in plain terms, and why they behave so differently from the logic gates in your laptop.

3 ideas
The short versionX flips 0 and 1. Z flips the sign (the phase) of the 1 part. H turns a definite 0 or 1 into an even mix. CNOT flips a second qubit only if the first is 1, which is how qubits get entangled.

How is a quantum gate different from a normal logic gate?

A classical gate such as AND or OR is a lookup table on bits. Two bits go in, one comes out, and information gets discarded along the way. A quantum gate is closer to a rotation. It takes the state of a qubit and turns it, smoothly and reversibly, into another state. That’s why every quantum gate has an exact inverse, and why you can’t build an AND gate directly out of qubits without extra qubits to hold the “lost” information.

If you’ve read what a qubit is, you know a qubit isn’t just 0 or 1 but a blend of both, described by two numbers called amplitudes. A single-qubit gate changes those amplitudes. Nothing random happens inside a gate; randomness only enters at the end, when you measure. This is the point most explanations skip, and it’s worth holding on to: a circuit is a deterministic recipe for setting up probabilities, and measurement is the one step that rolls the dice.

Picture the qubit as an arrow pointing from the centre of a ball to its surface. The north pole is 0 and the south pole is 1; everything in between is a superposition. Gates move the arrow around the ball. That picture, called the Bloch sphere, is a bit of a simplification once several qubits are entangled, but for one qubit it’s the best mental model we know.

The Pauli gates: X, Y and Z

The three Pauli gates are the simplest. Each one is a half-turn of the ball around one axis.

X is the quantum NOT gate. It sends 0 to 1 and 1 to 0, so if your qubit is a definite 0, X makes it a definite 1. On a superposition it swaps the two amplitudes. If you only remember one thing about X, it’s that it’s the “bit flip” and nothing mysterious happens.

Z is the strange one, because it does nothing visible to a definite 0 and, to a definite 1, only changes its sign (from +1 to -1). A sign sounds like it can’t matter, since measuring a plain 1 gives the same result either way. But in a superposition that sign is the difference between two states that look identical when measured and behave completely differently when you push them through another gate. This hidden property is called phase, and phase is the raw material of quantum interference. Much of the speed-up in algorithms like those in our guide to Shor’s and Grover’s algorithms comes from arranging phases so wrong answers cancel and right ones add up.

Y combines both: a bit flip and a phase flip at once (with a factor of i, the square root of -1, which keeps the bookkeeping consistent). You’ll see it less often in beginner circuits. Its main job is to complete the set, so that X, Y and Z cover half-turns around all three axes.

What does the Hadamard gate do?

Hadamard, written H, is the gate that opens the door to everything else. Give it a definite 0 and it returns an even blend of 0 and 1, so that measuring gives either result with 50% probability. Give it a definite 1 and it returns the same even blend, but with the opposite sign on the 1 part. That sign is invisible to measurement, yet it’s exactly why H is reversible: apply H a second time and the two blends cancel back into the original state. Run H twice on a fresh qubit and you’ll measure 0 every time, which is a tiny, satisfying piece of interference.

Because of this, H is the usual first gate in a circuit. Start every qubit in 0, apply H to each, and you have an even superposition of all possible bit strings at once. That’s the starting point for most algorithms. It’s also where the famous “quantum computers try every answer at the same time” slogan comes from, and where it goes wrong. The qubits are in superposition, but measurement returns only one result, and the algorithm has to use phase and interference to make the answer you want likely. We unpack this properly in quantum superposition explained simply.

One handy identity ties the gates together: sandwiching X between two Hadamards gives Z. In words, H swaps the roles of “bit flip” and “phase flip”. That’s useful when you read a circuit and wonder why somebody wrapped a gate in Hs.

What does CNOT do, and why does it matter so much?

Everything above acts on one qubit. CNOT (controlled-NOT) acts on two: a control and a target. If the control is 0, the target is left alone. If the control is 1, the target gets an X. On definite values it behaves exactly like a classical XOR, which is why it can look underwhelming on first meeting.

The magic arrives when the control is in superposition. Take the Bell-state recipe: H on the first qubit, then CNOT with that qubit as control. The control is now “both”, so the target ends up both flipped and not flipped, but correlated with the control. The two qubits no longer have separate states; there’s only a joint state in which they always agree. That’s entanglement, and CNOT is the gate that creates it. Without a two-qubit gate like this, a quantum computer would be a pile of independent qubits, and a classical machine could simulate it easily.

A reference table you can screenshot

GateQubitsWhat it doesThink of it asUndo it with
X1Swaps 0 and 1Bit flip (quantum NOT)X again
Z1Changes the sign of the 1 partPhase flipZ again
Y1Bit flip plus phase flipHalf-turn around the third axisY again
H1Definite value to even blend, and backEntry door to superpositionH again
CNOT2Flips target if control is 1Conditional bit flip, creator of entanglementCNOT again

Every gate in this table is its own undo, which is a handy property to check when a circuit gives odd results.

See them in code

If you’d like to poke at the gates, Qiskit makes each one a single line. Install qiskit and qiskit-aer, then try this on a laptop simulator:

from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator

qc = QuantumCircuit(1)
qc.h(0)      # superposition
qc.h(0)      # undo it
qc.measure_all()

sim = AerSimulator()
counts = sim.run(transpile(qc, sim), shots=1000).result().get_counts()
print(counts)   # expect every shot to read '0'

If Hadamard behaved like a coin flip, you’d see an even split. Instead the second H undoes the first and the counts come back all zeros. Delete the second qc.h(0) and you’ll get roughly half and half. Library interfaces change between versions, so if something fails after an update, check the current Qiskit docs. Our Qiskit walkthrough covers setup and the usual import errors, and you can run real hardware for free by following how to try a quantum computer free.

Difficulty of the idea (X, Z, Y)
Easy
Difficulty of the idea (Hadamard)
Medium
Difficulty of the idea (CNOT)
Takes a while
How often you'll meet it in tutorials
Constantly

Our own qualitative reading, not measured data.

When should you not bother with gate-level thinking?

If your goal is to understand what quantum computing can do for the world, you don’t need gates. The big picture in quantum computing explained and what it’s good for today works without a single circuit diagram. Gates start to pay off when you want to run something, follow a tutorial, or judge a headline about “gate fidelity”. And if you want to go deeper than a blog post, a good book beats a dozen articles; we’ve collected the ones we’d pick in our quantum computing books review.

Also note that the gates above are the textbook set. On real chips, errors on each gate (and especially the two-qubit ones) are the main thing holding machines back, which is the topic of quantum error correction. Don’t expect a hardware vendor’s native gates to match this list one-to-one; the compiler handles the translation.

If you take one thing from this, make it this: H opens a superposition, CNOT links qubits, and X and Z give you the two basic ways to nudge a state. Learn those four and the first dozen tutorials you open will suddenly read like sentences instead of hieroglyphs.

FAQ

Why can't a quantum gate just erase information like an AND gate does?
Quantum gates are reversible: every gate has an exact undo. An ordinary AND gate takes two bits in and gives one out, so you can't tell from the output what went in. Quantum evolution can't throw information away like that, which is why multi-qubit gates such as CNOT keep as many outputs as inputs.
How many gates do you need to build any quantum program?
A surprisingly small set. The Hadamard, a phase gate called T and CNOT are enough to approximate any quantum operation as closely as you like. Real programs just use many of them, which is why gate count and error rates matter so much on today's noisy hardware.
Is the Hadamard gate the same as a coin flip?
Not quite. A coin flip is random and can't be undone. Hadamard is fully deterministic and reversible: apply it twice and you're back where you started. The randomness only appears when you measure.
What's the difference between a bit flip and a phase flip?
A bit flip (the X gate) swaps the roles of 0 and 1. A phase flip (the Z gate) leaves 0 and 1 alone but changes the sign of the 1 part of a superposition. You can't see a phase flip by measuring right away, but it changes how later gates interfere with each other.
Do real quantum computers use these exact gates?
They use whatever gates their hardware does natively, and those differ between machines. Software such as Qiskit's transpiler rewrites your H and CNOT into the native set, so you can think in the standard gates and let the compiler translate.