yohandi
A recent graduate with a strong interest in algorithms and data structures.

[Tutorial] Discrete Fourier Transform in Quantum Computing

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
      and
      KaTeX can only parse string typed expression
      , 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
      , 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
      .
  • 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
      , corresponds to a NOT gate in a classical bit inversion. The gate operates as follows:
      KaTeX can only parse string typed expression
      and
      KaTeX can only parse string typed expression
      .
    • Hadamard gate, which is represented as
      KaTeX can only parse string typed expression
      . It creates superposition states from the basic states:
      KaTeX can only parse string typed expression
      and
      KaTeX can only parse string typed expression
      . If we apply hadamard to
      KaTeX can only parse string typed expression
      , we get
      KaTeX can only parse string typed expression
      .
    • Controlled phase gate, which controls the phase rotation, is represented as
      KaTeX can only parse string typed expression
      . The first three diagonal elements are 1, implying that when the control qubit is in the
      KaTeX can only parse string typed expression
      state, or
      KaTeX can only parse string typed expression
      state but targeting
      KaTeX can only parse string typed expression
      , 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
      state.

Discrete Fourier Transform

Discrete Fourier Transform transforms a sequence of complex numbers, say

KaTeX can only parse string typed expression
, into another sequence of complex numbers, say
KaTeX can only parse string typed expression
, where
KaTeX can only parse string typed expression
is defined as:

KaTeX can only parse string typed expression

, where

KaTeX can only parse string typed expression
. This implies that the
KaTeX can only parse string typed expression
-th element of
KaTeX can only parse string typed expression
is:

KaTeX can only parse string typed expression

By computing the matrix multiplication,

KaTeX can only parse string typed expression
can be simply obtained through an
KaTeX can only parse string typed expression
näive implementation.

Fast Fourier Transform

Currently, Fast Fourier Transform stands as the quickest classical algorithm that converts the same sequence of

KaTeX can only parse string typed expression
into
KaTeX can only parse string typed expression
in
KaTeX can only parse string typed expression
performance. Let
KaTeX can only parse string typed expression
be a polynomial function, the algorithm exploits the fact that:

  • KaTeX can only parse string typed expression
  • KaTeX can only parse string typed expression

, where

KaTeX can only parse string typed expression
is the polynomial containing all the terms of
KaTeX can only parse string typed expression
with even powers, and
KaTeX can only parse string typed expression
contains all the terms of
KaTeX can only parse string typed expression
with odd powers. As it is possible to reconstruct
KaTeX can only parse string typed expression
given
KaTeX can only parse string typed expression
such that
KaTeX can only parse string typed expression
and
KaTeX can only parse string typed expression
, the objective of the algorithm is simply to find
KaTeX can only parse string typed expression
for any configuration of
KaTeX can only parse string typed expression
. Setting up
KaTeX can only parse string typed expression
as
KaTeX can only parse string typed expression
allows divide-and-conquer approach to be used (due to symmetry) for efficient evaluation of
KaTeX can only parse string typed expression
by
KaTeX can only parse string typed expression
and
KaTeX can only parse string typed expression
. This method yields the FFT's hallmark performance:

KaTeX can only parse string typed expression

is obtained.

Discrete Fourier Transform in Quantum Computing

With the same objective, the Quantum Fourier Transform (QFT) converts

KaTeX can only parse string typed expression
into
KaTeX can only parse string typed expression
, where:

KaTeX can only parse string typed expression

Notice that the

KaTeX can only parse string typed expression
is expressed and rewrittable as:

KaTeX can only parse string typed expression

, where

KaTeX can only parse string typed expression
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

. 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

def dft(N, arr):
    n = math.ceil(math.log2(N))

    qc = QuantumCircuit(n, n)
    
    norm_arr = np.array(arr) / np.linalg.norm(arr)
    for i, amp in enumerate(norm_arr):
        if amp > 0:
            qc.x(i % n)

    def apply_qft(circuit, n):
        for j in range(n):
            circuit.h(j)
            
            for k in range(j + 1, n):
                circuit.cp(np.pi / 2 ** (k - j), j, k)

        for k in range(n // 2):
            circuit.swap(j, n - k - 1)

    apply_qft(qc, n)

    for i in range(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
, where
KaTeX can only parse string typed expression
is the number of qubits. To represent an array of
KaTeX can only parse string typed expression
elements in a quantum computer,
KaTeX can only parse string typed expression
number of qubits are needed. As a result, the overall performance of apply_qft is
KaTeX can only parse string typed expression
. 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
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
, Shor's algorithm runs in
KaTeX can only parse string typed expression
. 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!

References

  1. Nielsen, M., "Quantum Computation and Quantum Information," Cambridge University Press. https://www.worldcat.org/oclc/174527496.