The following figure shows the QFT circuit on
As you can see, there is a Hadamard gate, followed by a contribution of rotations on each qubit from every subsequent qubit, followed by SWAP gates. These sequences of rotations produce the QFT in which the order of the qubits is reversed. For example, on the first qubit we obtain the term
This explains why we have SWAP gates at the end of the circuit!
To warm up our fingers, let's first derive this circuit for three qubits and implement it. We need the controlled gates
Implement the QFT for three qubits.
Calculate the controlled-
These are familiar gates! Remember too that you can use the qml.ctrl
operation to make a controlled gate.
To interact with codercises, please switch to a larger screen size.
Learning Objectives: