Lesson 1 of 15
Fourier Series
Fourier Series
A Fourier series decomposes a periodic function into a sum of sines and cosines. For a function f(x) with period 2L, the series is:
The Fourier coefficients are computed via integration:
- DC component:
- Cosine coefficients:
- Sine coefficients:
Numerical Integration
We represent f(x) by N evenly spaced sample points on [-L, L) using a midpoint grid:
The step size is . The integrals become sums:
Square Wave Example
A square wave on is if , else . Its Fourier series contains only odd sine harmonics:
So , , and all .
Your Task
Implement the four Fourier series functions. Use N=1000 sample points on the midpoint grid. The f_values input is a list of N function values at the grid points.
Python runtime loading...
Loading...
Click "Run" to execute your code.