Discrete Fourier Transform (DFT) is a specific kind of Fourier Transform usually used in signal processing and data analysis, though it is also used to compute polynomial multiplication in computer science. DFT is applied to discrete, sampled data, rather than a continuous signal. The discrete part of its name reflects that the algorithm is designed for sequences of values at discrete intervals.
Before proceeding to read this post, the followings are few basic variables and operations in quantum computing that will be used for this post:
A qubit is represented by vectors.
Basic states cover
KaTeX can only parse string typed expression
∣0⟩=(10) and
KaTeX can only parse string typed expression
∣1⟩=(01), which classically are considered as 0 and 1, respectively.
Superposition state,
KaTeX can only parse string typed expression
∣ψ⟩, represents a general quantum state, which is a superposition of the basis states. In a linear combination,
KaTeX can only parse string typed expression
∣ψ⟩=α∣0⟩+β∣1⟩, where
KaTeX can only parse string typed expression
α and
KaTeX can only parse string typed expression
β are complex numbers that satisfy
KaTeX can only parse string typed expression
∣α∣2+∣β∣2=1.
The quantum bit operations that are used include Pauli-X gate, Hadamard gate, and Controlled phase gate.
Pauli-X gate, which is represented as
KaTeX can only parse string typed expression
X=(0110), corresponds to a NOT gate in a classical bit inversion. The gate operates as follows:
KaTeX can only parse string typed expression
X∣0⟩=∣1⟩ and
KaTeX can only parse string typed expression
X∣1⟩=∣0⟩.
Hadamard gate, which is represented as
KaTeX can only parse string typed expression
H=21(111−1). It creates superposition states from the basic states:
KaTeX can only parse string typed expression
H∣0⟩=2∣0⟩+∣1⟩ and
KaTeX can only parse string typed expression
H∣1⟩=2∣0⟩−∣1⟩. If we apply hadamard to
KaTeX can only parse string typed expression
∣ψ⟩, we get
KaTeX can only parse string typed expression
H∣ψ⟩=2α+β∣0⟩+2α−β∣1⟩.
Controlled phase gate, which controls the phase rotation, is represented as
KaTeX can only parse string typed expression
CRz(θ)=100001000010000eiθ. The first three diagonal elements are 1, implying that when the control qubit is in the
KaTeX can only parse string typed expression
∣0⟩ state, or
KaTeX can only parse string typed expression
∣1⟩ state but targeting
KaTeX can only parse string typed expression
∣0⟩, the gate does not change the state of the system. The last element implies a phase shift of
KaTeX can only parse string typed expression
θ when the control qubit is in the
KaTeX can only parse string typed expression
∣1⟩ state.
Discrete Fourier Transform
Discrete Fourier Transform transforms a sequence of complex numbers, say
KaTeX can only parse string typed expression
a0,a1,…,aN−1, into another sequence of complex numbers, say
[0.an−k−1…an−1] is a binary fraction representation. This expression showcases the algorithm's potential to encode phase information across a superposition of all computational basis states.
The action of the Hadamard gate produces superpositions necessity for the algorithm's operation:
KaTeX can only parse string typed expression
H∣aj⟩=21(∣0⟩+e2πiaj∣1⟩),
. Each step in the algorithm, reliant on superposition and entanglement, achieves the quantum analogue of the classical Discrete Fourier Transform efficiently.
from qiskit import QuantumCircuit, Aer, execute, transpile
from qiskit.visualization import plot_histogram
import math
import matplotlib.pyplot as plt
import numpy as np
defdft(N, arr): n = math.ceil(math.log2(N)) qc = QuantumCircuit(n, n) norm_arr = np.array(arr)/ np.linalg.norm(arr)for i, amp inenumerate(norm_arr):if amp >0: qc.x(i % n)defapply_qft(circuit, n):for j inrange(n): circuit.h(j)for k inrange(j +1, n): circuit.cp(np.pi /2**(k - j), j, k)for k inrange(n //2): circuit.swap(j, n - k -1) apply_qft(qc, n)for i inrange(n): qc.measure(i, i) simulator = Aer.get_backend('aer_simulator') counts = simulator.run(transpile(qc, simulator)).result().get_counts()print("Quantum Circuit:")print(qc.draw())print("Measurement Results:") plot_histogram(counts) plt.show()
The apply_qft function runs in
KaTeX can only parse string typed expression
O(n2), where
KaTeX can only parse string typed expression
n is the number of qubits. To represent an array of
KaTeX can only parse string typed expression
N elements in a quantum computer,
KaTeX can only parse string typed expression
log2(N) number of qubits are needed. As a result, the overall performance of apply_qft is
KaTeX can only parse string typed expression
O(log2(N)). This highlights a significant reduction in computational resources compared to classical methods. Currently, the fastest known quantum algorithm for Discrete Fourier Transform achieves about
KaTeX can only parse string typed expression
O(log(N)log(log(N))) performance.
Importance of Discrete Fourier Transform in Quantum Computing
The QFT algorithm exemplifies the leap between classical computing to quantum computing. One of the most notable applications of QFT include Shor's algorithm, which is an algorithm that finds the prime factors of an integer. Compared to the most efficient classical factoring algorithm that runs in
KaTeX can only parse string typed expression
O(e1.9log1/3(N)log2/3(log(N))), Shor's algorithm runs in
KaTeX can only parse string typed expression
O(log2(N)log(log(N))log(log(log(N)))). That is significantly faster!
Beyond the acceleration, QFT highlights the unique capabilities of quantum systems to encode and manipulate information in ways that classical systems cannot replicate. This opens up avenues for complex system optimizations!