numericai matmatic matlab uygulamalar ali abdullah

25
sayısal yöntemler ve matlab uygulamalar Numerical Methods And MATLAB Applications interpolation method Prepeared by Ali Abdullah.yousif

Transcript of numericai matmatic matlab uygulamalar ali abdullah

Page 1: numericai matmatic  matlab  uygulamalar ali abdullah

sayısal yöntemler ve matlab uygulamalar

Numerical Methods And MATLAB Applications

“interpolation methodPrepeared by Ali Abdullah.yousif

Page 2: numericai matmatic  matlab  uygulamalar ali abdullah

Content: Newton's forward interpolation

method Newton's backward interpolation

method central difference interpolation gauss forward difference

interpolation formula Gauss backward difference

interpolation formula Stirling interpolation formula

Page 3: numericai matmatic  matlab  uygulamalar ali abdullah
Page 4: numericai matmatic  matlab  uygulamalar ali abdullah

Newton's forward interpolation methodForward difference operator are shown. wherein the first table. a difference table as shown is prepared.The difference between the values corresponding to the data is represented.   Overall, with the of the differences and higher-order differences are calculated as the difference of the previous differences. difference values. (xo)

&forward finite difference table

xi

Page 5: numericai matmatic  matlab  uygulamalar ali abdullah

( (6.42). =

(6.47)

The formula given in Eq.(6.47) is called the Newton’s forward interpolation formula. This formula is used to interpolate the values of y near the beginning of a set of equally spaced tabular values. This formula can also be used for extrapolating the values of y a little backward .

Page 6: numericai matmatic  matlab  uygulamalar ali abdullah

Example: find yor using the following table.

Solution: The difference table is shown in below: We have Hence Using Newton s forward formula

0.4 0.3 0.2 0.1 0

3.3201 2.4596 1.8221 1.3499 1 y=

1.0000 0

0.1224 0.3499

1.3499 0.1

0.0150 0.0428 0.1652 0.4723

1.8221 0.2

0.0578 0.2230 0.6375

2.4596 0.3

0.8605 3.3201 0.4

Page 7: numericai matmatic  matlab  uygulamalar ali abdullah

Eample:newton to forward data in the table with the correct interpolation method.A) second degree.B)-Find the third degree polynomial.C) same method for (0.34) to calculate the reputation value.D) for third-degree polynomial interpolation (0.34) Develop a MATLAB program to calculate the reputation value.Solution: A) table data given in the question. that is the function of a cubic function. the real value of the polynomial at

the point, as shown below 1.271 Using newton eq. …..

B)

0.6 0.5 0.4 0.3 0.2 0.1

1.936

1.625

1.384

1.207

1.088

1.021

0.067

1.021 0.1

0.052 0.119

1.088 0.2

0.000 0.006 0.058 0.177

1.207 0.3

0.000 0.006 0.064 0.241

1.384 0.4

0.006 0.070 0.311

1.625 0.5

1.936 0.6

Page 8: numericai matmatic  matlab  uygulamalar ali abdullah

B) ..

C) x=0.34 and 0.064

actual relative error for the second-degree polynomial.

actual relative error for the third-degree polynomial.

Page 9: numericai matmatic  matlab  uygulamalar ali abdullah

>> x=[0.1 0.2 0.3 0.4 0.5 0.6 ]; y=[1.021 1.088 1.207 1.384 1.625 1.9361]; x0=0.34; degree=3; n=size(x,2); f=zeros(n,n); for i=1:n-1 f(i,1)=(y(i+1)-y(i)); end; for j=2:n-1 for i=1:n-j f(i,j)=(f(i+1,j-1)-f(i,j-1)); end; end; d=abs(x-x0); ind=find(d==min(d)); differencevalue =[y(ind) f(ind,:)]; alpha=(x0-x(ind))/(x(2)-x(1)) fx=differencevalue(1)+alpha+differencevalue(2); fori=i:degree product=alpha for j=i:i product=product*(alpha-j); end; fx=fx+product*differencevalue(i+2)/factorial(i+1); alpha = 0.4000 fori = 1 2 3 product = 0.4000

Page 10: numericai matmatic  matlab  uygulamalar ali abdullah

Newton's backward interpolation methodbackward difference operator. are shown. wherein a difference in the table as in the forward difference method is prepared. numerical values in the table is the same as the forward difference table for recognizing the numerical values are different. () corresponding to you efficiency ()) the difference between the values are represented.  when asked what happened to the money that the calculation of the values at the beginning of the use of table functions .newton backward difference equation. Newton’s forward interpolation formula is not suitable for interpolation values of y near the end of a table of values.

(xo)

(6.55)

(6.56)

Estimated error value:

Page 11: numericai matmatic  matlab  uygulamalar ali abdullah

