Fourier Analysis

Fourier Transforms Introduction

The Fourier Transform applies to continuous functions or discrete data can provide useful insights and tools for many applications

Basic Idea

  1. Transform some function/data into a form that reveals frequencies of information in the data
  2. Process/analyse it it in this “frequency domain” form
  3. Transform back again
    The original data/function is said to be in the…
Convert time or space-dependent data into the representation

f(t)=a0+a1cos(qt)+b1sin(qt)+a2cos(2qt)+b2sin(2qt)

i.e. infinite sum of increasingly high frequency sine/cosines
Could view this as:

  • a weird (non-polynomial) interpolation problem:
    • what coefficients let us fit the particular summation form to a given function?
  • an expansion/approximation of the function as an infinite sum of sines/cosines
    • e.g. compare to Taylor series

Main topics:

Continuous Fourier Series

Consider some continuous periodic function f(t) with period T, so$$f(t\pm T) = f(t)$$i.e., f repeats after one length/period T.
e.g. sin(2πktT) or cos(2πktT) satisfy this for all integers k

cos(2πk(t+T)T)=cos(2πktT+2kπ)=cos(2πktT)

Goal is to represent any f(t) as an infinite sum of trig functions:$$f(t) = a_0 + \sum_{k=1}^{\infty}a_k\cos(\frac{2\pi kt}{T})+\sum_{k=1}^{\infty}b_k\sin(\frac{2\pi kt}{T})$$ak,bk indicate the ”information”/amplitude for each sinusoid of a specific period Tk or frequency kT

Determining the Coefficients

Assume for now that t[0,2π] and period T=2π
Then we have$$f(t) = a_0 + \sum_{k=1}^{\infty}a_k\cos(kt)+\sum_{k=1}^{\infty}b_k\sin(kt)$$

Handy Identities (Orthogonality)

02πcos(kt)sin(jt)dt=0for any integers k,j

i.e. the integral of the product of cos(kt) and sin(jt) over [0,2π] is 0.
We say these two functions are orthogonal to each other

More Orthogonality Relations

02πcos(kt)cos(jt)dt=0for kj02πsin(kt)sin(jt)dt=0for kj02πsin(kt)dt=002πcos(kt)dt=0

We can use these to extract a single Fourier coefficient at a time!

Example

Determining coefficient a0

We want $$f(t) = a_0 + \sum_{k=1}^{\infty}a_k\cos(kt)+\sum_{k=1}^{\infty}b_k\sin(kt)$$Integrate over [0,2π] to use some of our orthogonality identities:

02πf(t)dt=a002πdt+k=1ak02πcos(kt)dt+k=1bk02πsin(kt)dt

Therefore:

a0=02πf(t)dt02πdt=12π02πf(t)dt

i.e., a0 is the average value of f over [0,2π]

Determining coefficient al (for integer l>0)

Again start with$$f(t) = a_0 + \sum_{k=1}^{\infty}a_k\cos(kt)+\sum_{k=1}^{\infty}b_k\sin(kt)$$Multiply by cos(lt) and integrate over [0,2π]

02πf(t)cos(lt)dt=02πa0cos(lt)dt+k=1ak02πcos(kt)cos(lt)dt+k=1bk02πsin(kt)cos(lt)dt

The result is 0 except when k=l. Hence, $$\int_0^{2\pi}f(t)\cos(lt)dt =a_l\int_0^{2\pi}\cos^2(lt)dt=a_l\pi$$
Thus, $$a_l = \frac{1}{\pi}\int_0^{2\pi}f(t)\cos(lt)dt$$

Summary

So if we have f, we can find all the coefficients by solving integrals

a0=02πf(t)dt02πdt=12π02πf(t)dtak=02πf(t)cos(kt)dt02πcos2(kt)dt=1π02πf(t)cos(kt)dtbk=02πf(t)sin(kt)dt02πsin2(kt)dt=1π02πf(t)sin(kt)dt
How does phase of the sinusoids come in?

A sine is a translated cosine! All “in-between” shifts are just linear combinations of sin/cos

Complex Number Review

For zC, we write z=a+bi where the imaginary number i=1
Visualized as points on the complex plane (a,b):

Using Euler’s Formula

We will find Euler’s formula very useful:

eiθ=cos(θ)+isin(θ)

Also$$e^{-i\theta} = \cos(-\theta) + i\sin(-\theta) = \cos(\theta)-\sin(\theta)$$Adding/subtracting these lead to two key identities:

