Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 39 ยท Gates and Circuits

Rotation Gates and Phase

Learn the continuous rotation gates Rx, Ry, Rz and the phase gate, the half-angle convention, the ZYZ decomposition of any single-qubit gate, and how to code them in NumPy.

The gates X, Z, S and T are fixed rotations of the Bloch sphere by 180, 90 and 45 degrees. Real hardware, and many algorithms, need rotations by any angle. This lesson introduces the continuous families Rx(theta), Ry(theta), Rz(theta) and the phase gate P(phi), explains the odd-looking half angles, and shows that every single-qubit gate can be assembled from three rotations.

Rotation gates

A rotation by angle theta about the x axis is

Rx(theta) = cos(theta/2) I - i sin(theta/2) X

and likewise for Ry and Rz with Y and Z. Written out:

  • Rx(theta) = [[cos(t/2), -i sin(t/2)], [-i sin(t/2), cos(t/2)]]
  • Ry(theta) = [[cos(t/2), -sin(t/2)], [sin(t/2), cos(t/2)]]
  • Rz(theta) = [[e^(-i t/2), 0], [0, e^(i t/2)]]

They are unitary for every real theta. Special cases tie back to familiar gates: Rx(pi) is X up to a global phase (it equals -iX), Ry(pi) is Y up to phase, and Rz(pi) is Z up to phase.

Why half angles?

On the Bloch sphere Rx(theta) really rotates by theta. The matrix contains theta/2 because states are vectors in a two-dimensional space, and the map from rotations to matrices doubles back: rotating by a full 360 degrees gives -I, which multiplies the state by -1. That sign is a global phase, so physically a 360-degree rotation does return the state, but the matrix needs a 720-degree turn to equal I exactly. Half angles encode this bookkeeping.

Python Rotation gates and their special cases

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Ry(theta) starting from |0> gives cos(theta/2)|0> + sin(theta/2)|1>, a state with real amplitudes whose probability of 1 is sin^2(theta/2). This is the standard way to prepare a qubit with a chosen probability. For example, theta = pi/2 gives |+>.

Rz versus the phase gate P

Rz(theta) is symmetric: it adds phase -theta/2 to |0> and +theta/2 to |1>. The phase gate puts all of the phase on |1>:

P(phi) = [[1, 0], [0, e^(i*phi)]]

The two differ only by a global phase: P(phi) = e^(i*phi/2) Rz(phi). That distinction is irrelevant for a lone qubit, but it becomes real once the gate is controlled by another qubit, because the global phase turns into a relative phase for the control. The earlier gates fit in the family: Z = P(pi), S = P(pi/2), T = P(pi/4).

Python Phase gate versus Rz

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Any single-qubit gate from three rotations

Every one-qubit unitary can be written as a product of three rotations about two axes, together with a global phase:

U = e^(i*alpha) Rz(beta) Ry(gamma) Rz(delta)

This is the ZYZ decomposition. It is why hardware only needs to implement a few rotations: a compiler can turn any single-qubit gate into this form. The recipe for a matrix U = [[a, b], [c, d]]:

  • gamma = 2 * atan2(|c|, |a|)
  • beta = arg(c) - arg(a)
  • delta = arg(d) - arg(c)
  • alpha is whatever global phase remains

The recipe breaks down when a or c is zero (the angles are then ambiguous), so production code handles those cases separately. The example below skips them and checks the result by rebuilding the matrix.

Python ZYZ decomposition of the Hadamard gate

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The result for H is a quarter turn about y sandwiched between half turns about z, matching the geometric picture: H swaps the z and x axes.

Axis-angle and the U gate

Many toolkits offer a general one-qubit gate with three angles, often called U(theta, phi, lambda), equal to Rz(phi) Ry(theta) Rz(lambda) up to global phase. When you read such a gate in a circuit, think "an arbitrary point on the sphere, then an arbitrary twist".

If a circuit looks long and full of angles, many neighboring rotations about the same axis can be merged: Rz(a) Rz(b) = Rz(a + b). Compilers do this automatically.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Ry(theta) acts on |0>. What is the probability of measuring 1?

    Ry(theta)|0> = cos(theta/2)|0> + sin(theta/2)|1>, so P(1) = sin^2(theta/2).
  2. 2. Why do rotation matrices use theta/2?

    The matrix of a rotation by theta contains theta/2; a full 2*pi turn yields -I, which multiplies the state by -1 (a global phase).
  3. 3. How does P(phi) relate to Rz(phi)?

    P(phi) = e^(i*phi/2) Rz(phi).
  4. 4. The ZYZ decomposition shows that:

    Three rotations (two about z and one about y) plus a global phase reach every single-qubit unitary.

Summary

  • Rx, Ry, Rz rotate the Bloch sphere by any angle; matrices use half angles.
  • Ry(theta)|0> prepares a state with P(1) = sin^2(theta/2).
  • P(phi) and Rz(phi) differ by global phase, which matters when controlled.
  • Any single-qubit gate is e^(i*alpha) Rz Ry Rz (ZYZ decomposition).
  • Rotations about the same axis merge by adding angles.

Next: Controlled Gates