# Aliasing and square waves

I’m working independently from Ken Steiglitz’s Intro to Signal Processing textbook.

Problem 9 in Chapter 3 asks about the period of a sampled square waveform. I understand that he’s getting to the fact that the “fractional” sampling frequency per wave period has to be accounted for (in the example in the text: 40k sampling frequency and a 700 Hz wave frequency equates to 57 1/7 samples per wave period- making the sampled waveform’s period 7*700Hz).

However, I’m not entirely sure how this periodicity is reflected in the spectrum of the square wave. I can’t seem to explain the connection between how this alteration of sampled frequency vs original frequency attributes to the aliasing, resulting in some of the ‘extraneous’ frequencies present in the spectrum. Any hints?

## 1 Answer

So the sampled wave period is actually $$\frac{7}{700 \mathrm{Hz}} = \frac{1}{100 \mathrm{Hz}}$$ -- I assume that's just a typo on your part.

There's a principle in Fourier analysis that sometimes people miss. It's that Fourier invented this stuff to make life easy -- so if it's harder to do it in the frequency domain just do it in the time domain.

For example, I can work out the $$40000 = (57 \frac 1 7)(700)$$ bit in my head, so I know that sampling almost anything with a period of $$T = \frac 1 {700 \mathrm{Hz}}$$ at 40000Hz is going to have a period of 10ms.

Now that we've used the easy way (the time domain) to assure ourselves what we're going to find in the frequency domain, the imprecise answer is that a square wave at $$700 \mathrm{Hz}$$ has only odd harmonics; i.e., there's harmonics at $$(700 \mathrm{Hz})n\ \forall\ n \in \mathrm{odd}$$. When you sample, the source spectrum will appear, as well as all possible shifted versions of it, shifted on intervals of $$40000 \mathrm{Hz}$$. This means that every possible frequency $$f = (700 \mathrm{Hz})n + (40000 \mathrm{Hz})m\ \forall\ n \in \mathrm{odd},\ m \in \mathbb I \tag 1$$ is in there.

Because the greatest common divisor of $$700 \mathrm{Hz}$$ and $$40000 \mathrm{Hz}$$ is $$100 \mathrm{Hz}$$, we know that the only possible values of $$f$$ are ones divisible by $$100 \mathrm{Hz}$$. This is the spectrum of a wave that repeats every 10ms.

So in the frequency domain we've worked out something with a lot of shaky math, some handwaving, and some brain cell curling messing around with integers just to find out something we could reason out in two seconds in the time domain. But at least we have the satisfaction of knowing that the time domain and frequency domain agree, and so the DSP world has not gone mad.