Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Math · Advanced Math
Question details

Use MATLAB to implement Lagrange interpolating polynomial

Theorem 3.2 If x, xi. .. . .Xn are1 distinct numbers and f is a function whose values are given at these numbers, then a unique polynomial P(x) of degree at most n exists with formula named Lagrange s likely known around 1675, first have been 9 by Edward 798). Lagrange y on the subject n f(m) = P (x.), for each k 0, l , . . . , n This polynomial is given by PI P(x) = f(xo) Lno(x) + . . . + f(%) Ln,n(x) = k-0 where, for each k = 0, 1, . . , n, Ln.k(x) = and his work had nce on later (3.2) He published 5. s used to write tly and parallels which is used for (xk x)

Write a MATLAB function to implement the Lagrange interpolating polynomial in Theorem 3.2, given input coordinates, X -(x,.xn) and the corresponding function values Y (fx).. f(xn)), and interpolation point x. Note that the index above runs from 1 instead of 0 that is used in the textbook. This is because MATLAB does not allow index 0.

Your function should use the same order of input below function y lagrange (X,Y,X) = X = input coordinates % Y = corresponding function values = interpolation point x , = interpolated function value at x, i.e. p(x) your implementation below end

Save your function in lagrange. m. Now, create a MATLAB script main.㎡ that contains the following: n3: number of input coordinates Y1./X: y coordinates generated by (x)-1/ inspace (1,2.9,n): equally-spaced x coordinates now, we use (x,Y) to calculate the Lagrange interpolating polynomia P(X), then compare the interpolated polynomial p(x) to f (x). xlinspace (1,3,100) 100 interpolation points Pzeros (1,100) for i = 1:100 p(1) -lagrange (X, Y, X(1)); calculate p(x(i)) figure plot (x,p) plot p(x) hold on plot (x,1.7x,r) plot the actual create a new figure plot multiple curves on the same figure function f (x) in red

We would like to test different numbers of input coordinates and compare the performance of P (x).Modify main.m and generate a figure similar to below. Refer to MATLAB help for command xlabel,ylabel, title and legend The Exact Function f(x)=1/x and the Lagrange Interpolants 0,8 c 0.6 0.4 0.2 actual 11.2 4 16 18 2.2 2.4 26 28 3

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.