My Lecture Note on Discrete Fourier Transform
June 6th, 2024

Ok, let me explain the Discrete Fourier Transform (DFT). I won't delve into why the Fourier Transform is important, but it is used in many fields: physics, image processing, signal processing, and many more. Let's start with the Fourier series. A periodic function f(x)f(x) can be approximated by an infinite summation of sine and cosine functions. Sine and cosine can be represented using the Euler formula, eix=cos(x)+isin(x)e^{ix} = \cos(x) + i\sin(x). Thus,

f(x)=n=Cneinx,f(x) = \sum_{n=-\infty}^{\infty} C_n e^{inx},

where x(π,π)x\in(-\pi,\pi). Use tt instead of xx and normalize it a bit to ωt\omega t, so we get

f(t)=n=Cneinωt,f(t) = \sum_{n=-\infty}^{\infty} C_n e^{in\omega t},

where ω=2πT\omega = \frac{2\pi}{T} and TT is the period. The Fourier series shows the periodic property very clearly. If we shift time by one period TT,

f(t+T)=n=Cneinω(t+T).f(t+T) = \sum_{n=-\infty}^{\infty} C_n e^{in\omega(t+T)}.

Then,

f(t+T)=n=CneinωteinωT=n=Cneinωtein2πTTf(t+T) = \sum_{n=-\infty}^{\infty} C_n e^{in\omega t} e^{in\omega T} = \sum_{n=-\infty}^{\infty} C_n e^{in\omega t} e^{in\frac{2\pi T}{T}}
f(t+T)=n=Cneinωtein2π=n=Cneinωt=f(t).f(t+T) = \sum _{n=-\infty}^{\infty}C_n e^{in\omega t} e^{in2\pi} = \sum_{n=-\infty}^{\infty} C_n e^{in\omega t}=f(t).

Here is my intuition again. In fact, einxe^{inx} is a basis function of a periodic function f(x)f(x). To show that einxe^{inx} is a basis, we first have to show that it is:

  1. Linearly independent

  2. Spanning

The first one is quite easy. To show that it is linearly independent, we need to show that given nbneinx=0, \sum_n b_n e^{inx} = 0, then bn=0 for all nZ. b_n = 0 \text{ for all } n \in \mathbb{Z}. But we know that for mnm \neq n,

ππei(mn)xdx=[ei(mn)xi(mn)]ππ=ei(mn)πei(mn)πi(mn)\int_{-\pi}^{\pi} e^{i(m-n)x} dx = \left[ \frac{e^{i(m-n)x}}{i(m-n)} \right]_{-\pi}^{\pi} = \frac{e^{i(m-n)\pi} - e^{-i(m-n)\pi}}{i(m-n)}
ππei(mn)xdx=2isin((mn)π)i(mn)=0,\int_{-\pi}^{\pi} e^{i(m-n)x} dx = \frac{2i\sin((m-n)\pi)}{i(m-n)} = 0,

because mnZm-n \in \mathbb{Z} resulting in sin(integerπ)=0sin(\text{integer}*\pi)=0. For m=nm = n,

ππei(mm)xdx=2π.\int_{-\pi}^{\pi} e^{i(m-m)x} dx = 2\pi.

Thus,

ππei(mn)xdx=δmn2π.\int_{-\pi}^{\pi} e^{i(m-n)x} dx = \delta_{mn} 2\pi.

Applying this with

nbneinx=0,\sum_n b_n e^{inx} = 0,

we get bn=0b_n = 0 for all nZn \in \mathbb{Z}. For the spanning property, here is the proof from this link. By first assuming that einxe^{inx} spans, then

f(x)=m=Cmeimxf(x) = \sum_{m=-\infty}^{\infty} C_m e^{imx}
ππeinxf(x)dx=m=ππeinxCneimxdx \int_{-\pi}^{\pi} e^{-inx} f(x) dx = \sum_{m=-\infty}^{\infty} \int_{-\pi}^{\pi} e^{-inx} C_n e^{imx} dx
ππeinxf(x)dx=m=ππeinxCneimxdx\int_{-\pi}^{\pi} e^{-inx} f(x) dx = \sum_{m=-\infty}^{\infty} \int_{-\pi}^{\pi} e^{-inx} C_n e^{imx} dx
Cn=12πππeinxf(x)dx.C_n = \frac{1}{2\pi} \int_{-\pi}^{\pi} e^{-inx} f(x) dx.

