Question: Problem 1: (i). Create an m-fille mynewton.m as described below: function p=mynewton(x0,y0,x) N = length(x0) Compute the divided difference table DD=[xO'yO']; Compute the needed divided

![p=mynewton(x0,y0,x) N = length(x0) Compute the divided difference table DD=[xO'yO']; Compute the](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4fec783815_03966f4fec72170c.jpg)


Problem 1: (i). Create an m-fille mynewton.m as described below: function p=mynewton(x0,y0,x) N = length(x0) Compute the divided difference table DD=[xO'yO']; Compute the needed divided differences (You can consult Algorithm 3.2, page 124 of the textbook). (You may use for loops.) a=D(1,2:end) use a for loop to compute the forward newton polynomial at given x (x is vector) p = a(1) + a(2). *(x-xO(1))+ a(3). *(x-xO(1)). *(x-XO(2)) + .... alend)*(x-XO(1)). .......... .*(x-XO(N-1)). (ii) create an m-file 'main_newton' that creates XO and yo in the interval [a,b] and interpolates the function f(x)=1/(1+x^2) and plots the curves as described in the following script: n=20; a=-5; b= 5; dx = (b-a); x0= a:dx:b; f =@ (x) 1./(1+x.^2); yO=f(x0); np=100; dxp=(b-a)p; xp=a:dxp:b; ys=f(xp); yp=mynewton(x0,y0,xp); figure(1) subplot(1,2,1) plot(xp,yp); hold on plot(xp,ys) plot(x0,y0,*') subplot(1,2,2) plot(xp,abs(xs-yp)) (iii) Print your results. (iv) Are your results correct? Explain why or why not? (v) Discuss your the behavior of the error (vi) Describe how you can use the divided difference table from problem 1 to solve problem 2 Problem 1: (i). Create an m-fille mynewton.m as described below: function p=mynewton(x0,y0,x) N = length(x0) Compute the divided difference table DD=[xO'yO']; Compute the needed divided differences (You can consult Algorithm 3.2, page 124 of the textbook). (You may use for loops.) a=D(1,2:end) use a for loop to compute the forward newton polynomial at given x (x is vector) p = a(1) + a(2). *(x-xO(1))+ a(3). *(x-xO(1)). *(x-XO(2)) + .... alend)*(x-XO(1)). .......... .*(x-XO(N-1)). (ii) create an m-file 'main_newton' that creates XO and yo in the interval [a,b] and interpolates the function f(x)=1/(1+x^2) and plots the curves as described in the following script: n=20; a=-5; b= 5; dx = (b-a); x0= a:dx:b; f =@ (x) 1./(1+x.^2); yO=f(x0); np=100; dxp=(b-a)p; xp=a:dxp:b; ys=f(xp); yp=mynewton(x0,y0,xp); figure(1) subplot(1,2,1) plot(xp,yp); hold on plot(xp,ys) plot(x0,y0,*') subplot(1,2,2) plot(xp,abs(xs-yp)) (iii) Print your results. (iv) Are your results correct? Explain why or why not? (v) Discuss your the behavior of the error (vi) Describe how you can use the divided difference table from problem 1 to solve problem 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
