Example: Fourier Polynomial
1. Write a program that generates a periodic function:
2. Plot the function:
3. Enter the positive endpoint of the periodic interval:
4. Specify the order of the Fourier series approximation:
5. Write a program to compute the Fourier coefficients:
6. Compute the Fourier coefficients:
7. Compute the Nth Fourier polynomial:
8. Plot the Fourier polynomial and the original function:
P1 approximation of f is poor around the high frequency points (the sharp edges).
9. Compute the Fourier coefficients:
10. Compute the Nth Fourier polynomial:
11. Plot the Fourier polynomial and the original function:
P2, which uses Nt=20, provides a much better approximation of the original function especially around the high frequency points (the sharp edges).