Qiskit: SX Gate

The SX Gate is a lesser used gate in Quantum Computing. Qiskit provides a method for applying SX Gate on a Qubit. In this chapter of the Qiskit Tutorial, you will learn about SX Gate and how to apply SX Gate on a Qubit in Qiskit.


SX Gate

The SX Gate acts on a single Qubit. The SX Gate performs the rotation about the X-axis of the Bloch Sphere by 90° or π/2 radians in the counter-clockwise direction.

Note– The SX Gate is a special case of RX Gate where the parameter(the phase change) is 90° or π/2 radians.

Note– The SX Gate is sometimes also called √X Gate. This is because applying the SX Gate twice produces the same effect as a X Gate.


SX Gate: Bloch Sphere

The SX Gate performs a rotation about the X-axis on the Bloch Sphere by a 90° or π/2 radians in the counter-clockwise direction.

Example

In this example, we will look at how the application of SX gate on the Qubit affects its representation on the Bloch Sphere. Remember how SX Gate performs a rotation by 90° or π/2 radians about the X-axis on the Bloch Sphere in the counter-clockwise direction.

In the below figure, the SX Gate is applied on a Qubit in the state Ψ = |0> and the resulting state of the Qubit is Ψ = |-i>.

Effect of Applying SX Gate

In the below figure, the SX Gate is applied on a Qubit in the state Ψ = |i> and the resulting state of the Qubit is Ψ = |0>.

Effect of Applying SX Gate

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


SX Gate: Matrix

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

Matrix for SX Gate

In the matrix, i represents square-root of -1.

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

Example

In this example, we will apply the SX gate to a Qubit, and calculate the resulting state by Multiplying it with the Matrix for SX Gate.

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

After Applying the SX Gate, the resulting state of the Qubit can be calculated by-

The resulting state is  Ψ = (1+i)/2 |0> + (1-i)/2 |1> , after removing the Global Phase, the state can be written as Ψ = 1/sqrt(2) |0> -i/sqrt(2) |1>, which is the same as that achieved by the desired rotation on the Bloch Sphere.


Inverse of SX Gate

The inverse of a S Gate is SX Gate, which is also known as SXdg Gate or SX-Dagger Gate. The SX Gate produces the effect of rotation by 90° or π/2 radians about the X-axis on the Bloch Sphere in counter-clockwise direction. The SX Gate produces the effect of rotation by 90° or π/2 radians about the X-axis on the Bloch Sphere in clockwise direction. Since applying SX Gate after applying SX Gate changes the state of the Qubit to the original state, SX Gate is the inverse of SX Gate. You will learn more about SX Gate in the next chapter.


SX Gate in Qiskit

The SX Gate in Qiskit can be applied to any Qubit by calling the sx() method on the Quantum Circuit(an instance of QuantumCircuit class) and passing it an integer for the Qubit on which SX Gate is to be applied.

Example

In this example, we will be applying SX Gate on the first Qubit in the Quantum Circuit, which will contain 2 Qubits.

# Creating a Quantum Register with 2 Qubit
qr = qiskit.QuantumRegister(2)

# Creating a Quantum Circuit
circuit = QuantumCircuit(qr)

# Applying SX Gate on the first Qubit
circuit.sx(0)

# Drawing the Quantum Circuit
circuit.draw()

This will result in the following Quantum Circuit being drawn-

Applying Qiskit SX Gate

Notice that the SX Gate is applied to the first Qubit.