<jupyter_start><jupyter_text>Quantum Fourier TransformQuantum fourier transform is an algorithm like a classical fast fourier transform. Fourier transform algorithm is an algorithm to sum up the series of wave into the frequency. The quantum fourier transform discrete series of wave into a quantum state.  TheoryIt is very simular to the classical fast fourier transform. Map a quantum state to another state.$$QFT:\mid x \rangle \mapsto \frac{1}{\sqrt{N}}\sum_{k=0}^{N-1} \omega_n^{xk}\mid k\rangle \\ \omega_n = e^{\frac{2\pi i}{N}}$$  Input as bit and output as quantum stateInput is 01 bit input and finally we get the quantum state.$$QFT(\mid x_1,x_2,…,x_n \rangle) = \frac{1}{\sqrt{N}}(\mid 0 \rangle + e^{2\pi i [0.x_n]} \mid 1 \rangle) \otimes … \otimes (\mid 0 \rangle + e^{2\pi i [0.x_1x_2…x_n]} \mid 1 \rangle)$$Now we get the quantum state cannot observed with classical measurement. We need inverse fourier transform or other operation to get the quantum state itself.  CircuitLet's see the easiest 2qubits circuit.<jupyter_code>!pip install blueqat
from blueqat import Circuit
import math

Circuit().x[0].x[1].h[0].rz(math.pi/4)[0].cx[1,0].rz(-math.pi/4)[0].cx[1,0].h[1].run()<jupyter_output><empty_output><jupyter_text>Next N=4<jupyter_code>Circuit().x[:].h[0].rz(math.pi/4)[0].cx[1,0].rz(-math.pi/4)[0].cx[1,0].rz(math.pi/8)[0].cx[2,0].rz(-math.pi/8)[0].cx[2,0].rz(math.pi/16)[0].cx[3,0].rz(-math.pi/16)[0].cx[3,0].h[1].rz(math.pi/4)[1].cx[2,1].rz(-math.pi/4)[1].cx[2,1].rz(math.pi/8)[1].cx[3,1].rz(-math.pi/8)[1].cx[3,1].h[2].rz(math.pi/4)[2].cx[3,2].rz(-math.pi/4)[2].cx[3,2].h[3].run()<jupyter_output><empty_output><jupyter_text>This is quantum fourier transform. Now we get quantum state directly from the simulator.  Advanced : check with fft on numpyIt is very difficult to check qft on simulator. This time we try check the state vector using fft on numpy.<jupyter_code>import numpy as np
print(np.fft.fft(np.array([0,0,0,1])/2))<jupyter_output>[ 0.5+0.j   0. +0.5j -0.5+0.j   0. -0.5j]
{'fraction_non_alphanumeric': 0.18208955223880596, 'fraction_numerical': 0.051741293532338306, 'mean_word_length': 4.778735632183908, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '364209', 'license': 'Apache-2.0', 'n_tokens_mistral': 798, 'n_tokens_neox': 771, 'n_words': 200, 'path': 'tutorial/112_qft_en.ipynb', 'repo_name': 'tmdoi/Blueqat-tutorials', 'size': '2010'}