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) 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). Thus,
f(x)=n=−∞∑∞Cneinx,
where x∈(−π,π). Use t instead of x and normalize it a bit to ωt, so we get
f(t)=n=−∞∑∞Cneinωt,
where ω=T2π and T is the period. The Fourier series shows the periodic property very clearly. If we shift time by one period T,
Here is my intuition again. In fact, einx is a basis function of a periodic function f(x). To show that einx is a basis, we first have to show that it is:
Linearly independent
Spanning
The first one is quite easy. To show that it is linearly independent, we need to show that given ∑nbneinx=0, then bn=0 for all n∈Z. But we know that for m=n,
because m−n∈Z resulting in sin(integer∗π)=0. For m=n,
∫−ππei(m−m)xdx=2π.
Thus,
∫−ππei(m−n)xdx=δmn2π.
Applying this with
n∑bneinx=0,
we get bn=0 for all n∈Z. For the spanning property, here is the proof from this link. By first assuming that einx spans, then
f(x)=m=−∞∑∞Cmeimx
∫−ππe−inxf(x)dx=m=−∞∑∞∫−ππe−inxCneimxdx
∫−ππe−inxf(x)dx=m=−∞∑∞∫−ππe−inxCneimxdx
Cn=2π1∫−ππe−inxf(x)dx.
The coefficient of the Fourier series Cn is an integral of the original function:
Cn=2π1∫−ππe−inxf(x)dx.
Now substitute Cn into the Fourier series of f(x)
fFS(x)=n=−∞∑∞Cneinx,
we get
fFS(x)=n=−∞∑∞2π1∫−ππe−inyf(y)dyeinx
fFS(x)=2π1∫−ππn=−∞∑∞ein(x−y)f(y)dy.
Here, from appendix A, we have ∑n=−∞∞ein(x−y)≈∫−∞∞ein(x−y)dn. Using the property of the Dirac delta function ∫−∞∞ein(x−y)dn=2πδ(x−y), we get
fFS(x)=2π1∫−ππ2πδ(x−y)f(y)dy=f(x)
The last line implies that a function f(x) is in fact fFS(x), implying that 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 T to ∞.
First, change our Cn into an appropriate form:
Cn=2π1∫x=−πx=πe−inxf(x)dx.
Again substituting ωt for x, we have
Cn=2π1∫ωt=−πωt=πe−inωtf(ωt)d(ωt)
Cn=2πω∫t=−π/ωt=π/ωe−inωtf(ωt)d(t)
Cn=2π2π/T∫t=−T/2t=T/2e−inωtf(t)dt
Cn=T1∫t=−T/2t=T/2e−inωtf(t)dt
In the last line, I used the fact that f(ωt) is just f(t) (with some extra constant). Next, substituting Cn into our Fourier series equation and taking the limit of our period to infinity, we have
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), 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) 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):
fvec(t)=n=−∞∑∞f(t)δ(t−ntsample).
Substitute this into the Fourier transform equation, we get
where f[n] is a vector of our data in the time domain, and Ω=ωtsample. Note that ω=T2π, and we define the new frequency Ω=ωtsample=T2πtsample. For this frequency Ω to be intuitive and make sense, tsample should live between 0 and T, 0<tsample≤T. This shows how often we sample the data. If tsample=T, it means we sample data every period. Thus, Ω is defined within any period of 2π, for example, 0<Ω≤2π or −π<Ω≤π.
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 ω, 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 −∞ to ∞. 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 −∞ to ∞ in the time domain (a non-periodic function), we want it confined within a specific range and to have N finite elements in the time domain. From DTFT,
fDTFT(Ω)=2π1n=0∑N−1f[n]e−inΩ.
Since we want our data to be periodic rather than non-periodic, this means that f[n] will repeat itself at some point. From our requirements that f[n] contains N finite elements, this means that f[N]=f[0]. To analyze only one period, we demand that f[i]=0 for i∈/{0,1,…,N−1}.
Nevertheless, the above equation is still a continuous function of Ω. To quantize it, we sample Ω at N equal intervals in the "frequency" domain. Why also N in the frequency domain as well? N 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 e−inΩ into N 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 Ω=N2πk where k∈{0,1,2,…,N−1}. Substituting Ω into fDTFT, we get DFT: