112 pts Let fx2 sin xx where x is in radian a Use quadratic

112 pts.] Let f(x)-2 sin (xx), where x is in radian. (a) Use quadratic Lagrange interpolation P2 (x) based on the nodes x,-= i, and X2 = 3, to approximate f(2) and f(2.4). (b) Use cubic Lagrange interpolation P3 (x) based on the nodes x0 = 0, x1 = 1, x2- 3 and x3 5, to approximate f(2) and f(2.4). (e) Plot P2 Cx), Ps (x) and the original function fx) 2 sin) in the interval x t- 0.5, 5.5]. 2. 12 pts.] Manually construct the divided-difference table for the interpolation problem in Example 10.7, which is shown below. Example 10.7: Manual Interpolation with Newton Polynomial Basis Use quadratic interpolation and the data presented in Example 10.2 on page 523 to est the viscosity of glycerin at 22 °C. The interpolant is of the fórm Before any calculations are performed, one usfdecide whichne(support used to define the interpolant, For T-22 C, the \"nearest\" three points are at T T2-20, and T3 = 30. Therelevant divided differences are 10. fir,] = = 3.810. f17. Tal = 2-41 1.492-3.810 fin. 13] -0.629-1.492 02318 10 63 +0.2318 7.2750 × 10-3, 20 so thak the imterpolant formula becomes (T)-3.810-0.2318(T- 10). +72750 x 10-,(T-10)(T-20. Evaluating the interpolant at = 22 gives (22) 3.8 10-0.231 8(12) + 7.2750rcs(12)(2) = 1.2030. The result depends on the choice of the support points and the degree of the polynomial interpolant. (See Example 10.2 and Exercises 12 and 13.)

Solution

1)

function v = lagrange(x,y,u)
   n = length(x);
   v = zeros(size(u));
   for k = 1:n
   w = ones(size(u));
   for j = [1:k-1 k+1:n]
   w = (u-x(j))./(x(k)-x(j)).*w;
   end
   v = v + w*y(k);
end

u = -.25:.01:2.4;
v = lagrange(x,y,u);
plot(x,y,’o’,u,v,’-’)

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

2)

function [f, a, res] = newtoninterpolation(x, y, p)
n = length(x);
res(:,1)=y\';
for j=2:n
for i=j:n
res(i,j)= ( res(i-1,j-1)-res(i,j-1)) / (x(i-j+1)-x(i));
end
end
a = diag(res)\';

arr(1,:) = repmat(1, size(p));
c(1,:) = repmat(a(1), size(p));
for j = 2 : n
arr(j,:)=(p - x(j-1)) .* arr(j-1,:);
c(j,:) = a(j) .* arr(j,:);
end
f=sum(c);

 112 pts.] Let f(x)-2 sin (xx), where x is in radian. (a) Use quadratic Lagrange interpolation P2 (x) based on the nodes x,-= i, and X2 = 3, to approximate f(2)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site