# How to apply QFT to the last two qubits of a Qiskit quantum circuit?

I'm pretty new in Qiskit and quantum circuits. I'm using Qiskit to implement a quantum circuit and I followed this tutorial to implement a QFT. The way this QFT was built, it applies QFT in the first $$n$$ qubits, but what I need is to apply the QFT in the last $$n$$ qubits. Is there any way to do this?

In general, to build a Quantum Fourier Transform on an arbitrary number of qubits, you can use the QFT class already implemented in Qiskit. In particular, to apply it to the last two qubits of your circuit, you can convert the QFT object to a gate and then append it passing the qubits indices.

from qiskit import QuantumCircuit
from qiskit.circuit.library import QFT

qc = QuantumCircuit(3)
qft = QFT(num_qubits=2).to_gate()
qc.append(qft, qargs=[1, 2])

qc.decompose(reps=2).draw('mpl') • To get the inverse QFT, you just need qft_inv = qft.inverse(); more in general, given an arbitrary quantum gate defined in Qiskit, you can compute its inverse operation by calling the method Gate.inverse. Mar 14 at 22:26