$$
QFT |x> = frac{1}{2^{n/2}} sum_{y=0}^{2^n-1} e^{2 pi iyx / 2^n} |y>
$$
$|x_1>$ = -H-CR2-CR3-.. -CRn—————–
$|x_2>$ = ——————H-CR2–.. ———-
.
.
$|x_{n-1}>$ = ———————.. –H-CR2—
$|x_n>$ = ————————-.. ——–H-
import cirq
import random
import matplotlib.pyplot as plt
import numpy as np
def make_qft(qubits):
qreg = list(qubits)
while len(qreg) > 0:
q_head = qreg.pop(0)
yield cirq. H(q_head)
for i, qubit in enumerate(qreg):
yield (cirq. CZ **(1 / 2 ** (i + 1)))(qubit, q_head)
qubits = cirq. LineQubit.range(4)
qft = cirq. Circuit(make_qft(qubits))
print(qft)