Responsive Navbar with Google Search
Fourier Series: Square Wave

Square Wave: Program 1

Fourier Series

The Fourier series is a way to represent a periodic function as a sum of simple sine and cosine waves. It breaks down any periodic function or signal into the sum of an infinite series of sines and cosines. This concept is widely used in fields such as signal processing, acoustics, and heat transfer, as it provides a tool for analyzing the frequency components of signals.

Key Concepts

  • Periodic Function: A function \( f(x) \) is called periodic with period \( T \) if \( f(x + T) = f(x) \) for all \( x \). In a Fourier series, we are interested in expressing this periodic function as a combination of simpler periodic functions (sines and cosines).
  • Orthogonal Basis: The sines and cosines form an orthogonal basis for the space of periodic functions. This means that any periodic function can be expressed as a linear combination of sine and cosine functions.
  • Harmonics: The sine and cosine functions are often called the harmonics of the original periodic function. The fundamental harmonic corresponds to the lowest frequency \( \frac{1}{T} \), while higher harmonics correspond to integer multiples of this frequency.

Fourier Series Mathematical Form

For a periodic function \( f(x) \) with period \( T \), the Fourier series is expressed as:

\[ \small f(x) = a_0 + \sum_{n=1}^{\infty} \left( a_n \cos \left( \frac{2\pi n}{T} x \right) + b_n \sin \left( \frac{2\pi n}{T} x \right) \right) \]

Where:

  • \( a_0 \) is the average (DC component) of the function over one period.
  • \( a_n \) and \( b_n \) are the Fourier coefficients for the cosine and sine terms, respectively.
  • \( n \) is the harmonic number, representing the frequency multiple of the base frequency.

Fourier Coefficients

The Fourier coefficients \( a_0 \), \( a_n \), and \( b_n \) are calculated as follows:

\( a_0 \) (the DC term):

\[ a_0 = \frac{1}{T} \int_0^T f(x) \, dx \]

\( a_n \) (cosine coefficients):

\[ a_n = \frac{2}{T} \int_0^T f(x) \cos \left( \frac{2\pi n}{T} x \right) \, dx \]

\( b_n \) (sine coefficients):

\[ b_n = \frac{2}{T} \int_0^T f(x) \sin \left( \frac{2\pi n}{T} x \right) \, dx \]

Output 1

Square Wave: Program 2

Fourier series approximation of a square wave signal (without using scipy.signal)

Output 2