For the following piecewise function: (a) Express y(x) as a Fourier series, (b) Write aMATLAB program that

Question:

For the following piecewise function:y(x): -x for 1

(a) Express y(x) as a Fourier series,ao y(x) = = 22 + n=1 an os nx + bn sin nx


(b) Write aMATLAB program that computes the value of the Fourier series for n = 10, n = 100 and n = 1000 using a grid in x that is linearly space from [−1, 1] using 101 points. The program should automatically plot these three functions to the screen.

(c) Write a MATLAB program that determines the value of the error,E = ||yn-y* ||

where yn is the approximation from the Fourier series using n terms and y is the exact value of the function, for n = 1, 2, . . . , 1000. You can use the MATLAB function norm(x) to compute the norm. The program should automatically create a semilog-x plot of this error as a function of the number of terms n. Explain why the error does not go to zero for n ≫ 1. The quantity || . . . || is a vector norm.

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: