Qiskit: RX Gate

The RX Gate is an important gates in Quantum Computing. Qiskit provides a method for applying RX Gate on a Qubit. In this chapter of the Qiskit Tutorial, you will learn about RX Gate and how to apply RX Gate on a Qubit in Qiskit.


RX Gate

The RX Gate acts on a single Qubit. The RX Gate performs the rotation about the X-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 X-axis. For example, when a RX Gate with a parameter π/3 is applied on a Qubit, the rotation about the X-axis will be π/3 radians.

Note– The X Gate is a special case of RX Gate when the rotation about the X-axis of the Bloch Sphere is π radians.


RX Gate: Bloch Sphere

The RX Gate performs a rotation about the X-axis on the Bloch Sphere by the given amount.

Example

In this example, we will look at how the application of RX gate on the Qubit affects its representation on the Bloch Sphere.

In the below figure, the RX Gate with parameter π/2 is applied on a Qubit in the state Ψ = |0>, and the resulting state of the Qubit is Ψ = 1/sqrt(2) |0> - i/sqrt(2) |1>.

Effect of Applying RX Gate

Note– Since RX Gate performs rotation about the X-axis, it will have no effect on a vector that lies on the X-axis.


RX Gate: Pauli Matrix

The RX Gate in Quantum Computing is represented by the matrix RX

Matrix for RX Gate

where θ is the angle of rotation about the X axis in the counter-clockwise direction.

The resulting state of a Qubit after the application of RX Gate can also be calculated by multiplying the Matrix for RX Gate with the vector representing the state of the Qubit.

Example

In this example, we will apply the RX gate to a Qubit, and calculate the resulting state by Multiplying it with the Pauli Matrix for RX Gate. The value of parameter θ will be π/2.

Let the state of the Qubit be Ψ = |0>

After Applying the RX Gate with θ = π/2, the resulting state of the Qubit can be calculated by-

Effect of Applying RX Gate

Inverse of RX Gate

The inverse of RX Gate with parameter θ is RX Gate with parameter -θ . The RX Gate with parameter θ will perform a rotation around the X-axis on the Bloch Sphere by θ radians in the counter-clockwise direction. The RX Gate with parameter -θ will perform a rotation around the X-axis on the Bloch Sphere by θ radians in the clockwise direction.


RX Gate in Qiskit

The RX Gate in Qiskit can be applied to any Qubit by calling the rx() 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 RX Gate is to be applied.

Example

In this example, we will be applying RX Gate on the first Qubit in the Quantum Circuit, which will contain 2 Qubits. The parameter θ is passed to the rx() method along with the index of the Qubit on which the RX 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 RX Gate on the first Qubit with parameter pi/2
circuit.rx(np.pi/2, 0)

# Drawing the Quantum Circuit
circuit.draw()

This will result in the following Quantum Circuit being drawn-

Applying RX Gate in Qiskit