Write a .m Matlab file to implement the Fourier Series of function f(x)= x² on interval (-1,1). Requirements: Α-ΣΑ, cost
Posted: Fri May 20, 2022 12:30 pm
Write a .m Matlab file to implement the Fourier Series of function f(x)= x² on interval (-1,1). Requirements: Α-ΣΑ, cost- + + Bsin n=1 n=1 2плх, 2ηπχ, 1. In the Fourier Series formula f(x) = ) + ), compute only first 20 2 T T items. [In the class the example only summed the first 8 items.) 2. Compute 20 approximated functions: 2ηπα, y 1 = f,(x) = -) + [contain only 1st term of each summation] 2 T T 2nax 2ηπα, [contain first 2 terms of each summation] yz = f2(x)= 2 T T 2ηπα, + n=1 n=1 Α-ΣΑ, cost- Α-ΣΑ, cost- ΣΒ, sint- 5)+ŽB, sin ;() 4 + n=1 n=1 20 Y20 = $20 (x)= 4 + $4,cosc 2ηπα, T 5+ B sin 2ηπχ -) [contain first 20 terms of each summation] T n=1 n=1 3. Compute 20 absolute errors between y= f(x)= x’ and each of 20 functions above. That is, 2ηπχ 2nax A cos -) + B, sin(2nAX) - r T T 1 4 = 4 +34 e 2 n=1 n=1 2nx 2n2x, +Š B, sin ΣΑ, cost- e A + 2 = -X T T n=1 n=1 20 20 e20 -- +3 ΣΑ, cos(- + 2ηπα, 2ηπχ, ) + ΣΒ, sint- T T -Σ2 4-14 x 2 n=1 4. Plot E Ő (1) Create a figure in which there are two x-y planes aligned vertically. [Use subplot() to create such a figure. See the example I ever gave in the class] = (2) Top x-y plane: plot 20 curves defined by yz = f(x), yz = f2(x),..., Y20 = $20 (x). The title is “Approximation of Fourier Series”, x_label is ‘x, y label is Fourier Series. (3) Bottom x-y plane: plot 20 curves of absolute errors by e (x) ,e2(x),...,120 (x). The title is "Absolute error of Fourier Series”, x label is 'X', y label is Absolute error.