created at November 2, 2022

Fourier Series

Fourier Series allows us to replace the given periodic function with infinite sum of harmonic functions (sine and cosine), each of them having some specific amplitude and frequency. This is widely used in radio electronics to generate various periodic signals. If we consider that a single period of the periodic function f(x) lies in between -L:L, then Fourier series is:

f(x)=a02+n=1(ancos(nπxL)+bnsin(nπxL))f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty }\left (a_n cos\left (\frac{n \pi x}{L}\right )+b_n sin\left (\frac{n \pi x}{L}\right )\right )

where:

a0=1LLLf(x)dxa_0=\frac{1}{L}\int_{-L}^{L}f(x) dx

- the constant coefficient presenting the average value of the function f(x).

an=1LLLf(x)cos(nπxL)dxa_n=\frac{1}{L}\int_{-L}^{L}f(x) \cdot cos\left (\frac{n \pi x}{L} \right )dx
bn=1LLLf(x)sin(nπxL)dxb_n=\frac{1}{L}\int_{-L}^{L}f(x) \cdot sin\left (\frac{n \pi x}{L} \right )dx

- the variable coefficients, depending on n.

First harmonics of Fourier Series have the most contribution to the value of the given function, thus there is no need to use infinite number of harmonics in practice, it's enough to use just some of them, say, first 10.

Here is example of breaking the function f(x) = x with period in range -1:1 by using the first 5 harmonics:

For even functions

Even function is symmetric relative to Y axis, i.e. f(x) = f(-x) for each x. For that kind of functions the Fourier Series will be reduced to a simpler one containing only the constant coefficient and cosines:

f(x)=a02+n=1(ancos(nπxL))f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty }\left (a_n cos\left (\frac{n \pi x}{L}\right )\right )

where

an=2L0Lf(x)cos(nπxL)dxa_n=\frac{2}{L}\int_{0}^{L}f(x) \cdot cos\left (\frac{n \pi x}{L} \right )dx

For odd functions

Odd function is symmetric relative to Coordinate Origin, i.e. f(x) = -f(-x) for each x. For that kind of functions the Fourier Series will contain the sine harmonics only:

f(x)=n=1(bnsin(nπxL))f(x)=\sum_{n=1}^{\infty }\left (b_n sin\left (\frac{n \pi x}{L}\right )\right )

where

bn=2L0Lf(x)sin(nπxL)dxb_n=\frac{2}{L}\int_{0}^{L}f(x) \cdot sin\left (\frac{n \pi x}{L} \right )dx

Simulation in Dysolve

In the attached document we will show how you can use Dysolve to simulate the Fourier Series. You can set your own function f(x) and the number N, which is how many first harmonics will be used in calculation.

Caution! Since the app will integrate the function numerically for each n value, the calculation will take time. So, don't use large N values as it will hang up your app, especially on mobile device.

Also, the Dysolve version 3.1.0 (or higher) is required for this simulation