Source: http://onmyphd.com/?p=harmonics

Harmonics

Sections

What are harmonics?

If you have a signal with a fundamental frequency $f$ (like a sinusoidal with frequency $f$), harmonics are every other sinusoidal components at frequencies multiples of the fundamental frequency ($2f$, $3f$, ...). These harmonics are important because they can be seen at the output of a system with some nonlinearity. The power in the harmonics represent how nonlinear the system is.

Let's say that we apply a perfect sinusoid $x(t) = \sin(2\pi f t)$ to a certain system. If the system is linear, the output will have a perfect sinusoid at its output: $$y(t) = b x(t) + a = b\sin(2\pi f t) + a$$ where $a$ and $b$ are the parameters of the linear system, $x(t)$ is its input and $y(t)$ is the output.

Now let's assume that the system is nonlinear and, like any nonlinear system, can be approximated by a polinomial function $y(t) = a + b x(t) + c x(t)^2 + d x(t)^3 + ...$. How deep we go into the terms of the polinomial function depends on how accurate we want to approximate the system. We apply the same perfect sinusoid and look at the output: $$\begin{equation}y(t) = a + b \sin(2\pi f t) + c \sin(2\pi f t)^2 + d \sin(2\pi f t)^3 + ...\label{eq:nonlinear}\end{equation}$$ We make use of the trigonometric properties (you can find them on wikipedia): $$ \sin(\theta)^2 = \frac{1-\cos(2\theta)}{2}$$ $$ \sin(\theta)^3 = \frac{3\sin(\theta) - \sin(3\theta)}{4}$$ Replacing them in $\eqref{eq:nonlinear}$: $$y(t) = a + b \sin(2\pi f t) + c \frac{1-\cos(2\cdot 2\pi f t)}{2} + d \frac{3\sin(2\pi f t) - \sin(3\cdot 2\pi f t)}{4} + ...$$ $$y(t) = a + \frac{c}{2} + \left(b + \frac{3d}{4}\right)\sin(2\pi f t) - \frac{c}{2}\cos(2\pi (2f) t) - \frac{d}{4}\sin(2\pi (3f) t) + ...$$ As you can see, the nonlinear terms of the polinomial generate sine waves at integer multiples of the input frequency.

In pratice, the harmonics show as distortion in the output signal. In audio systems, distortion is a big topic and ideally we would want no harmonics.

The sliders below control each coefficient of the polinominal function. In the above plot you can see the original sine wave ($x(t)$) and the output $y(t)$ of the system. As you increase c and d (the nonlinear components), the output signal becomes more distorted

b =
c =
d =

The sliders above control each coefficient of the polinominal function. In the plot above you can see the input and output signals in the frequency domain. As you increase c and d (the nonlinear components), the harmonics start to show up

To measure how nonlinear a system is, the metric Total Harmonic Distortion is used. It measures the power in the harmonics and compares it to the power in the fundamental frequency.

Harmonics in differential signals

Often, a signal is transmitted in a differential way, i.e., the difference between two opposed signals represent the analog signal. For example, a signal $x(t)$ can be represented as $x(t) = x^+(t) - x^-(t)$, where $x^+(t) = \sin(2\pi f t)$ and $x^-(t) = -\sin(2\pi f t)$. In that case, and assuming both signals pass through the same system, each output becomes: $$y^+(t) = a + b \sin(2\pi f t) + c \sin(2\pi f t)^2 + d \sin(2\pi f t)^3 + ...$$ $$y^+(t) = a + \frac{c}{2} + \left(b + \frac{3d}{4}\right)\sin(2\pi f t) - \frac{c}{2}\cos(2\pi (2f) t) - \frac{d}{4}\sin(2\pi (3f) t) + ...$$ $$y^-(t) = a - b \sin(2\pi f t) + c (-\sin(2\pi f t))^2 + d (-\sin(2\pi f t))^3 + ...$$ $$y^-(t) = a + \frac{c}{2} - \left(b + \frac{3d}{4}\right)\sin(2\pi f t) - \frac{c}{2}\cos(2\pi (2f) t) + \frac{d}{4}\sin(2\pi (3f) t) + ...$$ The output is $y(t) = y^+(t) - y^-(t)$: $$y(t) = 2\left(b + \frac{3d}{4}\right) \sin(2\pi f t) - \frac{d}{2}sin(2\pi(3f)t) + ...$$ The even harmonics cancel out in a differential signal. Only the odd harmonics remain.

Intermodulation

And what if two or more sine waves at different frequencies were applied to a nonlinear system? Would only be generated harmonics at integer multiples of the frequency of each sinusoidal? In fact, although the principle is the same, interactions between the several sine waves will also generate components at the sum and difference of all the harmonics and fundamentals. These interactions are so proeminent that the phenomenon has its own name, intermodulation.