Question: These questions in Numerical Analysis. Could you please make sure the code for Matlab is working? Thanks. ( 1 ) ( MATLAB: Lagrange interpolation )

These questions in Numerical Analysis.
Could you please make sure the code for Matlab is working? Thanks. (1)(MATLAB: Lagrange interpolation)
We consider the function f(x)=11+x2 on the interval -5,5.
(a) Implement a MATLAB function that compute the interpolating Lagrange polynomial
nf of degree n=2,4,8 on equally spaced nodes (you can use the function polyfit and
polyval). Plot the graph of f and the interpolating polynomials on the same figure (use
100 sample points to evaluate f and the Lagrange polynomial). Comment your result.
(b) Explain briefly why can we use the MATLAB command polyfit to find Lagrange
interpolating polynomial.
(2)(MATLAB + natural cubic spline)
(a) Implement a MATLAB function called natural cubic spline that has the form:
[ xout, yout ]=n atural_cubic_spline (x,y, nsample )
where the vectors x and y represents the nodes xi and data yi, the integer nsample is the
number of sampling points in each interval xi,xi+1(use the command linspace to
generate them). The function returns a vector xout with the coordinate of the sampling
point and a vector yout with the value of the natural cubic spline at the sampling points.
(b) Create a MATLAB script that use the above function with xi=-5+i,yi=11+xi2
for i=0,dots,5 and n=11. Plot the output in a graph. Any comment compares to the
results you got in question 1.a?
 These questions in Numerical Analysis. Could you please make sure the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!