Docsity

interpolation exercise, Exercises of Mathematical Methods for Numerical Analysis and Optimization

Partial preview of the text

Download interpolation exercise and more Exercises Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

RYNP Course No. ME 3121 Numerical Computation for Mechanical Engineers Course Plan Topic No. of Classes Reference Books Interpolation 6 Classes 1&3 Numerical Differentiation and Integration 4 ,, 3 Solution of Transcendental/Nonlinear Equations 6 _,, 1&3 Solution of Linear Algebraic Equations 4 ,, 2&3 Curve Fitting 3, 2&3 Eigen value and Eigen vectors 2 4, 3 Solution of Ordinary Differential Equations 7 55 2&3 Solution of Partial Differential Equations 7 2&4 Total- 39 Classes Reference Books Numerical Mathematical Analysis By James B. Scarborough Numerical Methods for Engineers By S.C. Chapra & R.P. Canale Introductory Methods of Numerical Analysis By S.S. Sastry Computational Fluid Flow and Heat Transfer By K. Muralidhar & T. Sundararajon Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Interpolation This Chapter introduces the students to: 1. Interpolate a data within or outside (a bit away from the table) a set of tabular values of equal and unequal intervals. 2. Deduce the various formulae or methods for interpolation. At the end of study of this Chapter students will be able to: 1. Understand various formulae or methods for interpolation. 2. Solve the problems of determining the values in between two given data in a set of tabular values using different formulae and to compare their accuracy. Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Table 1: Diagonal (Forward) Difference Table Pty tty fay aly aty day day fay Xo Yo Ayo eT v1 A*Yo Ay, A°Yo X Y2 A’y, A*’Yo Ay» Ay A*yo %3 ¥3 Ay, A’y, A® yo Ay; Ay, A’y; A’Yo X4 Y4 A’y, Aty, Avy, Ay, A*y; A*y, X5 Ys A’y, Aty; Ays A*y, X6 Ye A’ys AY6 Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Table 2: Horizontal (Backward) Difference Table x ly vy [vy [vy [ity |vsy | isy Xo Yo Xy v1 Vy, X Yo Vy, Vy, V V2 v3 X3 Y3 Y3 Y3 Y3 Xq Ya V v4 V? vq V3 vq V4 vq Xs Ys Vy, Vy, V3y, V4y, V5 X¢ Ye Vy, V*y, V3y, Viye Veye V8 Ve Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Newton Forward Interpolation Formula : Our objective is to find suitable polynomial for replacing any given function over a given interval. Let y= f(x) denotes a function which takes the values Yoo¥1>""Y, for the equidistant values X9,x,,°"""x, of independent variable x and (x) denotes a polynomial of the n th degree. This polynomial may be written in the form Now we have to determine the values of ap, a), a)” a, So as to make (x9) = Yor O(X1) = ¥1, O(Ky)Fy; ete. As x values are equidistant then x,-x9= h, X»- Xp = 2h, ete. From eqn.(1)we may have (Xp) = ap OF, Yo =Aq 1... Ap = Yq Again $(x)) = y, = agta;(X,-Xo) Vi—4 _ Yio _ Ayo or, a, = = ST x, Xp h h Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Again (x2) = yo = ag tay (X-Xp) +a (X9-Xp) (X2-X1) = yo +42 (2h) + a2(2h)(h) Yo = Yo + 2 (¥1 — Yo) + a2 (2h?) ¥2—2y1+¥o AV a2 = = 2h? Bh? Similarly ag = 22322 3% = Yo _ _A*Yo__ AY ¥3 6h? 3.2.1h3 31h3 d A" yo A" yo and an = = ” 43.2.1hA" nihn Now putting the values of a9,a),a)°°"" a, in eqn.(1) we have A IN IN Ala) = yy += *(e—m)4 yee x, \x- nar Xp x — x, (x — x,t esesnsseseeetnsotneeenes sosecsssssssesecessessssseeeseesssseees Tia —Xp \r-x, or — 2p osaesna -x,,) EP) This is called Newton’s Formula for Forward Interpolation (NFFI) in terms of x. Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET This is the usually written NFFI. This formula is for forward interpolation because it contains values of tabulated functions from y, onward to the right (forward from yo) and none to the left of this value. This is mainly used to interpolate the values near the beginning of a set values and for extrapolating values of y at a short distance backward (to the left) from yo. The starting point y) may be any tabular value, but then the formula will contain only those value of y which one after the value chosen as starting point. Diagonal difference table is used for this formula. Newton’s Formula for Backward Interpolation: Newton’s Formula for Forward Interpolation cannot be used for interpolating a value of y near the end of the tabular values. To derive a formula for this case we write the polynomial in the following form: To determine the values of ap, a), a)...a, SO as to make (x) = y,, O(X,.,) = Yn. etc. O(X,) = Yn = ay So, a9= Yn (Xy1) = Yn-1 = A $44 (X%p-1 — Xp) =Yn + a,(-h) or, a, = (Yn ~~ Yn-p/h = Avy,/h Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Similarly, a,= A,y,/2!h?, a, = Ay, /3!h?, a,= Agy, /4tht......... Therefore, AiYn x — Xn Az Yn (* — Xn\ (*X — Xn-1 A3¥n X ~ Xn\ (X — Xn-1\ (X — Xn-2 oO) = = ya + PE) + SS) (GG) AnYn xX —Xn\ (X — Xn-1\ (X — Xn-2 xX — X41 ssn yn (an) (a Anaa) (Hac) SA @ This is Newton’s formula for Backward Interpolation in terms of x. Again, this formula can be modified in the previous way putting u=(x-x,)/h or, x =x, + hu Again, (x — x,_,/h= {x - (x, —h)}/h=(x-x,)/h+hh=utl u(u + 1) d(x) = G(x, +hu)=y, +uAvy, + Ay, tu((ut Du + 2)) Par eceeeteeeeeseeeeneeenees ees eaeeeesessesecsesecsessesesessesees +u(u+l\u+2).....(utn -1)Aove nl This is the Newton’s Formula for Backward Interpolation. Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Solution. We first form the table of differences, as shown below: Xx y =log,)x Ay A’y A}y 3.141 0.4970679364 0.0001382443 3.142 0.4972061807 0.0000000440 0.0001382003 -0.0000000001 3.143 0.4973443810 0.0000000439 0.0001381564 0.0000000001 3.144 0.4974825374 0.0000000440 0.0001381124 3.145 0.4976206498 Here x = m = 3.1415926536, xg = 3.141, h = 0.001. Hence wow, 31415926536-3.141 ho 0.001 = 0.5926536 u= u-1 = - 0.4073464, etc. Substituting these values in Newton’s formula for Forward Interpolation, We get Log) 1=0.4970679364 + 0.5926536(0.0001382443) + 4 0.5926536 (0:5926536~1)(0.5926536 - 2) (-0.0000000001) 0.5926536 (0.5926536"1) (0.0000000440) = 0.4971498727 This result is correct to its last figure. Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Problem 02. Using the tabular values of the preceding Problem, find logio 3.140 Solution: Here x = x-1 = 3.140, xo = 3.141, h = 0.001. Hence X—Xq X-1—-X%q_ TA ho ho Rh u-1 = - 2,etc u— =-I1, Logio 3.140 = 0.4970679364+(-1)(0.0001382443) + coces (0.0000000440) (-1)(-1- )C1-2) + 6 = 0.4969296481 This result is also correct to its last figure. (—0.0000000001) Note: The process of computing the value of a function outside the range of given values, as in the example above, is called extrapolation. It should be used with caution, but if the function is known to run smoothly near the ends of the range of given values, and if h is taken as small as it should be, we are usually safe in extrapolating for a distance h outside the range of given values. Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET To find sin 38°, we use Newton’s backward difference formula with x,= 40 and x = 38. This gives X7Xy 38-40 _ hoo 5” _ 2 us 5 Hence, using NFBI formula , we obtain ACOA (-0,0043652) y(38) = 0.6427876 — 0.4 (0.0692112)+ % (0.4) (—0.4 + 1) (—0.4 + 2) ; (—0.0005599) 4 €0-4)(-0.4 + 1)(-0.4 + 2)(-0.4 +3) 24 4s (0.4) (0.4 + 1) (-0.4 + 2)(—0.4 + 3)(—0.4 + 4) 120 = 0,6427876 — 0.02768448 + 0.00052382 + 0.00003583 — 0.00000120 (0.0000289) (0.000004 1) = 0.6156614. Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Interpolation with Unequal Intervals of the Arguments Divided Difference: Let (x9, Vo): (%1,.41),---:(%)>¥,) be the given (7+1) points. Then the divided differences of order 1, 2,..., are defined by the relations: 1 — Yo [x9, 4, ]=———., x) — Xo [xo x; ty] = Catal bo *1] Bs gree. > +2 — Xo [My Pn 2-5 My | [Mey Bornes Xn] xy — *9 [X05 15 ++ XJ = Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET Hence the general form of divided difference is as follows- x, = y + Yo nm’ («— x09) (kK — x1). K—x,) (Ko — Xx) (Kg —X1).--- 0 — Xn) Vn (4, — x) G4, = Xo )e-- Ge =) (2, = *) Cen = Xo) Con = 1 eGo = Xn) Relation between. Simple difference and Divided Difference : To compare these two, let us consider equal interval for both the cases and the following differences are found. 24 Diff. (For equal interval) Simple Diff. Divided Diff. y2 yi _ _ _ O(xX,, X,,%,)= + (v2 -yi)-Gi yo) Bett) Bea) Gm) Gm) Yo My, =¥,-2y, +N *G—x)(% x) _ +2 4 v1 4 Yo So, the divided diff. = simple diff. >> 2hh h{-h) -h.-2h , _ 327 2Vi + Vo Wh? Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET 3" Diff. (For equal interval) Simple Diff. Divided Diff. A’yy = ¥3 —3¥. +3, —Y S(%35%p5X1sX) = V3 —3¥2 +3Vi — Vo 3h.2h.h — ¥3 32 +31 — Vo 31h° So, the divided diff. = Simple diff. x af In general sense, Divided diff. = Simple diff. x me n: . Divided Diff= Simple Diff «—— ni Fahim Al Galib, Lecturer(Part-time), Dept. of ME, KUET