Matlab Code
x=[-2 0 1 2 4];
y=[5 1 1.25 1 -7];
plot(x,y)
Output
(a)Linear Lagrange interpolation
x=linspace(-2,4);
if -2<=x<0
y=6+x/2;
end
if 0<=x<1
y=1+x/8;
end
if 1<=x<2
y=1.5-0.25*x;
end
if 2<=x<4
y=9-4*x;
end
plot(x,y)
Output
(b)
x=linspace(-2,4);
if -2<=x<=1
y=(x.^2+2*x)*(1.25/3)+(5/6)*(x.^2-x)-(1/2)*(x.^2+x-2);
end
if 1<=x<=4
y=(-7/3)*(x-1).*(x-2)+(1.25/3)*(x-2).*(x-4)-(1/2)*(x-1).*(x-4);
end
plot(x,y)
Output
(c)
x=linspace(-2,4);
y=5-2*(x+2)+0.25*x.*(x+2)-x.*(x-2).*(x+2)*(0.09375)-x.*(x+2).*(x-1).*(x-2)*(0.12326);
plot(x,y)
Problem 2. Given the data points (xi. yi), with xi 2 02 4 yil 5 1 1.25 find the following interpo...
Problem 01 (about INTERPOLATION Given the following data Xi Yi 4 -5 (a) Using 2-nd order (or QUADRATIC) "LAGRANGE" interpolation function, compute the value of Y ( @X 4.7) ?? (b) Using 2-nd order (or QUADRATIC) "Newton Divided Difference" interpolation function, compute the coefficients bo, b1 and b2 ??
Please solve problem 7 not 5. however you need data from problem 5 to slove problem 7 Hide email Problem 5 (10 points): For the data below, perform Newton Divided Difference interpolation of fC7.5 C) using first through third order interpolating polynomial:s for f viscosity of water 1000 in metric (MKS) units. Choose thexi interpolation points to provide the most accurate interpolation (points should most closely surround x = 7.5 C). 040 y i 1.781 | İ .568 | 1...
a) Find False Position function for this data. b) Find the third-order interpolation function with Lagrange method c) Find the third-order interpolation function with Newton's Divided Difference Method. d)Find the natural spline interpolation function for the same data e)Draw the given points in a row using the False Position function, the third order polynomial obtained by Lagrange and Newton's Divided Difference Method, and the natural spline interpolation function using MATLAB. 4-0 2
2. Consider interpolating the data (x0,yo), . . . , (x64%) given by Xi | 0.1 | 0.15 | 0.2 | 0.3 | 0.35 | 0.5 | 0.75 yi 4.0 1.0 1.22.12.02.52.5 For all tasks below, please submit your MATLAB code and your plots. You can write all code in a single (a) Using MATLAB, plot the interpolating (6th degree) polynomial given these data on the domain .m-file [0.1,0.75] using the polyfit and polyval commands. To learn how to use...
For an nth-order Newton's divided difference interpolating polynomial fn(x), the error of interpolation can be estimated by Rn-| g(xmPX, , xm» ,&J . (x-x-Xx-x.) . . . (x-x.) | , where (xo, f(xo)), (xi, fx)).., (Xn-1, f(xn-1) are data points; g[x-,x,,x-.., x,] is the (n+1)-th finite divided difference. To minimize Rn, if there are more than n+1 data points available for calculating fn(x) using the nth-order Newton's interpolating polynomial, n+1 data points (Xo, f(xo)), (x1, f(x)), , (in, f(%)) should...
2. More on Cubic Splines Consider the data Xi : 1 2 3 4 Yi : 18 27 64 a. Construct the cubic interpolant, i.e., find the cubic polynomial p that satisfies p(xi) = Yi, i = 1,2,3,4 and draw its graph. b. Construct the interpolating natural cubic spline and draw its graph. c. Comment on your results.
er Lagrange ,Divided difference and Hermitewatnejed, Jnp 1.5, and x2-2, andf (x)ssin(x) * Given the point sx.-1, a) Find its Lagrange interpolation P on these points b) Write its newton's divided difference P, polynomial c)Write Hermite Hs by Using part a outcomes d) Write Hermite Hi by Using part b outcomes Rules: Lagrange form of Hermite polynomial of degre at most 2n-+1 Here, L., (r) denotes the Lagrange coefficient polynomial of degree n. If ec la.bl, then the error formula...
Let (xi , f(xi)), i = 0, . . . , 3, be data points, where xi = i + 2, for i = 0, . . . , 3. Given the divided differences f[x0] = 1, f[x0, x1] = 2, f[x0, x1, x2] = −7, f[x0, x1, x2, x3] = 9, add the data point (0, 3), find a Newton form for the Lagrange polynomial interpolating all 5 data points. 3. (25 pts) Let (r,, f()), 0,3, be data...
Given the data points (xi , yi), with xi 0 1.2 2.3 3.5 4 yi 3.5 1.3 -0.7 0.5 2.7 find and plot (using MATLAB) the least-squares basis functions and the resulting least-squares fitting functions together with the given data points for the case of a) a linear monomial basis p(x)= {1 x}T . b) a quadratic monomial basis p(x)= {1 x x2}T . c) a trigonometric basis p(x)= {1 cosx sinx}T Moreover, determine the coefficients a by the Moore-Penrose...
1. (25 pts) Given the following start for a Matlab function: function [answer] = NewtonForm(m,x,y,z) that inputs • number of data points m; • vectors x and y, both with m components, holding x- and y-coordinates, respectively, of data points; • location z; and uses divided difference tables and Newton form to output the value of the Lagrange polynomial, interpolating the data points, at z. 1. (25 pts) Given the following start for a Matlab function: function [answer] NewtonForm(m.x.yz) that...