To see visually how good and bad various interpolation methods can be, we'll use Matlab's interpolation functions and plotting, on data generated from Runge's function:f(x) = 1/(1+xIn Matlab (^{2})diary on), do the following: 1. GenerateN+1=11equi-spaced nodesXin the interval [-5,5]:_{i}X = [-5:1:5];(to see values, omit the ;) and evaluatef(x)at these nodes:Y = 1./(1+X.^2);The N+1 points (X_{i}, Y_{i}) are the data points to be interpolated by various methods. Plot them to see where they are:plot(X,Y,'o') title('N+1 = 11 equi-spaced data points') pauseAlso generate lots of points x_{i}at which to evaluate f(x) and the interpolants for plotting:x = [-5:0.1:5];(this is a lower case x, not X) Evaluatef(x)at these x_{i}'s and plot y=f(x) and the data points:plot(x,y,'-', X,Y,'o') title('Runge f(x) and data pts') pauseNow, we use the data points (X_{i}, Y_{i}) to construct various interpolants. A good interpolant should "reproduce" the function f(x) as close as possible. Let's try a few. 2.Use Matlab'sN^{th}degree interpolating polynomial:polyinterpto construct (the coefficients of) the N^{th}degree interpolating polynomial (here N=10):pN = polyfit( X,Y, N);Now this can be evaluated anywhere in the interval [-5,5] withpolyval, e.g. at the x_{i}'s:v = polyval( pN, x);Find the Inf-norm error∥y-v∥:_{∞}err = norm(y-v, inf)and plot both f(x) and pN(x) on the same plot:plot(x,y,'-', x,v,'x-') title('f(x) and pN(x) at plotting pts') pauseIs this a good interpolant ? Why ? 3.Generate N+1=11 Chebychev points (XchebInterpolation at Chebychev nodes:_{i}, Ycheb_{i}) in [a,b]:fprintf('------ chebychev nodes ------\n') K = N+1; a=-5; b=5; for i=1:K Xcheb(i)=(a+b)/2 + (b−a)/2 *cos( (i−0.5)*pi/K ); end Ycheb = 1./(1+Xcheb.^2);Follow the steps in 2. to produce the N^{th}degree interpolating polynomialpNchebbased on the Chebychev nodes, its valuesvchebat the x_{i}'s, the error∥y − vcheb∥, and plot both f(x) and pNcheb(x) on the same plot. Compare the error and plot with those from 2. Which one is better ? why ? 4._{∞}Use Matlab'sPiecewise linear interpolation:interp1to construct the linear interpolant:lin = interp1(X,Y, x, 'linear');Repeat the steps of 2. Compare errors and plots. 5.Use Matlab'sPiecewise cubic interpolation:interp1to construct the cubic interpolant:cub = interp1(X,Y, x, 'cubic');Repeat the steps of 2. Compare errors and plots. 6.Use Matlab'sCubic spline interpolation:interp1to construct the spline interpolant:spl = interp1(X,Y, x, 'spline');Repeat the steps of 2. Compare errors and plots. 7. To see that the error gets worse for biggerNfor equi-spaced nodes but not for Chebychev nodes (for this f(x) at least), repeat 2. and 3. withN = 20.diary offClean up your "diary" to create a matlab script, "lab5.m", that does all the above. Then insert comments (lines starting with %), describing what each step does. Make sure your script works. Create a file "lab5.txt" with your comments for EACH case (2-7), like, e.g: ************************************ 4. Piecewise linear interpolation: error = Comments: ************************************ Which one did you like best ? At the end insert your lab5.m script. Submit the file "lab5.txt".