Quantum Gates: A Beginner's Guide to Quantum Circuits
Quantum gates are the elementary operations performed on qubits, the quantum equivalent of the logic gates that act on ordinary bits. A classical gate takes bits in and puts bits out, flipping or combining them according to fixed rules. A quantum gate does the same job in a much larger space: it transforms the state of one or more qubits while they remain in a quantum superposition, so it can act on many possible inputs at once.
Why they look the way they do
A qubit is not simply a zero or a one. Its state is described by a pair of amplitudes, which together fix the probabilities of measuring zero or one and also carry a relative phase. Gates manipulate those amplitudes. Mathematically, each gate is a unitary transformation, meaning it preserves the total probability and can always be undone by another gate. Reversibility is therefore not a quirk of some gates but a property of all of them: every quantum gate has an inverse gate that restores the previous state exactly. Classical logic works differently. A gate such as AND discards information, since many different inputs give the same output, and it cannot be run backwards. This is not a problem in practice, because classical circuits are built from reversible pieces by keeping the inputs around and writing the answer to a spare bit. On the quantum side, no such trick is available for copying an unknown state, so the reversibility of the gates themselves carries the whole burden.
Measurement is the exception. Reading a qubit collapses its state to a definite outcome and cannot be reversed, which is why measurement is usually drawn separately from the gates in a circuit diagram.
Read more
The gates worth learning first
The single-qubit gates form the alphabet. The Pauli gates are the simplest: X flips a qubit the way a NOT gate does, Z leaves the measurement probabilities untouched but shifts the phase, and Y does both. The Hadamard gate is the workhorse of nearly every quantum algorithm, since it turns a definite state into an even superposition of zero and one. Phase gates such as S and T rotate the phase by smaller and smaller fractions of a full turn, and general rotation gates let you dial in an arbitrary angle. Together these gates can approximate any single-qubit operation to whatever precision you need.
Two-qubit gates create the correlations that make quantum computing distinctive. The controlled-NOT, or CNOT, flips a target qubit only when a control qubit is one. Applied to a superposition, it produces entanglement, a joint state that cannot be described by describing the parts separately. The controlled-Z and the SWAP gate do related jobs. Larger constructions such as the Toffoli gate, which flips its target only when both of its control qubits are one and leaves it alone otherwise, show how more complex logic is built by composing simple pieces.
Practical advice for beginners
Start by drawing circuits rather than by chasing algebra. A circuit is read left to right, with each qubit on its own horizontal line and each gate a box or symbol on that line.
Learn to predict a gate's effect on the basis states first, then on superpositions. Most confusion comes from forgetting that a gate acts on the whole state at once, not on a single branch of it.
Remember that real hardware is noisy. Gates are never perfect, and qubits lose their state over time, which is why error correction matters so much in the field.
Finally, keep the global picture in view: any quantum algorithm is just a carefully chosen sequence of these few operations, followed by a measurement at the end.