Any wave pattern can be produced by superimposing the appropriate sinusoidal waves.  Fast computer algorithms exist that calculate the required frequencies and amplitudes.  An example is shown on the right.When you add many harmonic waves with slightly different frequencies, you can build wave packets or wave pulses.  Wave pulses can be viewed as the superposition of many harmonic (sinusoidal) waves with slightly different wavelengths and phase constants.

Let us look first at a periodic, but not necessarily harmonic, wave.  At t = 0  the displacement y is some periodic function f(x) of x.  Let the spatial period (wavelength) be λ = L.

Examples of periodic but not harmonic waves with spatial period (wavelength) λ = L are shown below.  These are snapshots of the displacement as a function of position at some fixed  time t.

Fourier's theorem states that any periodic (and reasonably continuous) function with spatial period (wavelength) L can be synthesized by a sum of harmonic functions whose spatial periods (wavelengths) are integral submultiples of L, (such as L/2, L/3, ...).

Let f(x) be such a periodic function.  Then we may write

,

where the coefficients A0, An , and Bn can be calculated using

,
.

Here kn = n2π/L, k = kn+1 - kn = 2π/L.  There are efficient computer algorithms to evaluate these coefficients.

When L becomes very large, i.e. L --> ∞, the Fourier series generalizes to the Fourier transform.  Then the difference between adjacent values of k goes to zero and sinusoidal waves with a continuous range of wavelength must be used to synthesize f(x).

#### Example:  Synthesizing a square wave.

Assume a wave consists of a series of square pulse.  Each pulse has a width ∆x = 100 units, a height of 2 units and the wavelength L of the wave is 200 units.  At t = 0 one wavelength L of the wave is shown in the figure below (displacement versus position).

For this wave A0 = 1, Am = [4/(mπ)]sin(mπ/2), and Bm = 0.
So we have Am = (-1)(m-1)/24/(mπ) if m = odd and Am = 0 if m = even, and we can write at t = 0:

f(x) = 1 + ∑m = odd(-1)(m-1)/2[4/(mπ)]cos(kmx)
or
f(x) = 1 +  [4/(π)]cos(2πx/L) - 4/(3π)]cos(6πx/L) + 4/(5π)]cos(10πx/L) - 4/(7π)]cos(14πx/L) + 4/(9π)]cos(18πx/L) + 4/(11π)]cos(22πx/L) + ... ,

i.e. we write the square wave as a sum of harmonic waves (cosines) with wavelength L/n, n = odd.