The coefficient of the Fourier series CnC_n is an integral of the original function:

Cn=12πππeinxf(x)dx.C_n = \frac{1}{2\pi} \int_{-\pi}^{\pi} e^{-inx} f(x) dx.

Now substitute CnC_n into the Fourier series of f(x)f(x)

fFS(x)=n=Cneinx,f_{FS}(x) = \sum_{n=-\infty}^{\infty} C_n e^{inx},

we get

fFS(x)=n=12πππeinyf(y)dyeinxf_{FS}(x) = \sum_{n=-\infty}^{\infty} \frac{1}{2\pi} \int_{-\pi}^{\pi} e^{-iny} f(y) dy e^{inx}
fFS(x)=12πππn=ein(xy)f(y)dy.f_{FS}(x) = \frac{1}{2\pi} \int_{-\pi}^{\pi} \sum_{n=-\infty}^{\infty} e^{in(x-y)} f(y) dy.

Here, from appendix A, we have n=ein(xy)ein(xy)dn\sum_{n=-\infty}^{\infty} e^{in(x-y)} \approx \int_{-\infty}^{\infty} e^{in(x-y)} dn. Using the property of the Dirac delta function ein(xy)dn=2πδ(xy)\int_{-\infty}^{\infty} e^{in(x-y)} dn=2\pi\delta(x-y), we get

fFS(x)=12πππ2πδ(xy)f(y)dy=f(x)f_{FS}(x) = \frac{1}{2\pi} \int_{-\pi}^{\pi} 2\pi\delta(x-y) f(y) dy=f(x)

The last line implies that a function f(x)f(x) is in fact fFS(x)f_{FS}(x), implying that f(x)f(x) can be approximated using the Fourier serie.

The Fourier series might not always be useful, as sometimes we want to use it with non-periodic functions. To achieve this, we derive the Fourier Transform, which can be viewed as the general case of the Fourier series. To get a non-periodic function from a periodic one, we just need to stretch the period TT to \infty.

First, change our CnC_n into an appropriate form:

Cn=12πx=πx=πeinxf(x)dx.C_n = \frac{1}{2\pi} \int_{x=-\pi}^{x=\pi} e^{-inx} f(x) dx.

Again substituting ωt\omega t for xx, we have

Cn=12πωt=πωt=πeinωtf(ωt)d(ωt)C_n = \frac{1}{2\pi} \int_{\omega t=-\pi}^{\omega t=\pi} e^{-in\omega t} f(\omega t) d(\omega t)
Cn=ω2πt=π/ωt=π/ωeinωtf(ωt)d(t)C_n = \frac{\omega}{2\pi} \int_{t=-\pi/\omega}^{t=\pi/\omega} e^{-in\omega t} f(\omega t) d(t)
Cn=2π/T2πt=T/2t=T/2einωtf(t)dtC_n = \frac{2\pi/T}{2\pi} \int_{t=-T/2}^{t=T/2} e^{-in\omega t} f(t) dt
Cn=1Tt=T/2t=T/2einωtf(t)dtC_n = \frac{1}{T} \int_{t=-T/2}^{t=T/2} e^{-in\omega t} f(t) dt

In the last line, I used the fact that f(ωt)f(\omega t) is just f(t)f(t) (with some extra constant). Next, substituting CnC_n into our Fourier series equation and taking the limit of our period to infinity, we have

