Fourier coefficients

The Fourier series of a periodic function f(x) with period x = 2π is of the form

f(x) = a0 /2 + Σ (ancos(nx) + bnsin(nx)); n=1,2,3....∞

To calculate the coefficients of the series, one starts with the following assumed identities:

f(x)cos(mx)dx = cos(mx) Σ(a0/2 + Σ ancos(nx) + bnsin(nx))dx

f(x)sin(mx)dx = sin(mx) Σ(a0/2 + Σ ancos(nx) + bnsin(nx))dx

where one integrates over one base period (m = 1).

Suppressing constants, the following types of integral are to be evaluated, summed over index n:

With m = 1,2,3...∞ and n = 1,2,3...∞: order of the harmonic (fundamental m, n = 1)

cos (mx)

sin (mx)

cos (mx) * (a*cos (nx) + b*sin (nx))

sin (mx) * (a*cos (nx) + b*sin(nx))

All integrals are zero except of those few where the indices are identical: m = n and the function types are the same (sine or cosine). Therefore every sum for a specific index n has only one member and the coefficients can easily be derived from the reduced equations as: 

a0 = 2/Tf(t) dt

an= 2/Tcos(nx) f(t) dt

bn = 2/Tsin(nx) f(t) dt

This simulation demonstrates the different types of functions and their integral.