Qiskit: Tdg Gate

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


Tdg Gate

The Tdg Gate acts on a single Qubit. The Tdg 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 Tdg Gate does not alter the probabilities of the state of the Qubit collapsing into |0> or |1> upon measurement.

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

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

Note– The Tdg Gate is also called T-dagger Gate or T Gate(T with a Dagger in super-script).


Tdg Gate: Bloch Sphere

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

Example

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

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

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

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


Tdg Gate: Matrix

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

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

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

Example

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

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

After Applying the Tdg 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 Tdg Gate

The inverse of a Tdg Gate is T Gate. You have already learned about T Gate in the previous chapter. The Tdg Gate produces the effect of rotation by 45° or π/4 radians about the Z-axis on the Bloch Sphere in clockwise direction. 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. 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.


Tdg Gate in Qiskit

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

Example

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

# Drawing the Quantum Circuit
circuit.draw()

This will result in the following Quantum Circuit being drawn-

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