Question: my code for part 1 function y=linterp(X,Y,x) w=[]; y=0; a1=0; a2=0; for i=1:length(X) w(i)=1; for j=1:length(X) if(i~=j) w(i)=w(i)/(X(j)-X(i)); end end a1=a1+w(i)*Y(i)/(x-X(i)); a2=a2+w(i)/(x-X(i)); end y=a1/a2; end

 my code for part 1 function y=linterp(X,Y,x) w=[]; y=0; a1=0; a2=0;

my code for part 1

function y=linterp(X,Y,x) w=[]; y=0; a1=0; a2=0; for i=1:length(X) w(i)=1; for j=1:length(X) if(i~=j) w(i)=w(i)/(X(j)-X(i)); end end a1=a1+w(i)*Y(i)/(x-X(i)); a2=a2+w(i)/(x-X(i)); end y=a1/a2; end

2. The MATLAB function poly inputs an array of numbers and outputs a polynomial (as a coefficient vector) whose roots are the input numbers. In other words, poly inputs r,... .Tn and outputs ao,ai,....an where Figure out an algorithm for this transformation, and write it in MATLAB as the function function p mypoly(X) You may not call poly within mypoly, and you may not use the Symbolic Math Toolbox (syms, etc.) Hint: Explicit expressions for a polynomial's coefficients in terms of its roots are given by Vieta's formulas. However, directly evaluating Vieta's formulas performs much more arithmetic than necessary_ roughly 2 operationsand is also somewhat complicated in Matlab. Try to discover a simpler algorithm that computes all coefficients at (roughly) the same time while 1p processing the first k roots you have found ao, a1,..., ak satisfying (roughly) n2 operations. The trick is that after and the (k +1)-th step is multiplying derive formulas for the (k+2) coefficients of this new polynomial in terms of ao, . ak

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!