Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a) Write down the general expression for Lagrange Polynomial. b) If you have 5 d

ID: 2981467 • Letter: A

Question

a) Write down the general expression for Lagrange Polynomial. b) If you have 5 data points, what order of polynomial you would get? C) Write down the Lagrange Polynomial passing through those 5 points if the values of the function at those 5 points are as follows x -5 -1.25 0 1.25 3.0 F(x) -68 -4 0 5 25 Extrapolate the polynomial between -10 to +10 and plot the polynomial using MATLAB.

Explanation / Answer

Interpolation and Curve Fitting with MATLAB I For the given data points; egin{displaymath} egin{array}{rr} x & y \ hline 1 & 1.06 \ 2 & 1.12 \ 3 & 1.34 \ 5 & 1.78 \ end{array}end{displaymath} construct the interpolating cubic $ P_3(x)=ax^3+bx^2+cx+d$. Hint: First, write the set of equations then solve it by writing/using a MATLAB program. Interpolate for $ x=4$ Extrapolate for $ x=5.5$ Solution: >> A=[1 1 1 1; 8 4 2 1; 27 9 3 1;125 25 5 1] >> B=[1.06 1.12 1.34 1.78]' >> X=uptrbk(A,B) X = -0.0200 0.2000 -0.4000 1.2800 >> X'*[27 9 3 1]' ans = 1.3400 >> X'*A(3,1:4)' ans = 1.3400 >> X'*[4^3 4^2 4 1]' ans = 1.6000 >> X'*[(5.5)^3 (5.5)^2 5.5 1]' ans = 1.8025 We have given the following MATLAB code to evaluate the Lagrange polynomial $ P(x)=sum_{k=0}^N y_k rac{prod_{j eq k}(x-x_j)}{prod_{j eq k}(x_k-x_j)}$ based on $ N+1$ points $ (x_k,y_k)$ for $ k=0,1,ldots,N$. function [C,L]=lagran(X,Y) %Input - X is a vector that contains a list of abscissas % - Y is a vector that contains a list of ordinates %Output - C is a matrix that contains the coefficents of % the Lagrange interpolatory polynomial % - L is a matrix that contains the Lagrange coefficient polynomials w=length(X); n=w-1; L=zeros(w,w); %Form the Lagrange coefficient polynomials for k=1:n+1 V=1; for j=1:n+1 if k~=j V=conv(V,poly(X(j)))/(X(k)-X(j)); end end L(k,:)=V; end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote