Pricing…Open Lab
Gates & entanglement · after Measurement · ~8 min

Single-qubit gates

Single-qubit gates are fixed, reversible steps that change one qubit's amplitudes. X swaps the 0 and 1 amplitudes. Z flips the sign of the 1 amplitude. H opens and closes superpositions. S, T, RX, RY and RZ set phases and angles more finely. Z is a fixed half turn of phase, and RZ is the same turn with an angle you pick.

What are the gates, one by one?

A single-qubit gate is a step that changes one qubit's two amplitudes. (An amplitude is a number that says how strongly the qubit leans toward 0 or toward 1.) The step is reversible, which means it can always be undone. Nothing is measured and nothing is random. Each gate is a fixed 2×2 grid of numbers called a matrix. Applying the gate multiplies the qubit's amplitudes by that grid. Run the same gate on the same state and you get the same result every time, like pressing the same button on a calculator.

Here are the gates you will use most:

  • X swaps the amplitudes of |0⟩ and |1⟩. It is the quantum NOT, like flipping a light switch.
  • Z flips the sign of the |1⟩ amplitude. The odds depend only on the size of each amplitude, not its sign. So if you measure right away, Z does nothing you can see. It only matters once interference is involved.
  • H sends |0⟩ to (|0⟩+|1⟩)/√2 and |1⟩ to (|0⟩−|1⟩)/√2. It is the gate that opens and closes superpositions.
  • S and T are smaller phase steps. S multiplies the |1⟩ amplitude by i, which is a quarter turn of phase. T is half of that, an eighth of a turn. So T·T = S and S·S = Z.
  • RX, RY, RZ turn the qubit by any angle you choose, measured in radians. (A full circle is about 6.28 radians.)
Every shot reads 1. X always does the same thing, with no chance involved.standby
12q0|0⟩X
press run to acquire
|0⟩|1⟩
——
counts: sampledamplitudes: statevector, exactengine: in-browser

Why do gate sequences cancel or combine?

Gates combine by multiplying their matrices. Many combinations shrink into something simpler. Two H gates in a row cancel exactly: H·H = I, where I means "do nothing." So H then H on |0⟩ reads 0 on every shot. The first H opens the superposition and the second closes it. The two paths to |1⟩ cancel out.

Here is a more useful rule: H·Z·H = X. On its own, Z does nothing you can measure on |0⟩. Put it between two H gates and it becomes a bit flip. Think of a secret ink that only shows up under a special light. Z writes in the secret ink, and the H gates are the light. This is the pattern to remember: H turns phase differences into bit differences you can measure. Every algorithm based on interference uses it.

You can check these rules yourself. In the next circuit, swap the Z for S, S. Or swap it for T, T, T, T. The result is the same, because S·S = Z and four T gates make a Z.

Always 1. The Z you couldn't see directly became an X you can.standby
1234q0|0⟩HZH
press run to acquire
|0⟩|1⟩
——
counts: sampledamplitudes: statevector, exactengine: in-browser

What does RZ do that Z doesn't?

Z turns the phase by a fixed half turn, which is π radians. RZ(θ) turns it by any angle θ. RZ(π) and Z differ only by a global phase, which is one shared factor on the whole state. No measurement can ever detect a global phase. So as circuit steps, RZ(π) and Z do the same job. What RZ adds is every angle in between. It gives you smooth, fine control of phase.

You can see the angle using the same H sandwich. The circuit H, RZ(θ), H leaves the qubit with a chance of sin²(θ/2) of reading 1. The phase angle turns into a chance you can measure. It works like a volume knob, not an on/off button. That knob is what algorithms with adjustable settings actually turn.

Let's work an example with θ = π/2. Half of that is π/4. The sine of π/4 is about 0.707. Square it: 0.707 × 0.707 ≈ 0.5. So about half the shots should read 1.

θ = π/2, so sin²(π/4) = 0.5. Expect about half the shots to read 1.standby
1234q0|0⟩HRZH
press run to acquire
|0⟩|1⟩
——
counts: sampledamplitudes: statevector, exactengine: in-browser

What do these gates look like on a real QPU?

Real devices don't build every gate on this list directly. Each machine has a small set of native gates, the ones its hardware actually performs. A typical superconducting chip offers only a few, often just SX, X, RZ and one two-qubit gate. A program called a compiler rewrites everything you write into those. Your H becomes an RZ–SX–RZ sequence. Your T becomes an RZ. It is like a recipe that says "cream the butter" being rewritten for a cook who only knows "stir" and "wait."

RZ has one more trick. On most superconducting hardware it is virtual. The control system just updates the phase of later control pulses in its notes. It takes no time and adds almost no error. The real pulses (SX, X and the two-qubit gates) are where time and error come from. That is why cost on real hardware is counted in native gates, not in the gates you typed. See what each device runs natively on the QPU index.

Primary sources & further reading