Codebook: Quantum Fourier Transform

Ask here about the “Quantum Fourier Transform” Codebook topic from the “Quantum Fourier Transform” module.

Hi,
in “QFT circuit for two qubit” there is a calculation for HS and the result is given as a martix (numpy notation): ( [1, 1], [i, -i] ).

I miss the 1 / sqrt(2)

Is this just a typo or do I miss something?

Best regards,
jomu

Hi,
in “QFT circuit for two qubit” there are two diagrams for the circuit.
I implemented the first and it looks OK.
This is the code:
qml.Hadamard(wires = 0)
qml.ctrl(qml.S, control=1)(wires=0)
qml.Hadamard(wires = 1)
qml.SWAP(wires=[0,1])
return qml.state()

Then I tried the second but now the systems responds “not OK”.
This is the code:
qml.Hadamard(wires = 1)
qml.ctrl(qml.S, control=0)(wires=1)
qml.Hadamard(wires = 0)
return qml.state()

But when I do a swap at the very first beginning then again it OK:
qml.SWAP(wires=[0,1])
qml.Hadamard(wires = 1)
qml.ctrl(qml.S, control=0)(wires=1)
qml.Hadamard(wires = 0)
return qml.state()

But in this case there is not reduction in the depth of the circuit.

Is there something wrong with the sketch?

Best rergards,
jomu

Hi,
in “Properties of the QFT” you write:
“We will look at special functions where the amplitude is non-zero at multiples of
(and zero otherwise) and has no offset”

I tested this with numpy FFT.
When I use an input like:
poly_a = np.array([1, 0, 0, 0,
1, 0, 0, 0,
1, 0, 0, 0,
1, 0, 0, 0 ], dtype=complex)
then the FFT output is periodic as expected.

When I use an input like:
poly_a = np.array([1, 0, 0, 1,
1, 0, 0, 1,
1, 0, 0, 1,
1, 0, 0, 1 ], dtype=complex)
then the FFT output is not periodic any more.

My question: is this “and zero otherwise” a strict requirement for a periodic output?

Best regards,
jomu

Hi @jomu, yes there’s a typo. We’re missing the 1/sqrt(2). Good catch!

Hi @jomu , I think there might be something wrong with the sketch indeed because the output of the two circuits is different. Let me check and get back to you.

Hi @jomu,

Regarding your last question, “zero otherwise” is indeed a strict requirement for FFT to work as expected.

Hi Catalina,
thank you so much for all these clarifications and help. I really appreciate it!

Regards,
jomu

1 Like