cos(θ)=eiθ+eiθ2sin(θ)=eiθeiθ2

Fourier Series with Complex Exponentials

Now, given our earlier sinusoidal expression of a function f(t)$$f(t) = a_0 + \sum_{k=1}^{\infty}a_k\cos(kt)+\sum_{k=1}^{\infty}b_k\sin(kt)$$we can express it more concisely as$$f(t)=\sum_{k=-\infty}^{+\infty}c_ke^{ikt}$$where the ck coefficients are complex numbers
There exists a simple conversion: ckak,bk

Finding ck coefficients

We can also find ck directly, similar to what we did for ak and bk
The corresponding orthogonality property is:$$\int_0^{2\pi}e^{ikt}e^{-ikt}=\begin{cases}0; k\neq l\2\pi; k=l\end{cases}$$from which we can determine the coefficient formula,$$c_k=\frac{1}{2\pi}\int_0^{2\pi}e^{-ikt}f(t)dt$$

Truncating

An approximation of a function could be achieved by truncating the series to a finite number of sinusoids:$$f(t)\approx\sum_{k=-M}^{+M}c_ke^{ikt}$$

Discrete Input Data

Consider now a vector of discrete data

DFT as Interpolation

We have N=128 points, and period T=32
For N points, we will use N degrees of freedom (i.e N coefficients) to exactly interpolate the data
Assuming N is even, we can approximate with a truncated Fourier series as:

f(t)\approx\sum_{-\frac{N}{2}+1}^{N/2}c_ke^{\frac{(2\pi i)kt}{T}}$$If $T=2\pi$, then we will have the simplified version of it as $f(t)\approx\sum_{-\frac{N}{2}+1}^{N/2}c_ke^{ikt}$ Plugging in each of our $N$ data points $(t_n, f_n)$ into the expression will give us $N$ **equations**, involving **unknowns coefficients, $c_k$** This will lead towards our Discrete Fourier Transform ## Discrete Fourier Transform For notational convenience we defined:$$W = e^{\frac{2\pi i}{N}}$$$W$ is an **$N$th Root of Unity**, since it satisfies$$W^N = e^{2\pi i} = 1$$So$$f_n = \sum_{k=0}^{N-1}F_ke^{i(\frac{2\pi n k}{N})} = \sum_{k=0}^{N-1}F_kW^{nk}$$Discrete data $f_n$ is expressed as a sum of coefficient, $F_k$, times complex exponentials, $W^{nk}$ ### Roots of Unity With $W = e^{\frac{2\pi i}{N}}$, then $$W^k = e^{\frac{2\pi ik}{N}}$$are also **Nth roots of unity,** for all integers $k$ For example: * for $N=3$, the roots of unity have the form $W^k = e^{k(\frac{2\pi i}{3})}$ * for $N=8$, the roots of unity have the form $W^k = e^{k(\frac{2\pi i}{8})}=e^{k\frac{i \pi}{4}}$ #### Complex Plane ![Pasted image 20250422165915.png](/img/user/assets/Pasted%20image%2020250422165915.png) **Each Nth root** corresponds to a point on the unit circle, in the complex plane Let $\theta = \frac{2\pi k}{N}$, then$$W_k = e^{i\theta} = \cos\theta + i\sin\theta$$Modulus is always 1, since $\sqrt{\cos^2\theta + \sin^2\theta} = 1$ ### Discrete Fourier Transform To be useful, operations we need are: 1. Convert input time-domain data $f_n$ to frequency-domain $F_k$ 2. Convert **frequency-domain data $F_k$** back to time-domain $f_n$ We derived #2; given Fourier coefficients $F_k$, we have: $$f_n = \sum_{k=0}^{N-1}F_kW^{nk}

What about #1? How can we solve for the Fk=???

Another Orthogonality Idea

To find Fk, we’ll need another useful property of our Nth roots of unity:

