Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions