Understanding the Fourier Transfrom

Fundamental Principles

Part 1 (sine waves only)

If you want to know how much of a particular sine wave (with phase zero) contributes to a signal, just multiply the signal by the sine wave at each point, and then add up the area under the curve. To note, we are only considering a standard sine wave with no phase shift (we only choose the frequency).

Green and red areas would cancel out if the sine wave at a specific frequency makes no contribution.Here the sine wave makes full contribution, as the original signal is a sine wave itself.Size of the non-zero area tells us the relative amplitude of that frequency sine wave in the signal.

The sine wave we multiply the signal with has an amplitude of just one. The summed green area would tell us what amplitude this sine wave actually contributes.

Question. If the sine wave and signal match exactly with only green area, shouldn’t integral sum to infinity? Answer: You’re right. FT only converges for finite signals.

Repeat process for all frequencies of sine waves.

Part 2 (cosine waves)

So far, we’ve only multiplied by sine waves. However, this wouldn’t be complete.

If we had a cosine wave signal, there is no sine wave (no phase shift) that makes a contribution to the signal.

This means we have to multiply the signal by a sine wave and a cosine wave, and find amplitude contributions for each. The above diagram shows a cosine signal (blue) being multiplied by a sine and cosine signal (yellow and red). The red wave results to zero, meaning no contribution from the sine wave, and the yellow wave makes full contribution. This is reflected in the equation, with amplitude 1 and 0.

Now what if the blue signal is shifted?

Both the red sine wave and yellow cosine wave make contributions. The ratio of their contributions is the phase of the original signal.

Remember the identity:

acos(x)+bsin(x)=Rsin(x+θ)a \cos(x) + b \sin(x) = R \sin(x + \theta)

where:

- R=a2+b2R = \sqrt{a^2 + b^2}

- θ=tan1(ab)\theta = \tan^{-1}\left(\frac{a}{b}\right)

Multiplying by both a sine and cosine wave, we can capture the contribution of a sinusoidal wave of any phase.

To create the frequency spectrum for this example, we simply take RR as the amplitude at a frequency ff. This also means that two identical signals with different phases would have the same frequency spectrum, but have different phase diagrams.

Final Part

The following quote is from the start of this document,

If you want to know how much of a particular sine wave (with phase zero) is in a signal, just multiply the signal by the sine wave at each point, and then add up the area under the curve. To note, we are only considering a standard sine wave with no phase shift (we only vary the frequency).

- Me

Now we can say instead, that if we want to know how much of a sine wave of a specific frequency with a phase shift is in a signal, just multiply the signal by a sine wave and a cosine wave at each point. The ratio of the contributions determines the contribution of a particular sine wave with a particular phase shift.

Quite conveniently, we have Euler’s formula:

cos(2πft)+isin(2πft)=ei2πft\cos(2\pi ft) + i\sin(2\pi ft) = e^{i2\pi ft}

We only need to multiply the signal by an exponential, where the real part of the sum is the cosine amplitude, and the imaginary part is the sine amplitude.

Recap

  • It is possible to break a signal down into a sum of sine waves, with each wave having it’s own amplitude, frequency and phase.

  • We do this by first specifying a frequency of wave we want to test, then multiplying the signal by a sine and cosine of that frequency. From this, we can find the contribution of the wave and it’s phase shift.

  • Consider the following formula:
    acos(2πft)+bsin(2πft)=Rsin(2πft+θ)a\cos(2\pi ft)+b\sin(2\pi ft)=R\sin(2\pi ft+\theta)

    aa and bb are the contributions we learn from the integration sum for each wave.

    θ\theta is the phase shift of the wave we are testing.

    RR is the contribution of that wave.

  • We’ve now found the contribution of a specific frequency wave, as well as it’s phase. All that’s left to do is plot the contribution in a frequency spectrum.

We can derive an equation that will give us the contribution and phase of a sinusoid of any frequency ww. We do this using…

The Fourier Transform

Continuous-Time Fourier Transform (CTFT)

Given a continuous-time signal x(t)x(t):

X(jω)=x(t)ejωtdtX(j\omega) = \int_{-\infty}^{\infty} x(t) \cdot e^{-j\omega t} \, dt

We multiply the signal by a sine and cosine of frequency ww, and then integrate to find the contribution of a sinusoid of frequency ww. This is exactly what we are trying to do!

