This project demonstrates how to approximate a step function using a Fourier series in Python. It is a great educational example for beginners in signal processing, numerical analysis, or engineering mathematics who want to understand the behavior of Fourier series — especially the Gibbs phenomenon near discontinuities.
- Defines a step function on the interval
[-π, π] - Computes its Fourier series using only sine terms (odd function)
- Plots the original function and its Fourier approximation
- Visualizes how increasing the number of terms (N) improves the approximation
The step function:
Its Fourier series (only sine terms because it's an odd function):
-
Clone the repo or copy the Python script:
git clone https://github.com/aminomrani/fourier-series-step-function-visualizer.git cd fourier-series-step-function-visualizer -
Make sure you have Python installed with required libraries:
pip install numpy matplotlib
-
Run the script:
python fourier_step.py
- Understand Fourier series for periodic functions
- See how sine terms build up a discontinuous signal
- Observe Gibbs phenomenon in action
- Learn basic
matplotlibandnumpyusage
- Python 3.x
- numpy
- matplotlib
This project is open-source under the MIT License.
Amin Omrani MSc Chemical Engineering Student