Eample:From the following table estimate the number of student who obtained mark in computer programming between 75 and 80 .

Solution: The cumulative frequency table is shown in the table .To find the number of student with mark less than 80Let =-0.5 then using NEWTON backward formula we obtain

so number of student getting marks in computer programming between 75 and 80=198-180=18

75-85 65-75 55-65 45-55 35-45 Mark

20 60 60 40 20 No.of student

No.of student

Mark lessthan(x)

20 45

40 60 55

20 60 120 65

-20 0 60 180 75

-20 -40 -40 20 200 85

Page 12: numericai matmatic  matlab  uygulamalar ali abdullah

Example: using the data given in 6.4, with Newton's backward difference formula.

a) Find a polynomial of second and third degree.b) the same method to calculate x = 0:34 reputation value.c) the polynomial interpolation from 3.derece f = (0.39) to

develop a program that will calculate .

Solution:prepared for the difference in the table can be used to calculate .method point but according to this example the function () must be selected by considering, for example, x = 0.5. step size value .(so has the second-degree polynomial as follows using the first and second order forward difference terms.

third degree polynomial interpolation from 3.derece

1.021 0.1

0.052 0.067 1.088 0.2

0.006 0.058 0.119 1.207 0.3

0.006 0.064

0.177 1.384 0.4

0.006 0.070 0.241 1.625 0.5

0.311 1.936 0.6

Page 13: numericai matmatic  matlab  uygulamalar ali abdullah

B) ..C) x=0.34 and

Page 14: numericai matmatic  matlab  uygulamalar ali abdullah

x=[0.1 0.2 0.3 0.4 0.5 0.6 ]; y=[1.021 1.088 1.207 1.625 1.936 ]; xn=0.39; x=[0.1 0.2 0.3 0.4 0.5 0.6 ]; y=[1.021 1.088 1.207 1.384 1.625 1.9361]; xn=0.34; degree=3; n=size(x,2); f=zeros(n,n); for i=1:n-1 f(i,1)=(y(i+1)-y(i)); end; for j=2:n-1 for i=1:n-j f(i,j)=(f(i+1,j-1)-f(i,j-1)); end; end; ind=find(x>xn); ind=ind(1); xind=ind:-1:ind-degree+1; yind=1:i:degree; differencevalue=[y(ind+1) f(sub2ind(size(f),xind,yind))] alpha=(xn-x(ind+1))/(x(2)-x(1)); fx=differencevalue(1)+alpha+differencevalue(2); for i=1:degree-1 product=alpha; for j=1:i product=product*(alpha+j); end; fx=fx+product*differencevalue(i+2)/factorial(i+1); End ; differencevalue = 1.6250 0.2410 0.0640 0.0060

Page 15: numericai matmatic  matlab  uygulamalar ali abdullah

CENTRAL DIFFERENCE INTERPOLATION a step size equal to f(x) function ( ) center at the point of difference, will be recognized. The central difference operator, indicated by Various central difference formula for the intermediate values can be used in prepared statements difference. about the central difference correlations are shown below.

at

Page 16: numericai matmatic  matlab  uygulamalar ali abdullah
Page 17: numericai matmatic  matlab  uygulamalar ali abdullah
Page 18: numericai matmatic  matlab  uygulamalar ali abdullah

Example: using the data given in 6.4, the central difference interpolation method, the first and. finding a second and third degree polynomial x = 0:34 calculate the values: Prepared difference table used for this example. According to the method for the function to be calculated in 0.34 point x = (xo < x < x1) must be chosen as the x = 0.3 and x = 0.4.step size value h = x-x1 = 0.1

Second degree central difference interpolation

At x=0.34 then Third degree central difference interpolation

𝑓 (𝑥 )= 𝑓 𝑜+(𝑥−𝑥𝑜 ) 𝛿 𝑓 12

→ 𝑓 ( 𝑥 )=1 .207+( 𝑥− 0 . 3 ) 0 . 177

0.067

1.021

0.1

0.052

0.119

1.088

0.2

0.006

0.058

0.177

1.207

0.3

0.000 0.006

0.064

0.241

1.384

0.4

0.000 0.006

0.070

0.311

1.625

0.5

1.936

0.6

Page 19: numericai matmatic  matlab  uygulamalar ali abdullah
Page 20: numericai matmatic  matlab  uygulamalar ali abdullah
Page 21: numericai matmatic  matlab  uygulamalar ali abdullah
Page 22: numericai matmatic  matlab  uygulamalar ali abdullah
Page 23: numericai matmatic  matlab  uygulamalar ali abdullah
Page 24: numericai matmatic  matlab  uygulamalar ali abdullah
Page 25: numericai matmatic  matlab  uygulamalar ali abdullah