Plotting the magnitude of X(jω)X(j\omega) gives us the frequency spectrum.

Now, what if the signal was discrete…

Discrete Time Fourier Transform

The immediate analogy for the Fourier Transform in the discrete domain is the Discrete Time Fourier Transform, where tt is replaced with nn, the sample number. The output is a continuous periodic spectrum. The transform works identically to the standard Fourier, but now only multiplying and integrating over sampled points.

Discrete Time Fourier Transform:

X(ejω)=k=x[k]ejωkX(e^{j\omega})=\sum_{k=-\infty}^{\infty}x[k]e^{-j\omega k}

  • Input: Discrete-time signal, potentially of infinite length

  • Output: Continuous function of frequency, defined for all ω[π,π]\omega \in [-\pi, \pi]

    • The output is periodic with period

    • This is like typical sampling shown in Image Processing

Discrete Fourier Transform

In reality, discrete signals have a finite duration. We take a different approach to computing the spectrum, treating the finite samples as periodic and representing the spectrum as a combination of harmonic frequencies.

As the samples are finite (and further considered periodic), we only need a finite number of frequencies to represent the signal. The reason why we have to consider the samples as periodic is because a finite set of frequencies will always produce a periodic signal when summed. This in contrast to the ideal frequency spectrum for an infinite signal, that would require an infinite number of frequencies to completely reconstruct.

Harmonic Frequencies

The lowest frequency measurable in a finite set of samples is the frequency equal to the duration of the signal.

Higher detectable frequencies are just integer multiples of this fundamental frequency.

The maximum measurable frequency is limited by the number of samples.

The total number of frequencies we use to represent the signal is equal to the number of samples in the signal, NN.

There are 8 samples in this signal, so we use 8 harmonic frequencies representing the signal.

Here we multiply by the DC value (1 in this case) and then integrate. This sums to zero, so there is no DC offset/contribution.

Now we look at the lowest frequency. We multiply by a sine and cosine of the same frequency and integrate to find the contribution of this frequency.

Continue doing this for each frequency multiple. Now you have the discrete frequency spectrum.

DFT Equation

Now we must represent this mathematically.

Discrete Fourier Transform:

X[n]=k=0N1x[k]ej2πnNk,n=0,1,...,N1X[n]=\sum_{k=0}^{N-1}x[k]e^{-j2\pi\frac{n}{N}k},\quad n=0,1,...,N-1

  • Input: Finite-duration discrete-time signal of length NN

  • Output: Finite set of NN complex numbers representing frequency samples

    • X[n]X[n], where n=0,1,...,N1n = 0, 1, ..., N-1

    • These are coefficients or contributions of the harmonic frequencies.

There are two indexes, kk and nn:

  • kk refers to the discrete sample in x[k]x[k] and is also the discrete analogy for tt.

    • The analogy explains why kk appears in the exponential. Standard form for a sinusoid:cos(wt)=cos(2πft)=cos(2πtT)=cos(2π1Nnfrequency f or 1Tktime t)ej2πnNk\cos\left(wt\right)=\cos\left(2\pi ft\right)=\cos\left(2\pi\frac{t}{T}\right)=\cos\left(2\pi\cdot\underbrace{\frac{1}{N}\cdot n}_{\text{frequency }f\text{ or }\frac{1}{T}}\cdot\underbrace{k}_{\text{time }t}\right)\Rightarrow e^{-j2\pi\frac{n}{N}k}

    • nn refers to the harmonic frequency/coefficient number.

For example, to find the coefficient for the second harmonic frequency, you would set n=2n=2 in the equation, then sum from k=0k=0 to k=N1k=N-1 (since we have NN samples and the first sample is indexed at 0).

The equation multiplies the signal by a harmonic frequency at discrete points on the wave, then integrates (sums) to find the contribution.

Frequency of the first harmonic is f1=1Nf_1=\frac{1}{N}, and for nth harmonic,fn=nNf_{n}=\frac{n}{N} , up to N1N-1 (Nth frequency would be the same as the first harmonic). These can be represented on a unit circle in angular frequency (radians), ωn=2πnN\omega_{n}=2\pi\frac{n}{N}.

Angular frequency harmonics on unit circle

Example

x[k]={1,2,3,4}x[k] = \{1, 2, 3, 4\}, N=4N = 4

