The RZ Gate is an important gates in Quantum Computing. Qiskit provides a method for applying RZ Gate on a Qubit. In this chapter of the Qiskit Tutorial, you will learn about RZ Gate and how to apply RZ Gate on a Qubit in Qiskit.
RZ Gate
The RZ Gate acts on a single Qubit. The RZ Gate performs the rotation about the Z-axis of the Bloch Sphere by a given amount. It is a parameterized Gate with the parameter being the amount of rotation to be performed around the Z-axis. For example, when a RZ Gate with a parameter π/3 is applied on a Qubit, the rotation about the Z-axis will be π/3 radians.
Note– The Z Gate is a special case of RZ Gate when the rotation about the Z-axis of the Bloch Sphere is π radians.
RZ Gate: Bloch Sphere
The RZ Gate performs a rotation about the Z-axis on the Bloch Sphere by the given amount.
Example
In this example, we will look at how the application of RZ gate on the Qubit affects its representation on the Bloch Sphere.
In the below figure, the RZ Gate with parameter π/2 is applied on a Qubit in the state Ψ = 1/sqrt(2) |0> + 1/sqrt(2) |1>
, and the resulting state of the Qubit is
.Ψ = 1/sqrt(2) |0> + i/sqrt(2) |1>
Note– Since RZ Gate performs rotation about the Z-axis, it will have no effect on a vector that lies on the Z-axis.
RZ Gate: Pauli Matrix
The RZ Gate in Quantum Computing is represented by the matrix RZ
where θ is the angle of rotation about the Z axis in the counter-clockwise direction.
The resulting state of a Qubit after the application of RZ Gate can also be calculated by multiplying the Matrix for RZ Gate with the vector representing the state of the Qubit.
Example
In this example, we will apply the RZ gate to a Qubit, and calculate the resulting state by multiplying it with the Pauli Matrix for RZ Gate. The value of parameter θ will be π/2.
Let the state of the Qubit be Ψ = |0>
After Applying the RZ Gate with θ = π/2, the resulting state of the Qubit can be calculated by-
Inverse of RZ Gate
The inverse of RZ Gate with parameter θ is RZ Gate with parameter -θ . The RZ Gate with parameter θ will perform a rotation around the Z-axis on the Bloch Sphere by θ radians in the counter-clockwise direction. The RZ Gate with parameter -θ will perform a rotation around the Z-axis on the Bloch Sphere by θ radians in the clockwise direction.
RZ Gate in Qiskit
The RZ Gate in Qiskit can be applied to any Qubit by calling the rz()
method on the Quantum Circuit(an instance of QuantumCircuit
class) and passing it the amount of rotation(in radians), and an integer for the Qubit on which RZ Gate is to be applied.
Example
In this example, we will be applying RZ Gate on the first Qubit in the Quantum Circuit, which will contain 2 Qubits. The parameter θ is passed to the rz()
method along with the index of the Qubit on which the RZ Gate is to applied. In this example, the value of θ will be π/2.
Note– The parameter θ is the angle of rotation in radians in the counter-clockwise direction.
import numpy as np
# Creating a Quantum Circuit with 2 Qubits
circuit = QuantumCircuit(2)
# Applying RZ Gate on the first Qubit with parameter pi/2
circuit.rz(np.pi/2, 0)
# Drawing the Quantum Circuit
circuit.draw()
This will result in the following Quantum Circuit being drawn-