f(t)=limTn=Cneinωtf(t) = \lim_{T \to \infty} \sum_{n=-\infty}^{\infty} C_n e^{in \omega t}
f(t)=lim2π/ωn=1Tt=t=einωtf(t)dteinωtf(t) = \lim_{2\pi/\omega \to \infty} \sum_{n=-\infty}^{\infty} \frac{1}{T} \int_{t'=-\infty}^{t'=\infty} e^{-in \omega t'} f(t') dt' e^{in \omega t}
f(t)=limω 0n=ω2πt=t=einω(tt)f(t)dtf(t) = \lim_{ \omega  \to 0} \sum_{n=-\infty}^{\infty} \frac{ \omega }{2\pi} \int_{t'=-\infty}^{t'=\infty} e^{in \omega (t-t')} f(t') dt'
f(t)=n=Δ ω2πt=t=einΔ ω (tt)f(t)dtf(t) = \sum_{n=-\infty}^{\infty} \frac{\Delta  \omega }{2\pi} \int_{t'=-\infty}^{t'=\infty} e^{in \Delta   \omega  (t-t')} f(t') dt'

Since n=Δ ω \sum_{n=-\infty}^{\infty} \Delta  \omega  is the Riemann sum, we can change n=Δ ω\sum_{n=-\infty}^{\infty} \Delta  \omega to dω\int_{-\infty}^{\infty} d \omega and ndωnd \omega to ω\omega. The idea of the proof can be found in appendix A.

f(t)=12πω=ω=dω t=t=eiω(tt)f(t)dtf(t) = \frac{1}{2\pi} \int_{ \omega =-\infty}^{ \omega =\infty} d \omega  \int_{t'=-\infty}^{t'=\infty} e^{i \omega (t-t')} f(t') dt'
f(t)=12πω=ω=eiω t(t=t=12πeiω tf(t)dt)dωf(t) = \frac{1}{\sqrt{2\pi}} \int_{ \omega =-\infty}^{ \omega =\infty} e^{i \omega  t} \left( \int_{t'=-\infty}^{t'=\infty} \frac{1}{\sqrt{2\pi}} e^{-i \omega  t'} f(t') dt' \right) d \omega
f(t)=12πω=ω=eiω tfFT(ω)dω,f(t) = \frac{1}{\sqrt{2\pi}} \int_{ \omega =-\infty}^{ \omega =\infty} e^{i \omega  t} f_{FT}( \omega ) d \omega,

where

fFT(ω)=t=t=12πeiωtf(t)dtf_{FT}( \omega ) = \int_{t'=-\infty}^{t'=\infty} \frac{1}{\sqrt{2\pi}} e^{-i \omega t'} f(t') dt'

is the Fourier transform.

Next, we will explain the DTFT and DFT. We will first begin with the DTFT, where DFT can be easily realized. The idea behind the two is quite simple: we can't actually compute continuous functions on a computer, so we need to quantize our data into its discrete representation. Given an incoming input which we call the function f(t)f(t), we can't actually store all the data. Because we know that the input is a continuous value, we have to periodically collect that data and store it on our computer before processing it. So f(t)f(t) is, in fact, a vector of data, not a continuous function. If we want to analyze it using a Fourier transform, it won't work because the Fourier transform we defined above supports a function, not a vector. This is where the DTFT comes in. We want to find a discrete version of the Fourier transformation of our data, which can be easily achieved by quantizing f(t)f(t):

fvec(t)=n=f(t)δ(tntsample).f_{\text{vec}}(t) = \sum_{n=-\infty}^{\infty} f(t) \delta(t-nt_{\text{sample}}).

Substitute this into the Fourier transform equation, we get

fFT(ω)=12πt=t=eiωtf(t)dt12πt=t=eiωtfvec(t)dtf_{FT}( \omega ) = \frac{1}{\sqrt{2\pi}} \int_{t=-\infty}^{t=\infty} e^{-i \omega t} f(t) dt \approx \frac{1}{\sqrt{2\pi}} \int_{t=-\infty}^{t=\infty} e^{-i \omega t} f_{\text{vec}}(t) dt
fDTFT(ω)=12πt=t=eiωtn=f(t)δ(tntsample)dtf_{DTFT}( \omega ) = \frac{1}{\sqrt{2\pi}} \int_{t=-\infty}^{t=\infty} e^{-i \omega t} \sum_{n=-\infty}^{\infty} f(t) \delta(t-nt_{\text{sample}}) dt
fDTFT(ω)=12πn=t=t=eiωtf(t)δ(tntsample)dtf_{DTFT}( \omega ) = \frac{1}{\sqrt{2\pi}} \sum_{n=-\infty}^{\infty} \int_{t=-\infty}^{t=\infty} e^{-i \omega t} f(t) \delta(t-nt_{\text{sample}}) dt
fDTFT(ω)=12πn=f(ntsample)eiωntsamplef_{DTFT}( \omega ) = \frac{1}{\sqrt{2\pi}} \sum_{n=-\infty}^{\infty} f(nt_{\text{sample}}) e^{-i \omega nt_{\text{sample}}}
fDTFT(Ω)=12πn=f[n]einΩ,f_{DTFT}(\Omega) = \frac{1}{\sqrt{2\pi}} \sum_{n=-\infty}^{\infty} f[n] e^{-in\Omega},

where f[n]f[n] is a vector of our data in the time domain, and Ω=ωtsample\Omega = \omega t_{\text{sample}}. Note that ω=2πT\omega = \frac{2\pi}{T}, and we define the new frequency Ω= ωtsample=2πtsampleT\Omega =  \omega t_{\text{sample}} = \frac{2\pi t_{\text{sample}}}{T}. For this frequency Ω\Omega to be intuitive and make sense, tsamplet_{\text{sample}} should live between 0 and TT, 0<tsampleT0 < t_{\text{sample}} \leq T. This shows how often we sample the data. If tsample=Tt_{\text{sample}} = T, it means we sample data every period. Thus, Ω\Omega is defined within any period of 2π2\pi, for example, 0<Ω2π0 < \Omega \leq 2\pi or π<Ωπ-\pi < \Omega \leq \pi.

Finally, we can discuss Discrete Fourier Transforms. You might guess that after quantizing the time domain, we get DTFT, but the result is still a “continuous” function of ω\omega, which again contains infinite values. To make it easy to analyze, we will quantize the frequency domain of the DTFT, and that is DFT! But that is not all; the fact that we derive DTFT from FT means that it is a function that spans the value from -\infty to \infty. DTFT is used with non-periodic functions (we can use it with a periodic one by defining a new function that contains only the value within one period and setting the value outside that range to zero).

Back to DFT. DFT is a Fourier Transform that is defined to work with a periodic function. Why? Because it contains a finite set of data. If we want something useful to analyze, we need data that contain finite elements in both the original domain and the transformed domain. Instead of letting DTFT span from -\infty to \infty in the time domain (a non-periodic function), we want it confined within a specific range and to have NN finite elements in the time domain. From DTFT,

fDTFT(Ω)=12πn=0N1f[n]einΩ.f_{DTFT}(\Omega) = \frac{1}{\sqrt{2\pi}} \sum_{n=0}^{N-1} f[n] e^{-in\Omega}.

Since we want our data to be periodic rather than non-periodic, this means that f[n]f[n] will repeat itself at some point. From our requirements that f[n]f[n] contains NN finite elements, this means that f[N]=f[0]f[N] = f[0]. To analyze only one period, we demand that f[i]=0f[i] = 0 for i{0,1,,N1}i \notin \{0, 1, \ldots, N-1\}.

Nevertheless, the above equation is still a continuous function of Ω\Omega. To quantize it, we sample Ω\Omega at NN equal intervals in the "frequency" domain. Why also NN in the frequency domain as well? NN because, well, IMO it is similar to a basis transformation where you need to preserve the rank of the original vector. In the time domain, you have a vector, and when you transform it to the frequency domain, you want to have the same vector but with a different set of basis. When you divide einΩe^{-in\Omega} into NN equally spaced intervals, it acts as basis functions, and they are orthogonal and become the root of unity.

The uniform interval sampling of the frequency domain gives us Ω=2πkN\Omega = \frac{2\pi k}{N} where k{0,1,2,,N1}k \in \{0, 1, 2, \ldots, N-1\}. Substituting Ω\Omega into fDTFTf_{DTFT}, we get DFT:

fDTFT(2πkN)=fDFT(k)=12πn=0N1f[n]ei2πknN.f_{DTFT}\left(\frac{2\pi k}{N}\right) = f_{DFT}(k) = \frac{1}{\sqrt{2\pi}} \sum_{n=0}^{N-1} f[n] e^{-i \frac{2\pi kn}{N}}.

That is it! We just derived FS, FT, DTFT, and DFT. Below is a great summary:

http://www.dspguide.com/CH8.PDF
http://www.dspguide.com/CH8.PDF

Appendix A

Appendix B

https://www.dsprelated.com/freebooks/mdft/DFT_Derived.html
https://www.dsprelated.com/freebooks/mdft/DFT_Derived.html

References

Subscribe to Fieldlnwza007
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from Fieldlnwza007

Skeleton

Skeleton

Skeleton