Qiskit: T Gate

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


T Gate

The T Gate acts on a single Qubit. The T gate changes the phase of the Qubit by 45° or π/4 radians. However, in terms of its effect on a state represented in terms of the standard basis pairs |0> and |1>, it has no effect on the coefficients of |0> to |1>. Hence, the application of T Gate does not alter the probabilities of the state of the Qubit collapsing into |0> or |1> upon measurement.

Note– The T Gate is a special case of Phase Gate where the parameter(the phase change) is 45° or π/4 radians.

Note– The T Gate is sometimes also called ∜Z Gate. This is because applying the T Gate 4 times produces the same effect as a Z Gate.


T Gate: Bloch Sphere

The T Gate performs a rotation about the Z-axis on the Bloch Sphere by a 45° or π/4 radians in the counter-clockwise direction.

Example

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

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

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

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


T Gate: Matrix

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

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

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

Note– The value of eiπ/4 is 1/sqrt(2) + i/sqrt(2)

Example

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

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

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

Since there is only rotation about the Z-axis, notice that the probability of getting |0> and |1> are the same whereas there is a change in the phase of the Qubit.


Inverse of T Gate

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


T Gate in Qiskit

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

Example

In this example, we will be applying T 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 T Gate on the first Qubit
circuit.t(0)

# Drawing the Quantum Circuit
circuit.draw()

This will result in the following Quantum Circuit being drawn-

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