Question: USE NEWTON'S DIVIDED DIFFERENCES INSTEAD OF LAGRANGE FOR MY MATLAB CODE PLEASE, MAT 340 NUMERICAL METHODS. THANKS IN ADVANCE! MY CODE: PLEASE CHANGE IT TO

USE NEWTON'S DIVIDED DIFFERENCES

INSTEAD OF

LAGRANGE FOR MY MATLAB CODE PLEASE,

MAT 340 NUMERICAL METHODS. THANKS IN ADVANCE!

USE NEWTON'S DIVIDED DIFFERENCES INSTEAD OF LAGRANGE FOR MY MATLAB CODE PLEASE,

MY CODE: PLEASE CHANGE IT TO INSTEAD USE NEWTON'S DIVIDED DIFFERENCES to construct the interpolating polynomial. Your Newton interpolating function must have the coordinates and the domain you are interpolating over and output the polynomial along with its maximum error defined. Provide plots.

f=@(x) 1./(1+10.*x.^2);

X=linspace(-1,1); %% domain in order to plot

%% s for the error

s=linspace(0,1);

plot(X,f(X),'k','lineWidth',3)

hold on

for n=3:12

x=linspace(-1,1,n+1);

y=f(x);

P=lagrangepoly(x,y);

plot(X,P(X),'--')

n

Error_n=max(abs(f(s)-P(s)))

end

%%

% The error was decreasing up until the odd n's up until 7 and increasing for even n's

% For n=100 the error should be large

1 Problem 1 For a set of n + 1 data points (^o, o), (x1,yi),..., (xn,yn) we want to approxi mate a given function f(x) by polynomial interpolation, i.e where each L(x) is a Lagrange polynomial defined by (x - xo)(x - xi)..-(x - x,-1)(x - ^iti)... (x - xn) Li(x) := i=0, 1, . . . , n. Write a function that finds the interpolating polynomials Pn(x), with n-3, 4, ,12 which 14m3 on x 1-1, 1]. Plot all polynomials Pn(x) and the function f(x) in the same figure. For each n, use approximate the function j(x) 1+10x Error, - max) xE[0,1 to measure the error. What do you observe? What would you predict if n 100? 1 Problem 1 For a set of n + 1 data points (^o, o), (x1,yi),..., (xn,yn) we want to approxi mate a given function f(x) by polynomial interpolation, i.e where each L(x) is a Lagrange polynomial defined by (x - xo)(x - xi)..-(x - x,-1)(x - ^iti)... (x - xn) Li(x) := i=0, 1, . . . , n. Write a function that finds the interpolating polynomials Pn(x), with n-3, 4, ,12 which 14m3 on x 1-1, 1]. Plot all polynomials Pn(x) and the function f(x) in the same figure. For each n, use approximate the function j(x) 1+10x Error, - max) xE[0,1 to measure the error. What do you observe? What would you predict if n 100

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!