Qiskit: Y Gate

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


Y Gate

The Y Gate acts on a single Qubit. In terms of its effect on a state represented in terms of the standard basis pairs |0> and |1>, it maps the coefficient of |0> to |1>, and |1> to |0>. This is results in an exchange of probabilities of getting |0> and |1>. Additionally, it also flips the phase of the Qubit by 180° or π radians.

Note– The Y Gate is also known as Bit and Phase flip Gate. This is because it performs a bit flip like X Gate and a Phase flip like Z Gate.

Example

For a Qubit in state Ψ = 1/sqrt(3) |0> + sqrt(2/3) |1>, the application of Y Gate will change the state of the Qubit to Ψ = -i sqrt(2/3) |0> + i/sqrt(3) |1>.

Before the Y Gate was applied to the Qubit, the probabilities of getting |0> and |1> were 1/3 and 2/3 respectively. After the Y Gate was applied on the Qubit, the probabilities of getting |0> and |1> were 2/3 and 1/3 respectively. Hence, there was an interchange in the probabilities of getting |0> and |1>.This is demonstrated in the table below-

Before applying Y GateAfter applying Y Gate
Probability of Getting 0 on measurement1/32/3
Probability of Getting 1 on measurement2/31/3

There is also a change in the phase of the Qubit by 180° or π radians which can be noticed with the change of sign for the coefficient of |0>.


Y Gate: Bloch Sphere

The Y Gate performs a rotation of 180° or π radians about the Y-axis on the Bloch Sphere.

Example

In this example, we will look at how the application of Y gate on the Qubit affects its representation on the Bloch Sphere. Remember how Y Gate performs a rotation of 180° or π radians about the Y-axis on the Bloch Sphere.

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

Qiskit Y Gate effect

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

Qiskit Y Gate effect

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


Y Gate: Pauli Matrix

The Y Gate in Quantum Computing is represented by the matrix Y or σy

Pauli Matrix for Y Gate

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

Example

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

Let the state of the Qubit be Ψ = 1/sqrt(3) |0> + sqrt(2/3) |1>

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

Calculating result of Y Gate applied on a Qubit

Similarly as before, the probability of getting |0> and |1> are reversed along with a flip in phase.


Inverse of Y Gate

The Y is its own inverse. Therefore, applying Y Gate to the same Qubit twice will result in the original state of the Qubit.

Example

For a Qubit in state Ψ = 1/sqrt(3) |0> + sqrt(2/3) |1>, the application of Y Gate will change the state of the Qubit to Ψ = -i sqrt(2/3) |0> + i/sqrt(3) |1>.

After application of the Y Gate again to the same Qubit, the resulting state of the Qubit will be Ψ = 1/sqrt(3) |0> + sqrt(2/3) |1>.

Since applying Y Gate twice to the same Qubit results in the same state, Y Gate is its own inverse.


Y Gate in Qiskit

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

Example

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

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

# Creating a Quantum Circuit
circuit = QuantumCircuit(qr)

# Applying Y Gate on the first Qubit
circuit.y(0)

# Drawing the Quantum Circuit
circuit.draw()

This will result in the following Quantum Circuit being drawn-

Notice that the Y Gate is applied to the first Qubit. Also notice, that Qubits follow a 0 based indexing.