Question: Problem 1 1. Complete the following MATLAB function to evaluate the Lagrange polynomial of degree p-n-1, where . . . shows the lines that should

Problem 1 1. Complete the following MATLAB function to evaluate the Lagrange polynomial of degree p-n-1, where . . . shows the lines that should be completed function L=L(x, xs,k) n length (xs); for i=1 : n if (i-k) DD (xs (i) -xs (k) end end In the above program x represents the location for which the Lagrange polynomial is evaluated, xs is a vector of length n and it represents the points through which a Lagrange denotes the kth Lagrange polynomial polynomial passes and 2. Use the above function and plot all five Lagrange polynomials of degree p-4 that pass through points xs-[-1,-0.9, 0.0, 0.5, 0.8]. For plotting purposes, let x-linspace (-1,1,501). Plot all polynomials in the same figure and show the location of the xs by: plot (xs, ones (1,length (xs)),'-o') Problem 2 Use the Lagrange interpolants from Problem 1 and approximate the function f(x) interval of-1r
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
