Skip to content

aminomrani/fourier-series-step-function-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fourier Step Function Visualizer

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.

🔍 What It Does

  • 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

📊 Example Plot

fourier step approximation


📚 Math Background

The step function:

$$f(x) = -1, for x < 0 1, for x ≥ 0$$

Its Fourier series (only sine terms because it's an odd function):

$$f(x) ≈ \sum_{n=1,3,5...}^{N} \frac{4}{n\pi} \sin(nx)$$

🚀 How to Run

  1. 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
  2. Make sure you have Python installed with required libraries:

    pip install numpy matplotlib
  3. Run the script:

    python fourier_step.py

🧠 Learning Goals

  • Understand Fourier series for periodic functions
  • See how sine terms build up a discontinuous signal
  • Observe Gibbs phenomenon in action
  • Learn basic matplotlib and numpy usage

📦 Dependencies

  • Python 3.x
  • numpy
  • matplotlib

📜 License

This project is open-source under the MIT License.


✍️ Author

Amin Omrani MSc Chemical Engineering Student

About

Visualizes the Fourier series approximation of a step function and shows the Gibbs phenomenon using Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published