Pauli X, Y, and Z gates perform fixed operations on a qubit, much like NOT gates in classical logic. The Hadamard gate allows us to enter a state of superposition. However, building useful quantum algorithms requires more than just flipping bits or creating 50/50 superpositions. Often, precise angle adjustments are needed to modify the quantum state.
This brings us to phase gates and rotation operators. These operations allow you to manipulate the complex phase of a qubit without necessarily changing the probability of measuring a or . Understanding these rotations is essential for algorithms like the Quantum Fourier Transform and Quantum Phase Estimation.
In the previous section, we defined the state as:
If you measure this state, you have a 50% probability of observing 0 and a 50% probability of observing 1. Now consider the state :
Measurement statistics for are identical to . Both yield 0 or 1 with equal probability. The difference lies in the relative phase, the sign between the two basis vectors. While this difference does not show up in a standard measurement immediately, it fundamentally changes how the qubit interferes with other states in a circuit. Phase gates are the tools we use to alter this relative phase.
The Pauli Z gate rotates a qubit by radians () around the Z-axis of the Bloch sphere. This operation flips the phase of the component. We often need finer control than a full flip.
The S gate (sometimes called the Phase gate) performs a rotation of () around the Z-axis. Mathematically, it applies a complex factor of to the component.
If we apply the S gate twice, we get .
The T gate (sometimes called the gate) performs a rotation of () around the Z-axis. It is the square root of the S gate.
These gates allow us to navigate the equator of the Bloch sphere. The following diagram illustrates the relationship between these phase operations starting from the state.
Diagram showing the cumulative effect of Phase gates. The T gate is a finer rotation than S, and S is a finer rotation than Z.
While S and T gates offer fixed increments, quantum hardware allows for continuous rotations. We describe these using rotation operators denoted as , , and . These operators take a parameter representing the angle of rotation in radians.
This flexibility is useful when encoding data into a quantum system, such as normalizing pixel values from an image into angles.
The gate is the generalized version of the Z, S, and T gates. It changes the phase without affecting the probabilities of the basis states.
Note that some textbooks define this slightly differently regarding the global phase factor, but the relative phase difference between and remains .
Unlike Z-rotations, rotating around the Y-axis changes the relative amplitudes of and . This means an rotation changes the probability of measurement outcomes. This is frequently used for initializing qubits to a specific probability distribution.
We can verify these rotations using Python's NumPy library. In this example, we will manually construct the unitary matrices for the S gate and a generic rotation. We will apply them to a qubit and observe how the state vector evolves.
This approach reinforces the linear algebra foundation established in Chapter 2.
import numpy as np
# 1. Define the Basis States
ket_0 = np.array([[1], [0]])
ket_1 = np.array([[0], [1]])
# Create the |+> state (Superposition)
# We use this to demonstrate the S-gate, which requires a superposition to have a visible effect
ket_plus = (1/np.sqrt(2)) * (ket_0 + ket_1)
print(f"Initial State (|+>):\n{ket_plus}")
# 2. Define the S Gate Matrix
# 1j is the Python notation for the imaginary unit 'i'
s_gate = np.array([
[1, 0],
[0, 1j]
])
# Apply S gate to |+>
state_after_s = np.dot(s_gate, ket_plus)
print(f"\nState after S-gate:\n{state_after_s}")
# Notice the second element is now imaginary (0.707j)
# 3. Define an Ry Rotation Matrix for 90 degrees (pi/2)
theta = np.pi / 2
ry_gate = np.array([
[np.cos(theta/2), -np.sin(theta/2)],
[np.sin(theta/2), np.cos(theta/2)]
])
# Apply Ry to the standard |0> state
# Rotating |0> by 90 degrees around Y creates the |+> state
state_after_rotation = np.dot(ry_gate, ket_0)
print(f"\nState after Ry(pi/2) on |0>:\n{state_after_rotation}")
Understanding phase requires visualizing the third dimension of the Bloch sphere. When we use the Hadamard gate, we move from the poles (Z-axis) to the equator (X-axis). Once on the equator, phase gates (, S, T) rotate the vector around the equator.
If you visualize the qubit state as a clock hand lying flat on a table:
Crucially, as long as the hand lies flat on the table (the equator), the "height" is zero. This corresponds to a 50/50 probability. The rotation only changes the direction (phase), not the height (probability bias).
The chart below plots the path of a qubit state vector during a rotation.
Probability amplitudes and as a function of rotation angle during an rotation. At (approx 1.57 radians), the amplitudes intersect, representing a perfect superposition.
Mastering these rotations provides the control needed to navigate the entire Hilbert space. In the next section, we will discuss how these continuous states collapse back into binary outcomes through the measurement postulate.
Was this section helpful?
© 2026 ApX Machine LearningEngineered with