Hi, could someone explain why this code is incorrect?
###############################################
num_wires = 3
dev = qml.device(“default.qubit”, wires=num_wires)
@qml.qnode(dev)
def three_qubit_QFT(basis_id):
“”"A circuit that computes the QFT on three qubits.
Args:
basis_id (int): An integer value identifying the basis state to construct.
Returns:
array[complex]: The state of the qubits after the QFT operation.
"""
# Prepare the basis state |basis_id>
bits = [int(x) for x in np.binary_repr(basis_id, width=num_wires)]
qml.BasisStatePreparation(bits, wires=[0, 1, 2])
##################
# YOUR CODE HERE #
##################
# Qubit x1
qml.Hadamard(wires=0)
# CTRL-R2
qml.ctrl(qml.RZ, control=1)(np.pi/2, wires=0)
# CTRL-R3
qml.ctrl(qml.RZ, control=2)(np.pi/4, wires=0)
# Qubit x2
qml.Hadamard(wires=1)
# CTRL-R2
qml.ctrl(qml.RZ, control=2)(np.pi/2, wires=1)
# Qubit x3
qml.Hadamard(wires=2)
# SWAP qubits
qml.SWAP(wires=[0, 2])
return qml.state()
###############################################