Lecture (6) 1 Engineering Mathematics (5) Numerical Analysis PHM2111 Prof. Dr. Nasser H. Sweilam nsweilam@sci.cu.edu.eg PHM2111 week (7) Fall 2020, 2/12/2020 Outline 2 ο Direct Method of Interpolation ο Interpolation and Polynomial approximation (Newton Divided differences ) ο Interpolation and Polynomial approximation (Lagrange Interpolation ) PHM2111 week (7) Fall 2020, 2/12/2020 What is Interpolation? 3 A function π¦ = π π₯ is given only at discrete points such as π₯0 , π¦0 , π₯1 , π¦1 , . . . . . . , π₯π−1 , π¦π−1 , π₯π , π¦π . How does we find the value of y at any other value of π₯? Well, a continuous function π π₯ may be used to represent the π + 1 data values with π π₯ passing through the π + 1 points. Then we can find the value of π¦ at any other value of π₯. This is called interpolation. Of course, if π₯ falls outside the range of π₯ for which the data is given, it is no longer interpolation but instead is called extrapolation. PHM2111 week (7) Fall 2020, 2/12/2020 Interpolation 4 Figure 1 Interpolation of discrete data PHM2111 week (7) Fall 2020, 2/12/2020 Direct Method 5 The direct method of interpolation is based on the following premise. Given π + 1 data points, fit a polynomial of order π as given below π¦ = π0 + π1 π₯+. . . +ππ π₯ π (1) through the data, where π0 , π1 . . . , ππ Are π + 1 real constants. Since π + 1 values of π¦ are given at π + 1 values of π₯, we can write π + 1 equations. Then the π + 1 Constants π0 , π1 . . . , ππ can be found by solving the π + 1 simultaneous linear equations. To find the value of π¦ at a given value of π₯, simply substitute the value of π₯ in Equation 1. But, it is not necessary to use all the data points. How does we then choose the order of the polynomial and what data points to use? This concept and the direct method of interpolation are best illustrated using examples. PHM2111 week (7) Fall 2020, 2/12/2020 Example 1 The upward velocity of a rocket is given as a function of time in Table 1. 6 t (s) V(t) (m/s) 0 10 15 20 22.5 30 0 227.04 362.78 517.35 602.97 901.67 Table 1 Velocity as a function of time. Determine the value of the velocity at π = ππ seconds using the direct method of interpolation first order polynomial. PHM2111 week (7) Fall 2020, 2/12/2020 Solution For first order polynomial interpolation (also called linear interpolation), the velocity given by 0 1 Since we want to find the velocity at π = ππ , and we are using a first order polynomial, we need to choose the two data points that are closest to π = ππ that also bracket π = ππ to evaluate it. The two points are π0 = π5 and π1 = 20 . Then ππ = ππ, π ππ = πππ. ππ & ππ = ππ, π ππ = πππ. ππ Gives π ππ = ππ + ππ ππ = πππ. ππ π ππ = ππ + ππ ππ = πππ. ππ Writing the equations in matrix form, we have ο©1 15 οΉ ο©a0 οΉ ο©362.78οΉ οͺ1 20οΊ οͺ a οΊ ο½ οͺ517.35οΊ ο« ο»ο« 1 ο» ο« ο» v ο¨t ο© ο½ a ο« a t Solving the above two equations gives π0 = −100.93, π1 = 30.914 At π = ππ π£ π‘ = −100.93 + 30.914π‘ → π£ 16 = 393.7 m/s PHM2111 week (7) 7 Fall 2020, 1/11/2020 Example 2 use table 1 in the pervious example to determine the value of the velocity at π = ππ seconds using the direct method of interpolation second order polynomial. 8 For second order polynomial interpolation (also called quadratic interpolation), the velocity is given by 2 vο¨t ο© ο½ a0 ο« a1t ο« a2 t Since we want to find the velocity at π = ππ , and we are using a second order polynomial, we need to choose the three data points that are closest to π = ππ that also bracket π = ππ to evaluate it. The three points are Then t 0 ο½ 10, t1 ο½ 15, and t 2 ο½ 20 vο¨10ο© ο½ a0 ο« a1 ο¨10ο© ο« a2 ο¨10ο© ο½ 227.04 2 vο¨15ο© ο½ a0 ο« a1 ο¨15ο© ο« a2 ο¨15ο© ο½ 362.78 2 vο¨20ο© ο½ a0 ο« a1 ο¨20ο© ο« a2 ο¨20ο© ο½ 517.35 2 PHM2111 week (7) Fall 2020, 2/12/2020 Writing the three equations in matrix form, we have ο©1 10 100 οΉ ο©a0 οΉ ο©227.04οΉ οͺ1 15 225οΊ οͺ a οΊ ο½ οͺ362.78οΊ οͺ οΊοͺ 1 οΊ οͺ οΊ οͺο«1 20 400οΊο» οͺο«a 2 οΊο» οͺο«517.35οΊο» Solving the above three equations gives π0 = 12.05, π1 = 17.733, πππ π2 = 0.3766 Hence vο¨t ο© ο½ 12.05 ο« 17.733t ο« 0.3766t 2 , 10 ο£ t ο£ 20 At π‘ = 16 vο¨16ο© ο½ 12.05 ο« 17.733ο¨16ο© ο« 0.3766ο¨16ο© 2 ο½ 392.19 m/s Example 3:- use table 1 in the pervious example to determine the value of the velocity at π = ππ seconds using the direct method of interpolation third order polynomial. v ο¨16 ο© ο½ ο4.2540 ο« 21.266 ο¨16 ο© ο« 0.13204 ο¨16 ο© ο« 0.0054347 ο¨16 ο© ο½ 392.06 m/s 2 PHM2111 week (7) 9 3 Fall 2020, 2/12/2020 Comparison Table 10 Order of Polynomial π£ π‘ = 16 m/s 1 2 3 393.7 392.19 392.06 Absolute Relative ---------- 0.38410 % 0.033269 % Approximate Error PHM2111 week (7) Fall 2020, 2/12/2020 Newton’s Divided Difference Polynomial Method 11 • Linear Interpolation • Quadratic Interpolation PHM2111 week (7) Fall 2020, 2/12/2020 1- Linear Interpolation 12 The simplest form of interpolation is to connect two data points with a straight line. This technique, called linear interpolation, f1 ο¨ x ο© ο f ο¨ x0 ο© f ο¨ x1 ο© ο f ο¨ x0 ο© ο½ x ο x0 x1 ο x0 which can be rearranged to yield f ο¨ x1 ο© ο f ο¨ x0 ο© f1 ο¨ x ο© ο½ f ο¨ x0 ο© ο« ο¨ x ο x0 ο© x1 ο x0 f1 ο¨ x ο© ο½ b0 ο« b1 ο¨ x ο x0 ο© which is the Newton linear-interpolation formula. The notation f1(x) designates that this is a first-order interpolating polynomial. PHM2111 week (7) Fall 2020, 2/12/2020 f ο¨ x1 ο© f1 ο¨ x ο© f ο¨ x0 ο© x0 PHM2111 week (7) x1 13 Fall 2020, 2/12/2020 Example 14 The upward velocity of a rocket is given as a function of time in Table 1. Find the velocity at t = 16 seconds using the Newton Divided Difference method for linear interpolation. π‘(s 0 10 15 20 22.5 30 π£(π‘ (m/s 0 227.04 362.78 517.35 602.97 901.67 at t = 16 PHM2111 week (7) b0 ο½ v(t0 ) ο½ 362.78 b1 ο½ v(t1 ) ο v(t0 ) ο½ 30.914 t1 ο t0 v(t ) ο½ b0 ο« b1 (t ο t 0 ) ο½ 362.78 ο« 30.914(t ο 15), v(16) ο½ 362.78 ο« 30.914(16 ο 15) ο½ 393.69 m / s Fall 2020, 2/12/2020 2- Quadratic Interpolation 15 Given (π₯0 , π¦0 , (π₯1 , π¦1 , πππ (π₯2 , π¦2 fit a quadratic interpolate through the data. f 2 ( x) ο½ b0 ο« b1 ( x ο x0 ) ο« b2 ( x ο x0 )( x ο x1 ) At π₯ = π₯0 b0 ο½ f ( x0 ) At π₯ = π₯1 b1 ο½ At π₯ = π₯2 PHM2111 week (7) f ( x1 ) ο f ( x0 ) x1 ο x0 f ( x2 ) ο f ( x1 ) f ( x1 ) ο f ( x0 ) ο x2 ο x1 x1 ο x0 b2 ο½ x2 ο x0 Fall 2020, 2/12/2020 Example 16 The upward velocity of a rocket is given as a function of time in Table 1. Find the velocity at t = 16 seconds using the Newton Divided Difference method for quadratic interpolation. π‘(s 0 10 15 20 22.5 30 π£(π‘ (m/s 0 227.04 362.78 517.35 602.97 901.67 MATH206 week (7) t0 ο½ 10, t1 ο½ 15 and t2 ο½ 20 b0 ο½ v(t0 ) ο½ 227.4 b1 ο½ v(t1 ) ο v(t0 ) ο½ 27.148 t1 ο t0 v(t2 ) ο v(t1 ) v(t1 ) ο v(t0 ) ο t2 ο t1 t1 ο t0 b2 ο½ ο½ 0.3766 t 2 ο t0 Fall 2020, 2/12/2020 v(t ) ο½ b0 ο« b1 (t ο t 0 ) ο« b2 (t ο t 0 )(t ο t1 ) ο½ 227.04 ο« 27.148(t ο 10) ο« 0.37660(t ο 10)(t ο 15), at t = 16 v(16) ο½ 227.04 ο« 27.148(16 ο 10) ο« 0.37660(16 ο 10)(16 ο 15) ο½ 392.19 PHM2111 week (7) 17 Fall 2020, 1/11/2020 The Lagrange interpolating polynomial PHM2111 week (9) 18 Fall 2020, 2/12/2020 The Lagrange interpolating polynomial is given by π ππ (π₯ = πΏπ (π₯ π(π₯π π=0 Where π in π(π₯ stands for the ππ‘β order polynomial that approximates the function π¦ = π(π₯ given at π + 1 data points as π₯0, π¦0 , π₯1, π¦1 , … , π₯π, π¦π and π π₯ − π₯π πΏπ π₯ = , π₯π − π₯π π=0 π≠π πΏπ π₯ is a weighting function that includes a product of π − 1 terms with terms π = π of omitted. The application of Lagrange interpolation will be clarified using an example. PHM2111 week (7) 19 Fall 2020, 2/12/2020 For example 1) First order Lagrange interpolating polynomial [ we use only two points (x0 , f(x0)) , (x1 , f(x1)) ] ο¦ 1 x ο xj ο§ f1 ο¨ x ο© ο½ ο₯ f ο¨ xi ο© ο ο§ i ο½0 ο§ j ο½ 0 xi ο x j iοΉ j ο¨ 1 οΆ ο· ο½ ο¨ x ο x1 ο© f ο¨ x ο© ο« ο¨ x ο x0 ο© f ο¨ x ο© 0 1 ο· ο¨ x0 ο x1 ο© x ο x ο¨ ο© 1 0 ο· οΈ 2) second order Lagrange interpolating polynomial [ we use only 3 points (x0 , f(x0)) , (x1 , f(x1)) , (x1 , f(x2))] ο¦ οΆ 2 x ο x x ο x1 ο©ο¨ x ο x2 ο© ο¨ j ο· ο§ f 2 ο¨ x ο© ο½ ο₯ f ο¨ xi ο© ο ο½ f ο¨ x0 ο© ο§ ο· ο¨ x0 ο x1 ο©ο¨ x0 ο x2 ο© i ο½0 ο§ j ο½ 0 xi ο x j ο· iοΉ j ο¨ οΈ x ο x0 ο©ο¨ x ο x2 ο© x ο x0 ο©ο¨ x ο x1 ο© ο¨ ο¨ ο« f ο¨ x1 ο© ο« f ο¨ x2 ο© ο¨ x1 ο x0 ο©ο¨ x1 ο x2 ο© ο¨ x2 ο x0 ο©ο¨ x2 ο x1 ο© 2 It is to be noticed that each term of the nth order Lagrange interpolating polynomial of order n. PHM2111 week (7) 20 Fall 2020, 2/12/2020 The nth order Lagrange interpolating polynomial is ο¦ οΆ n x ο x j ο· f n ο¨ x ο© ο½ ο₯ ο§ f ο¨ xi ο© ο ο§ ο· i ο½0 ο§ j ο½ 0 xi ο x j ο· iοΉ j ο¨ οΈ x ο x1 ο©ο¨ x ο x2 ο© ... ο¨ x ο xn ο© ο¨ ο½ f ο¨ x0 ο© ο¨ x0 ο x1 ο©ο¨ x0 ο x2 ο© ... ο¨ x0 ο xn ο© n x ο x0 ο©ο¨ x ο x2 ο© ... ο¨ x ο xn ο© ο¨ ο« f ο¨ x1 ο© ο¨ x1 ο x0 ο©ο¨ x1 ο x2 ο© ... ο¨ x1 ο xn ο© x ο x0 ο©ο¨ x ο x1 ο©ο¨ x ο x3 ο© ... ο¨ x ο xn ο© ο¨ ο« f ο¨ x2 ο© ο« ... ο« ο¨ x2 ο x0 ο©ο¨ x2 ο x1 ο©ο¨ x2 ο x3 ο© ... ο¨ x2 ο xn ο© ο¨ x ο x0 ο©ο¨ x ο x1 ο©ο¨ x ο x2 ο© ... ο¨ x ο xn ο1 ο© f x ο¨ nο© ο¨ xn ο x0 ο©ο¨ xn ο x1 ο©ο¨ xn ο x2 ο© ... ο¨ xn ο xn ο1 ο© PHM2111 week (7) 21 Fall 2020, 2/12/2020 Example:- Given the following data x 1 4 6 f(x) 0 1.386294 1.791760 Use Lagrange interpolating polynomial of the first order and the second order to evaluate f(2) Solution 1st order Lagrange interpolating polynomial [ we use only two points (1,0) , (4 , 1.386294) ] 1 1 i ο½0 j ο½0 iοΉ j f1 ο¨ x ο© ο½ ο₯ f ο¨ xi ο© ο x ο xj xi ο x j x ο x1 ο© x ο x0 ο© ο¨ ο¨ ο½ f ο¨ x0 ο© ο« f ο¨ x1 ο© ο¨ x0 ο x1 ο© ο¨ x1 ο x0 ο© x ο 4ο© x ο 1ο© ο¨ ο¨ ο½ ο¨ 0ο© ο« ο¨1.386294 ο© ο¨1 ο 4 ο© ο¨ 4 ο 1ο© 2 ο 1ο© ο¨ f1 ο¨ 2 ο© ο½ ο¨1.386294 ο© ο½ 0.4620981 ο¨ 4 ο 1ο© PHM2111 week (7) 22 Fall 2020, 1/11/2020 2nd order Lagrange interpolating polynomial [ we use only three points (1,0) , (4 , 1.386294) , (6, 1.791760)] ο¦ οΆ 2 xοx j ο· f 2 ο¨ x ο© ο½ ο₯ ο§ f ο¨ xi ο© ο ο§ ο· i ο½0 ο§ j ο½ 0 xi ο x j ο· iοΉ j ο¨ οΈ x ο x1 ο©ο¨ x ο x2 ο© x ο x0 ο©ο¨ x ο x2 ο© x ο x0 ο©ο¨ x ο x1 ο© ο¨ ο¨ ο¨ ο½ f ο¨ x0 ο© ο« f ο¨ x1 ο© ο« f ο¨ x2 ο© ο¨ x0 ο x1 ο©ο¨ x0 ο x2 ο© ο¨ x1 ο x0 ο©ο¨ x1 ο x2 ο© ο¨ x2 ο x0 ο©ο¨ x2 ο x1 ο© 2 x ο 4 ο©ο¨ x ο 6 ο© x ο 1ο©ο¨ x ο 6 ο© x ο 1ο©ο¨ x ο 4 ο© ο¨ ο¨ ο¨ f2 ο¨ x ο© ο½ ο¨0ο© ο« ο¨1.386294 ο© ο« ο¨1.791760 ο© ο¨1 ο 4 ο©ο¨1 ο 6 ο© ο¨ 4 ο 1ο©ο¨ 4 ο 6 ο© ο¨ 6 ο 1ο©ο¨ 6 ο 4 ο© 2 ο 1ο©ο¨ 2 ο 6 ο© 2 ο 1ο©ο¨ 2 ο 4 ο© ο¨ ο¨ f2 ο¨ 2ο© ο½ ο¨1.386294 ο© ο« ο¨1.791760 ο© ο¨ 4 ο 1ο©ο¨ 4 ο 6 ο© ο¨ 6 ο 1ο©ο¨ 6 ο 4 ο© ο½ 0.5658444 PHM2111 week (7) 23 Fall 2020, 2/12/2020 Example:- Consider the four points x f(x) 3.35 3.40 3.50 3.60 0.298507 0.294118 0.285714 0.277778 which satisfy the simple function y = f(x) = 1/x: Use Lagrange interpolating polynomial of the first order, the second order and the third order to evaluate f(3.44) Solution Let’s interpolate for y = f(3.44) using linear, quadratic, and cubic Lagrange interpolating polynomials. The exact value is y = 1/3.44 = 0.290698.... PHM2111 week (7) 24 Fall 2020, 2/12/2020 Linear interpolation using the two closest points, x = 3.40 and 3.50, yields x ο x1 ο© x ο x0 ο© ο¨ ο¨ f1 ο¨ x ο© ο½ f ο¨ x0 ο© ο« f ο¨ x1 ο© ο¨ x0 ο x1 ο© ο¨ x1 ο x0 ο© ο¨ x ο 3.50 ο© 0.294118 ο« ο¨ x ο 3.40 ο© 0.285714 f1 ο¨ x ο© ο½ ο¨ ο© ο¨ ο© ο¨ 3.40 ο 3.50 ο© ο¨ 3.50 ο 3.40 ο© f1 ο¨ 3.44 ο© ο½ ο¨ 3.44 ο 3.50 ο© 0.294118 ο« ο¨ 3.44 ο 3.40 ο© 0.285714 ο½ 0.290756 ο¨ ο© ο¨ ο© ο¨ 3.40 ο 3.50 ο© ο¨ 3.50 ο 3.40 ο© PHM2111 week (7) 25 Fall 2020, 2/12/2020 Quadratic interpolation using the three closest points, x = 3.35, 3.40, and 3.50, gives f2 ο¨ x ο© ο½ ο¨ x ο x1 ο©ο¨ x ο x2 ο© f x ο« ο¨ x ο x0 ο©ο¨ x ο x2 ο© f x ο« ο¨ x ο x0 ο©ο¨ x ο x1 ο© f x ο¨ 0ο© ο¨ 1ο© ο¨ 2ο© x ο x x ο x x ο x x ο x x ο x x ο x ο¨ 0 1 ο©ο¨ 0 2 ο© ο¨ 1 0 ο©ο¨ 1 2 ο© ο¨ 2 0 ο©ο¨ 2 1 ο© ο¨ x ο 3.40 ο©ο¨ x ο 3.50 ο© 0.298507 ο« ο¨ x ο 3.35ο©ο¨ x ο 3.50 ο© 0.294118 ο¨ ο© ο¨ ο© ο¨ 3.35 ο 3.40 ο©ο¨ 3.35 ο 3.50 ο© ο¨ 3.40 ο 3.35ο©ο¨ 3.40 ο 3.50 ο© ο¨ x ο 3.35ο©ο¨ x ο 3.40 ο© 0.285714 ο« ο¨ ο© ο¨ 3.50 ο 3.35ο©ο¨ 3.50 ο 3.40 ο© f2 ο¨ x ο© ο½ 3.44 ο 3.40 ο©ο¨ 3.44 ο 3.50 ο© 3.44 ο 3.35 ο©ο¨ 3.44 ο 3.50 ο© ο¨ ο¨ f 2 ο¨ 3.44 ο© ο½ ο¨ 0.298507 ο© ο« ο¨ 0.294118ο© ο¨ 3.35 ο 3.40 ο©ο¨ 3.35 ο 3.50 ο© ο¨ 3.40 ο 3.35 ο©ο¨ 3.40 ο 3.50 ο© ο¨ 3.44 ο 3.35ο©ο¨ 3.44 ο 3.40 ο© 0.285714 ο½ 0.290697 ο« ο¨ ο© ο¨ 3.50 ο 3.35ο©ο¨ 3.50 ο 3.40 ο© PHM2111 week (7) 26 Fall 2020, 2/12/2020 Cubic interpolation using all four points yields x ο x1 ο©ο¨ x ο x2 ο©ο¨ x ο x3 ο© x ο x0 ο©ο¨ x ο x2 ο©ο¨ x ο x3 ο© ο¨ ο¨ f3 ο¨ x ο© ο½ f ο¨ x0 ο© ο« f ο¨ x1 ο© ο¨ x0 ο x1 ο©ο¨ x0 ο x2 ο©ο¨ x0 ο x3 ο© ο¨ x1 ο x0 ο©ο¨ x1 ο x2 ο©ο¨ x1 ο x3 ο© ο¨ x ο x0 ο©ο¨ x ο x1 ο©ο¨ x ο x3 ο© f x ο« ο¨ x ο x0 ο©ο¨ x ο x1 ο©ο¨ x ο x2 ο© f x ο« ο¨ 2ο© ο¨ 3ο© x ο x x ο x x ο x x ο x x ο x x ο x ο¨ 2 0 ο©ο¨ 2 1 ο©ο¨ 2 3 ο© ο¨ 3 0 ο©ο¨ 3 1 ο©ο¨ 3 2 ο© 3.44 ο 3.40 ο©ο¨ 3.44 ο 3.50 ο©ο¨ 3.44 ο 3.60 ο© ο¨ f 3 ο¨ 3.44 ο© ο½ ο¨ 0.298507 ο© ο¨ 3.35 ο 3.40 ο©ο¨ 3.35 ο 3.50 ο©ο¨ 3.35 ο 3.60 ο© ο¨ 3.44 ο 3.35 ο©ο¨ 3.44 ο 3.50 ο©ο¨ 3.44 ο 3.60 ο© 0.294118 ο« ο¨ ο© ο¨ 3.40 ο 3.35 ο©ο¨ 3.40 ο 3.50 ο©ο¨ 3.40 ο 3.60 ο© 3.44 ο 3.35 ο©ο¨ 3.44 ο 3.40 ο©ο¨ 3.44 ο 3.60 ο© ο¨ ο« ο¨ 0.285714 ο© ο¨ 3.50 ο 3.35 ο©ο¨ 3.50 ο 3.40 ο©ο¨ 3.50 ο 3.60 ο© 3.44 ο 3.35 ο©ο¨ 3.44 ο 3.40 ο©ο¨ 3.44 ο 3.50 ο© ο¨ ο« ο¨ 0.277778ο© ο¨ 3.60 ο 3.35 ο©ο¨ 3.60 ο 3.40 ο©ο¨ 3.60 ο 3.50 ο© ο½ 0.290698 PHM2111 week (7) 27 Fall 2020, 2/12/2020 The results are summarized below, where the results of linear, quadratic, and cubic interpolation, and the errors. Error (3.44) = f(3.44) - 0.290698 are tabulated. advantages of higher-degree interpolation are obvious. f(3.44) = 0.290756 = 0.290697 = 0.290698 PHM2111 week (7) linear interpolation Error = |0.000058| quadratic interpolation =| -0.000001| cubic interpolation =| 0.000000| 28 Fall 2020, 2/12/2020 NEWTON-COTES FORMULAS 29 The Newton-Cotes formulas are the most common numerical integration schemes. They are based on the strategy of replacing a complicated function or tabulated data with a polynomial that is easy to integrate: b I ο½ ο² f ο¨ x ο©dx ο a PHM2111 week (7) b ο² f ο¨x ο©dx n a Fall 2020, 2/12/2020 Numerical Integration MATH303 week (9) 30 Fall 2020, 2/12/2020 THE TRAPEZOIDAL RULE 31 The trapezoidal rule is the first of the Newton-Cotes closed integration formulas. It corresponds to the case where the polynomial in πΌ = π π π π₯ ππ₯ ≅ π π π π π₯ ππ₯ is first-order: (b, f(b)) (a, f(a)) a PHM2111 week (7) b Fall 2020, 2/12/2020 b b a a f ο¨bο© ο f ο¨ a ο© f1 ο¨ x ο© ο½ f ο¨ a ο© ο« ο¨ x ο a ο© bοa I ο½ ο² f ο¨ x ο© dx ο ο² f n ο¨ x ο© dx f ο¨bο© ο f ο¨ a ο© ο© οΉ I ο½ ο² οͺ f ο¨aο© ο« ο¨ x ο a ο© οΊ dx bοa ο» a ο« b x ο½b 2 ο© ο¦ f ο¨bο© ο f ο¨ a ο© οΆ ο¨ x ο a ο© οΉ I ο½ οͺ f ο¨aο© x ο« ο§ οΊ ο· bοa 2 οͺο« οΊο» x ο½ a ο¨ οΈ 2 2 ο© ο¦ f ο¨b ο© ο f ο¨ a ο© οΆ ο¨b ο a ο© οΉ ο© ο¦ f ο¨b ο© ο f ο¨ a ο© οΆ ο¨ a ο a ο© οΉ I ο½ οͺ f ο¨aο© b ο« ο§ οΊ ο οͺ f ο¨aο© a ο« ο§ οΊ ο· ο· bοa 2 οΊο» οͺο« bοa 2 οΊο» οͺο« ο¨ οΈ ο¨ οΈ b ο aο© οΉ ο© ο¨ I ο½ οͺ f ο¨ a ο©ο¨ b ο a ο© ο« ο¨ f ο¨ b ο© ο f ο¨ a ο© ο© οΊ 2 ο« ο» ο© ο¨ f ο¨bο© ο« f ο¨ a ο©ο© οΉ I ο½οͺ ο¨ b ο a ο©οΊ 2 οͺο« οΊο» MATH303 week (9) 32 Fall 2020, 1/11/2020 PHM2111 week (7) 33 Fall 2020, 2/12/2020 MATH303 week (9) 34 Fall 2020, 2/12/2020 The Composite Trapezoidal Rule 35 One way to improve the accuracy of the trapezoidal rule is to divide the integration interval from a to b into a number of segments and apply the method to each segment. The areas of individual segments can then be added to yield the integral for the entire interval. The resulting equations are called composite, or multiple-segment, integration formulas. If a and b are designated as x0 and xn, respectively, the total integral can be represented as I ο½ x1 x2 xn x0 x1 xnο1 ο² f ο¨x ο©dx ο« ο² f ο¨x ο©dx ο« ... ο« ο² f ο¨x ο©dx PHM2111 week (7) Fall 2020, 2/12/2020 Substituting the trapezoidal rule for each integral yields I ο½h f ο¨ x0 ο© ο« f ο¨ x1 ο© 2 ο«h f ο¨ x1 ο© ο« f ο¨ x2 ο© 2 ο« ... ο« h f ο¨ xn ο1 ο© ο« f ο¨ xn ο© 2 h I ο½ ο©ο« f ο¨ x0 ο© ο« 2 f ο¨ x1 ο© ο« 2 f ο¨ x2 ο© ο« 2 f ο¨ x3 ο© ο« ... ο« f ο¨ xn ο© οΉο» 2 i ο½ n ο1 hο© οΉ ο½ οͺ f ο¨ x0 ο© ο« 2 ο₯ f ο¨ xi ο© ο« f ο¨ xn ο© οΊ 2ο« i ο½1 ο» MATH303 week (9) 36 Fall 2020, 2/12/2020 Estimating Error of the Trapezoidal Rule 37 π−π 3 ″ πΈπ = − π π 2 12 π π″ π = PHM2111 week (7) π ″ π π π₯ ππ₯ π−π Fall 2020, 2/12/2020 Example Use the two-segment trapezoidal rule to estimate the integral of f (x) = 0.2 + 25 x – 200 x2 + 675 x3 – 900 x4 + 400 x5 from a = 0 to b = 0.8. estimate the approximated error. And true error recall that the exact value of the integral is 1.640533. For n = 2 b ο a 0.8 ο 0 hο½ x f(x) 0 0.2 n ο½ 2 0.4 2.456 ο½ 0.4 0.8 0.232 hο© i ο½ n ο1 Iο½ f ο¨ x0 ο© ο« 2ο₯ i ο½1 f ο¨ xi ο© ο« f ο¨ xn ο© οΉ ο» 2ο« 0.4 ο½ ο0.2+2 ο΄ 2.456+0.232ο ο½ 1.0688 2 Et ο½ 1.640533 ο 1.0688 ο½ 0.57173 PHM2111 week (7) 38 ο₯ ο½ 34.9% t Fall 2020, 2/12/2020 π(π₯ = 0.2 + 25π₯ − 200π₯ 2 + 675π₯ 3 − 900π₯ 4 + 400π₯ 5 π ′ (π₯ = 25 − 400π₯ + 2025π₯ 2 − 3600π₯ 3 + 2000π₯ 4 π ″ (π₯ = −400 + 4050π₯ − 10800π₯ 2 + 8000π₯ 3 0.8 f ο’ο’ ο¨οΈ ο© ο½ ο²ο¨ ο© ο400 ο« 4050 x ο 10800 x 2 ο« 8000 x 3 dx 0 0.8 ο 0 0.8 ο©ο« ο400 x ο« 2025 x ο 3600 x ο« 2000 x οΉο» ο48 0 ο½ ο½ ο½ ο60 0.8 0.8 2 Ea b ο aο© ο¨ ο½ο 12 n 2 PHM2111 week (7) 3 3 4 0.83 f ο’ο’ ο¨οΈ ο© ο½ ο ο60 ο© ο½ 0.64 2 ο¨ 12 ο΄ 2 39 Fall 2020, 2/12/2020 Example in the pervious example Use the four-segment For b ο a 0.8 ο 0 hο½ ο½ ο½ 0.2 n 4 n=4 X f(x) 0 0.2 0.2 1.288 0.4 2.456 0.6 3.464 0.8 0.232 hο© i ο½ n ο1 Iο½ f ο¨ x0 ο© ο« 2ο₯ i ο½1 f ο¨ xi ο© ο« f ο¨ xn ο© οΉ ο» 2ο« 0.2 ο©ο«0.2+2 ο΄ ο¨1.288+2.456+3.464 ο© +0.232 οΉο» ο½ 1.4848 ο½ 2 Et ο½ 1.640533 ο 1.4848 ο½ 0.155733 ο₯ t ο½ 9.5% Ea b ο aο© ο¨ ο½ο 12 n 2 MATH303 week (9) 3 0.83 f ο’ο’ ο¨οΈ ο© ο½ ο ο60 ο© ο½ 0.16 2 ο¨ 12 ο΄ 4 40 Fall 2020, 2/12/2020 Example Use 4 – 1 −1 1 4−π₯ 2 hο½ segment multiple trapezoidal rule to evaluate ππ₯ Then find the true error. b ο a 1ο«1 ο½ ο½ 0.5 n 4 X f(x) -1 0.57735 -0.5 0 0.516398 0.5 0.5 1 0.516398 0.57735 n ο1 hο© οΉ I ο½ οͺ f ο¨ a ο© ο« 2ο₯ f ο¨ xi ο© ο« f ο¨ b ο© οΊ ο½ 1.05507 2ο« i ο½1 ο» 1 ο² ο1 1 4ο x 2 dx ο½ 1 ο© ο1 ο¦ x οΆοΉ dx ο½ οͺs i n ο§ 2 ο· οΊ ο½ 1.0472 ο²ο 1 2 ο¨ οΈο» ο1 ο« ο¦ xοΆ 2 1ο ο§ ο· ο¨2οΈ 1 PHM2111 week (7) 1 41 Fall 2020, 2/12/2020 Assignment 1 1 0 1−π₯ 2 42 1. Find the integral by the Trapezoidal rule with 9 points. 2. A particle of mass m moving through a fluid is subjected to a viscous resistance R, which is a function of the velocity π£. The relationship between the resistance R, velocity π£, and time t is given by the equation π£1 π‘= π£0 π ππ£. π (π£ Suppose that π π£ = −π£ π£ for a particular fluid, where R is in newtons and π£ in π/π . If m = 5 kg and π£0 = 12 π/π , approximate the time t required for the particle to slow to π£1 = 8 π/π using Trapezoidal rule with 8 subintervals. PHM2111 week (7) Fall 2020, 2/12/2020 3. Use Lagrange interpolating polynomial to determine y at x = 8 to the best possible accuracy. 4. Find Lagrange interpolating polynomial to approximate a function whose 5 data points are given below. Use it to estimate the value of the function f(x) at x = 2.8. PHM2111 week (7) 43 x F(x) 2.0 0.85467 2.3 0.75682 2.6 0.43126 2.9 0.22364 3.2 0.08567 Fall 2020, 2/12/2020 5. Calculate f (3.4) using Lagrange interpolating polynomials of order 1 through 3 and estimate the error for the 1st , 2nd and 3rd order. MATH206 week (9) 44 Fall 2020, 2/12/2020 Assignment 45 • Use Newton.s interpolating polynomial to determine y at x = 8 to the best possible accuracy. • Find Newton’s interpolating polynomial to approximate a function whose 5 data points are given below. Use it to estimate the value of the function f(x) at x = 2.8. MATH206 week (7) x F(x) 2.0 0.85467 2.3 0.75682 2.6 0.43126 2.9 0.22364 3.2 0.08567 Fall 2020, 1/11/2020 • Calculate f (3.4) using Newton.s interpolating polynomials of order 1 through 3 and estimate the error for the 1st , 2nd and 3rd order. PHM2111 week (7) 46 Fall 2020, 2/12/2020