# I don't understand harmonics, why do they happen?

I don't understand why harmonics occur in signals. So if I receive a time domain sinusoidal signal at 10 Hz and I perform the FFT of it, I will observe peaks at 10 Hz, 20 Hz, 30 Hz, and so on... with amplitudes decreasing, but why? Should it just not be one peak at 10 Hz?

For e.g. if I was to synthesize the time domain signal with this frequency graph, would I not then have now a sine wave of 10 Hz, 20 Hz, 30 Hz, etc. added up together when it should just be a sine wave at 10 Hz?

Maybe I haven't worded the question correctly, but hopefully, someone could try understand and lead me to some resources to help get my head around harmonics in general...

• What is your 10Hz time domain signal? Is it a pure sine wave, or is it something else? If it's not a pure sine wave, what do you mean by "at 10 Hz" -- do you mean it repeats itself every 1/10th of a second? Nov 13, 2019 at 21:01
• Is the received signal a sine wave or square? Nov 13, 2019 at 21:02
• sorry edited it, it is a sine wave Nov 13, 2019 at 21:10

There are two interpretations of the term harmonics here.

The first refers to the Fourier series expansion of a periodic signal $$x(t)$$ with a fundamental period of $$T_0$$ seconds and a fundamental frequency of $$f_0 = 1/T_0$$ in Hz.

In this representation, the harmomics family of sine waves at the frequencies of $$f_0$$, $$2f_0$$, $$3f_0$$,... are assumed to make up (sum up) a given periodic waveform with a fundamental frequency of $$f_0$$. The harmonic family has the property that each member is also periodic with the fundamental period $$T_0$$. So if a non-harmonic frequency sine wave is assumed to exist in the sum, it would violate the fact that the linear combination sum of all of the sine waves must also be periodic with $$T_0$$. So only the harmonic family satisfies this condition. The particular weights of each harmonic member depends on the partical signal waveform and for a pure sine wave only the harmonic at its own frequency would exist; which is the fundamental for a single sine wave.

The second interpretation is that given a pure sine wave, if you process this signal with a nonlinear device, then it will add harmonics of this sine wave at the output. And these harmonics of the input frequency result from the mathematical expression of the nonlinearity operarion. Depending on the nonlinearity type, (or the process type) they may produce in-harmonic contributions as well.

Harmonics "happen" when your input to an FFT isn't a pure unmodulated sine wave.

Any unexpected distortion in your input waveform generation (from being exactly identical to mix of sin(wt) + cos(wt)) can be the cause of harmonics appearing in an FFT result (above the noise floor and any windowing artifacts).

Those harmonics are required to represent the energy of any differences whatsoever between a periodic signal and a perfect sinewave of the same frequency. If harmonics aren't there, then there can't be any differences (assuming a integer periodic input), because a single result bin of an FFT can only represent a pure sinusoid.

If you're starting with a 10Hz sine wave, doing an FFT, and seeing harmonics, it's because the FFT is operating on a fixed size chunk of samples (normally a power of 2) that doesn't happen to be a multiple of the period of the wave. If you've got, say, a 48KHz sample rate, then there are 4800 samples in each cycle, so a Fourier transform would have to be some multiple of 4800 samples long in order to produce a perfect result.

You have to remember that the Fourier transform is assuming that the block of samples it's operating on is repeated infinitely. If you were doing an FFT on, say, 65536 samples, then you'd have 13.6533333 cycles, and a big discontinuity when it is repeated.

If your Fourier transform length isn't related to the signal frequency, then you will always have some spurious harmonics. This is normally dealt with by "windowing" the signal, multiplying it by something that starts at zero, rises to 1 half way through the FFT input, then ramps back to zero at the end. A raised cosine shape is a pretty good choice for a window. This attenuates those spurious harmonics, but nothing eliminates them, other than having an input period that divides evenly into the FFT period.