Lab · Lesson 4
An FFT by hand
Derive the FFT from the Fourier series, line by line, then solve two examples on a calculator: real and imaginary parts, size, phase and the mirror.
Read the whole lesson as notes · every step, derivation and worked example, on one page
1Goal Where we are going
An analyser turns 8, 1024 or 65 536 samples into a spectrum. This lesson derives the formula it uses, from scratch, the way you would in a maths class.
Then we solve two examples on a calculator, every operation written out, and you try one yourself.
By the end of this lesson we will have derived, line by line, the formula an FFT computes for every frequency bin:
and what its two parts mean for a vibration: the real and imaginary parts, the size you read on an analyser, and the phase.
Then we use it twice on a calculator, with every operation shown.
2What we already know The tools
Four facts carry the whole derivation: the Fourier series (1), three product-to-sum identities (2)–(4), zero net area over whole cycles (5)–(6), and Euler’s formula (7).
On the board: any whole number of cycles has as much area above the line as below. Change the number of cycles.
As we know, any signal that repeats every seconds can be written as a Fourier series: a constant plus cosines and sines at whole multiples of the running speed:
From trigonometry, a product of two cosines or sines turns into a sum:
Over one period, a whole number of cosine or sine cycles has zero net area (the board shows it):
And for , and :
Finally, Euler’s formula:
3Derivation Orthogonality
The key fact: multiply two different harmonics and the result has zero net area over a period. Multiply a harmonic by itself and you get .
Set and on the board. The orange curve is their product; the green and red areas cancel unless .
Take two harmonics, and (whole numbers, both at least 1), and integrate their product over one period. Using (2) with , :
, so the second integral is 0 by (5). The first is also 0 by (5), unless : then it is , which gives by (6). So
Exactly the same steps with (4) and (3):
This is called orthogonality: two different harmonics, or a sine and a cosine, multiply to zero net area. Only a harmonic times itself survives.
4Derivation Picking out one harmonic
Multiply the whole signal by and integrate. By orthogonality, every harmonic except the th drops out, which leaves .
On the board, the signal from example 1 times or . The net area, times , is the coefficient.
Multiply both sides of (1) by , for one chosen , and integrate over one period:
Term by term: the term is 0 by (5). Every term is 0 by (11). Every term is 0 by (9), except , which gives :
Divide both sides by :
Multiplying (1) by instead, (10) and (11) leave only :
And integrating (1) as it is, (5) removes every harmonic and (6) leaves :
5Derivation One complex number
Euler’s formula combines the cosine integral and the sine integral into one complex number, . Its real part is half of ; its imaginary part is minus half of .
Written as one cosine, , the harmonic’s size is twice the arrow’s length and its phase is the arrow’s angle.
That is two integrals per harmonic. Euler’s formula packs them into one complex number. Define
Substitute from (7) with , and split the integral:
Compare with (14) and (15): is half of , so each integral is half a coefficient:
Now the size and the phase. Write the th harmonic as one cosine with amplitude and phase , and expand it with :
Match the cosine and sine terms with in (1):
Square and add (using ), then divide the second by the first, and compare with (19):
6Derivation From the integral to a sum
An analyser has samples, not a curve. Replace the integral by thin rectangles, one per sample, and it becomes the DFT, the formula every FFT computes.
On the board, the area under and the 8 rectangles give the same answer.
An analyser never has the curve, only samples. Take equally spaced samples in one period:
In (17), the integral becomes a sum of thin rectangles, each wide:
The ’s cancel, and from (1):
If every harmonic in the signal lies below , sampled sines and cosines are orthogonal too, and (25) gives exactly the same as the integral.
Split (25) with (7), as in (18), into two sums you can do on a calculator, with :
7Derivation Why half is a mirror
Bin is bin wound the other way: the complex conjugate. It carries no new information, so analysers drop the top half and double the rest.
Slide through the bins: 7 mirrors 1, 6 mirrors 2.
What about the bins above ? Put in (25) and split the exponent:
is a whole number, so by (7) :
The samples are real, so this is (25) with the sign of flipped: the complex conjugate.
So the top half adds nothing new. Each harmonic’s size is shared between and its mirror, which is why the peak is in (22). Bin 0 is its own partner, so it is not doubled: by (16) and (17), .
8What it means Wind the samples
Equation (25) as a picture. Each sample becomes an arrow at angle , and the orange dot is their average: .
Try and (the signal has those), then (it doesn’t).
Read (25) as a picture: each sample becomes an arrow of length at angle , and is the average of the arrows (the orange dot).
When matches a harmonic in the signal, the arrows pile up on one side and the dot moves out. Otherwise orthogonality, (9) to (11), makes them cancel.
9Worked example 1 Take the samples
A signal with a 1X part (cosine and sine) and a 2X cosine. Sample it 8 times per turn, at 45° steps.
Every sample is worked out in full below the board.
Worked example 1. Find the spectrum of
Use . By (23), : steps of 45°.
Put each angle into (31): . Every operation (4 decimal places):
10Worked example 1 Bin 1, by hand
Multiply each sample by and , add the columns, divide by 8. Out come the real and imaginary parts, then the size and the phase.
The board shows the same result as the average of 8 arrows.
Bin . Multiply each sample by and by :
Add each product column, term by term:
Divide by using (26) and (27). Mind the minus sign in (27):
The size, by (22):
The phase, by (22). Re is positive and Im is negative, so the arrow is in the fourth quadrant and the calculator’s answer is the right one:
Check with (19), using from (31):
So the 1X part of (31) is : size from (37), timing from (38).
11Worked example 1 Bins 2, 3 and 7
Bin 2 finds the 2X cosine. Bin 3 finds nothing, because the products cancel. Bin 7 needs no work at all: it is the mirror of bin 1.
Slide through all eight bins.
Bin : the angles are now , steps of 90°.
Bin : steps of 135°. There is no 3X in (31), so the products cancel, exactly as orthogonality (9) to (11) says:
Bin : no need to add anything up. By the mirror rule (30), with (36):
The one-sided spectrum an analyser shows: a peak of 1.0 at 1X with phase −53.13°, and 0.5 at 2X with phase 0°.
12Worked example 2 An offset and a phase
This time the signal comes as an amplitude and a phase, plus a small offset, the way a sensor often reads. First rewrite it in the form (1), then sample it.
Worked example 2. A sensor with a small offset reads
This is not yet in the form (1). Expand with :
So, before doing any sums, (19) and (16) predict
Sample at the angles (32): . Every operation:
13Worked example 2 Bins 0 and 1
Bin 0 is just the average: the offset. It has no mirror, so it isn’t doubled. Bin 1 gives back the size 2.0 and the phase −60°.
Bin : every angle is 0, and , so (26) is just the average of the samples:
Bin :
Size and phase by (22). Fourth quadrant again (Re > 0, Im < 0):
Both match (44): from 8 numbers the FFT recovers the offset 0.4, the 1X size 2.0 and the phase −60°. ✓
14Your turn Try it with a calculator
Your turn. In the interactive lesson above, this step gives you a new signal each time, checks your answers and writes out the full working, line by line.
15Summary On one card
Four boxed results, each derived above: the DFT, what its real and imaginary parts are, how size and phase come out of it, and why half of it is a mirror.
Next lesson: what happens when the signal doesn’t fit a whole number of times in the record. That is leakage.
Everything in this lesson on one card:
Size tells you how much. Phase tells you where and why.