1. Engineering
  2. Computer Science
  3. example...

Question: example...

Question details

Write a MATLAB function to implement the Hermite interpolation in Algorithm 3.3. Note that the index should run from 1 instead of 0 that is used in the textbook. This is because MATLAB does not allow index 0 Your function should use the same order of input below. Note that we do not return Q as in the algorithm. Instead, we calculate the interpolated function value at x. function y hermite (X,Y,YF,x) = X=number3 x 1 x 2 x n %-= value3 f(x 1) f(x 2) f(x n) x-interpolation, (x2) f(x y ïnterpolated function value at x, i.e. H(x) x 2) .. x n) x = interpolation point X your implementation below end Save your function in hermite.n, and interpolate the tabular function given below at the point x 1.25. f(r) 110517 f (x) 0.22103 0.59673 147576 1.0 2.0 2.45960 Your function should return 1.1690.

First divided differences Second divided differences f(z) 20, 2I 2 20 1 22 22-21 al 23 -2 22, 23 24 22 24-23 s-23

ALGORITHM Hermite Interpolation 3.3 To obtain the coefficients of the Hermite interpolating polynomial H(x) on the (n 1) distinct numbers xo, . xn for the function f: INPUT numbers xo, xi. . . .n; values f(xo OUTPUT the numbers Q0.0. Qi.1 , f() and f(xo), . .. , f(n) where + Q44(x - xo)-(r -xi2... Step 1 For i = 0, 1, … , n do Steps 2 and 3 Step 2 Set z2i = Xi; Q21.0 = f(xi); Q2i +1.0 = f(x); Q2i+1,1 = f,(xi) 0 then set Step 3 If i 2i.1 32i 22i- Step 4 Fori 2, 3, ,2n 1 Qij-1--1.j-I for j = 2.3. . . . ,i set Qi.j Step 5 OUTPUT (Qo,o. Q1,1.. . Q2n+1.2+ STOPexample

Table 3.15 f(xx) fCx) 13 0.6200860.5220232 1 -0.5698959 2 1.9 0.2818186 -0.5811571

Example 2 Use the data given in Example I and the divided difference method to determine the Hermite polynomial approximation at x = 1.5 Solution The underlined entries in the first three columns of Table 3.17 are the data given in Example 1. The remaining entries in this table are generated by the standard divided- difference formula (3.9) For example, for the second entry in the third column we use the second 1.3 entry in the second column and the first 1.6 entry in that column to obtain 0.4554022 0.6200860 1.6 1.3 =-0.5489460. For the first entry in the fourth column, we use the first 1.3 entry in the third column and the first 1.6 entry in that column to obtain -0.5489460 (-0.5220232) 1.6-1.3 =-0.0897427 The value of the Hermite polynomial at 1.5 is + f11.3, 1.3, 1.6, 1.6,1.9, 1.9.5 1.3)21.5 .62(1.5 1.9) = 0.6200860 + (-0.5220232) (0.2) + (-0.0897427) (0.2)2 + 0.0663657(0.2)2(-0. I ) + 0.0026663 (0.2)2(-0, 1)2 +(-0.0027738)(0.2)2-0.1)-0.4) = 0.5118277.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution