Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Matlab to implement theorom langrange interpolating polynomial Theorem 3.2 If x, xi. .. . .Xn are1 distinct numbers and f is a function whose

Use Matlab to implement theorom langrange interpolating polynomial

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions

Question

List the benefits of depositary receipts to the investors.

Answered: 1 week ago

Question

Choose an appropriate organizational pattern for your speech

Answered: 1 week ago

Question

Writing a Strong Conclusion

Answered: 1 week ago