j=0N1WjkWjl=k=0N1Wj(kl)=Nδk,l$$assuming(fornow)that$k,l[0,N1]$Thesymbol$δk,l$indicatestheKroneckerdeltafunctiondefinedby:$$δk,l={0;kl1;k=l

A Discrete Fourier Transform (DFT) pair

Inverse DFT:$$f_n = \sum_{k=0}^{N-1}F_kW^{nk}$$
DFT:$$F_k=\frac{1}{N}\sum_{n=0}^{N-1}f_nW^{-nk}$$The Discrete Fourier Transform is invertible

Two Properties of the DFT

As consequences of the properties of Nth roots of unity…

  1. The sequence {Fk} is doubly infinite and periodic
    • i.e. If we allow k<0 or k>N1, the Fk coefficients repeat
  2. Conjugate symmetry: if data fn is real, Fk=FNk
    Hence, the |Fk| are symmetric about k=N2

Power/ Fourier Spectrum

The power spectrum visualizes the Fourier coefficients by plotting their moduli/magnitudes |Fk|:
Pasted image 20250422183354.png
This expresses the magnitude of the frequencies, but ignores phase

Discrete Data - Observations

Coefficient F0 is always the average of data values, F0=1Nn=0N1fn

The Fourier (Fk) plots are symmetric, since the data was real

Fast Fourier Transform

Making Fourier Transforms Fast

Questions:

Slow Fourier Transform

A direct implementation of Fk=1Nn=0N1fnWnk takes O(N2) complex floating-point operations
Essentially two nested for loops:
Pasted image 20250422185249.png

A Faster Fourier Transform

Design a divide and conquer strategy

  1. Split the full DFT into two DFT’s of half the length
  2. Repeat recursively
  3. Finish at the base case of individual numbers
    (If N2m for some m, we can pad our initial data with zeros)
Dividing it up

We can express the usual DFT with two new arrays of half the length (N/2):

gn=12(fn+fn+N2)$$$$hn=12(fnfn+N2)Wn

where n[0,N21].
Then, Feven=G=DFT(g) and Fodd=DFT(h).

Visualizing - A Butterfly Operation

We can think of each step as taking a pair of numbers and producing two outputs:
Pasted image 20250422190321.png

Big Picture - Recursive Butterfly FFT Algorithm

Pasted image 20250422190428.png
N=8=23, so we have 3 recursive stages
Note: Coefficient output order is scrambled
Pasted image 20250422190751.png

Is it actually faster?

Inverse Fast Fourier Transform

Consider the generic expression: $$f'k=\frac{1}{N}\sum^{N-1}f_nU^{nk}$$If U+W1, this is our forward DFT

Fourier Application: Image Data/Compression

1D Grayscale Image

We can think of a 1D array of grayscale values as a 1D image

Processing 1D Images

For greyscale images, we can perform a DFT on the pixels’ intensity/grey values
Pasted image 20250422194813.png
Notice: Plot is only the first 16 coefficients, since real data implies conjugate symmetry

Compression Strategy
Comparison

Pasted image 20250422195707.png
Recovered “image” hopefully has small deviations from the original “true” data

Image Processing in 2D

Pasted image 20250422195824.png

How does the DFT work for 2D (greyscale) image data?

We apply a 2D extension of the DFT definition to the data, like so:

Fk,l=1NMn=0N1j=0M1fn,jWNnkWMjl

Essentially two standard (1D) DFT’s combined.
Two (possibly distinct) roots of unity are used, one per dimension:

WN=e2πiN and WM=e2πiM

Result is a 2D array of Fourier coefficients, Fk,l

2D Fast Fourier Transform

Pasted image 20250422200410.png
The 2D FFT can be computed efficiently using nested 1D FFTs:

  1. Transform each row (separately) using 1D FFTs
  2. Transform each column on the result, again using 1D FFTs
Complexity

Performing M 1D FFT’s of length N: M×O(Nlog2N)=O(MNlog2N)
Performing N 1D FFT’s of length M: N×O(Mlog2M)=O(MNlog2M)
So total complexity is O(MN(log2M+log2N))

Block-based Image Compression

Pasted image 20250422200752.png
Often an image is subdivided into smaller blocks: 16×16 or 8×8 pixels

Fourier Application: Understanding Aliasing

Sampling of Signals: Aliasing

If a real input signal contains high frequencies, but the spacing of our discretely sampled data points is inadequate, aliasing can occur
Pasted image 20250422202037.png
A truly high frequency signal (red) aliases as a lower frequency signal (blue) in the discrete result

Takeaway

Our DFT coefficients Fk are sums of true continuous Fourier series coefficients ck of increasing frequency:

Fk=ck+ck+N+ckN+ck+2N+ck2N+

Hence, high frequencies from ck[N2+1,N2] in the real signal contribute to (“alias as”) low frequency Fk for k[N2+1,N2].

Nyquist Frequency

If the original continuous signal has frequencies ck0 for |k|>N2 those frequencies “alias” to a lower frequency

Treating Aliasing

Two (partial) solutions:

Example:

Digital Cameras often have optical lowpass filters or anti-aliasing filters that physically blur the incoming light, before it hits the image sensor