Compute X[0]X[0] (DC coefficient):

X[0]=k=03x[k]ej2π40k=k=03x[k]1=1+2+3+4=10X[0] = \sum_{k=0}^{3} x[k] \cdot e^{-j \cdot \frac{2\pi}{4} \cdot 0 \cdot k} = \sum_{k=0}^{3} x[k] \cdot 1 = 1 + 2 + 3 + 4 = 10

Compute X[1]X[1] (coefficient for first harmonic):

X[1]=k=03x[k]ej2π41k=x[0]1+x[1]ejπ2+x[2]ejπ+x[3]ej3π2X[1] = \sum_{k=0}^{3} x[k] \cdot e^{-j \cdot \frac{2\pi}{4} \cdot 1 \cdot k} = x[0] \cdot 1 + x[1] \cdot e^{-j\frac{\pi}{2}} + x[2] \cdot e^{-j\pi} + x[3] \cdot e^{-j\frac{3\pi}{2}}

Each exponential in this sum is basically a sampled point on the harmonic we are testing. Imagine the kk was tt, and the integral was with respect to tt , multiplying each point on the sine with the signal.

X[1]=1+2(j)+3(1)+4(j)=12j3+4j=(2)+2jX[1] = 1 + 2(-j) + 3(-1) + 4(j) = 1 - 2j - 3 + 4j = (-2) + 2j

X[1]=2+2jX[1] = -2 + 2j

Imagine the kk in the exponential is analogous to tt but only at discrete points. This is to multiply discrete points on the sinusoid with discrete signal samples.

Compute X[2]X[2]:

X[2]=k=03x[k]ej2π42kX[2] = \sum_{k=0}^{3} x[k] \cdot e^{-j \cdot \frac{2\pi}{4} \cdot 2 \cdot k}

We calculate each exponential term:

- ej2π420=e0=1e^{-j \cdot \frac{2\pi}{4} \cdot 2 \cdot 0} = e^{0} = 1

- ej2π421=ejπ=1e^{-j \cdot \frac{2\pi}{4} \cdot 2 \cdot 1} = e^{-j\pi} = -1

- ej2π422=ej2π=1e^{-j \cdot \frac{2\pi}{4} \cdot 2 \cdot 2} = e^{-j2\pi} = 1

- ej2π423=ej3π=1e^{-j \cdot \frac{2\pi}{4} \cdot 2 \cdot 3} = e^{-j3\pi} = -1

So:

X+x+x[3](1)=12+34=2X + x + x[3](-1) = 1 - 2 + 3 - 4 = -2

X[2]=2X[2] = -2

Compute X[3]X[3]:

X[3]=k=03x[k]ej2π43kX[3] = \sum_{k=0}^{3} x[k] \cdot e^{-j \cdot \frac{2\pi}{4} \cdot 3 \cdot k}

Evaluate each term:

- ej2π430=e0=1e^{-j \cdot \frac{2\pi}{4} \cdot 3 \cdot 0} = e^{0} = 1

- ej2π431=ej3π2=je^{-j \cdot \frac{2\pi}{4} \cdot 3 \cdot 1} = e^{-j\frac{3\pi}{2}} = j

- ej2π432=ej3π=1e^{-j \cdot \frac{2\pi}{4} \cdot 3 \cdot 2} = e^{-j3\pi} = -1

- ej2π433=ej9π2=je^{-j \cdot \frac{2\pi}{4} \cdot 3 \cdot 3} = e^{-j\frac{9\pi}{2}} = -j

Now substitute:

X[3]=1+2(j)+3(1)+4(j)=1+2j34j=(2)2jX[3] = 1 + 2(j) + 3(-1) + 4(-j) = 1 + 2j - 3 - 4j = (-2) - 2j

X[3]=22jX[3] = -2 - 2j

Final DFT Result:

X[0]=10X[0] = 10

X[1]=2+2jX[1] = -2 + 2j

X[2]=2X[2] = -2

X[3]=22jX[3] = -2 - 2j

Questions

Why is the frequency spectrum of am infinite aperiodic discrete signal, continuous and periodic?

Answer: Go back to image processing and read how sampling a signal in time domain is like multiplying with a comb function, and in the frequency domain, this is like convolving with the Fourier Transform of the comb function, which repeats the spectrum.