Direct Method of Interpolation Major: All Engineering Majors Authors: Autar Kaw, Jai Paul http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates http://numericalmethods.eng.usf.edu 1 Direct Method of Interpolation http://numericalmethods.eng.usf.edu What is Interpolation ? Given (x0,y0), (x1,y1), …… (xn,yn), find the value of ‘y’ at a value of ‘x’ that is not given. Figure 1 Interpolation of discrete. 3 http://numericalmethods.eng.usf.edu Interpolants Polynomials are the most common choice of interpolants because they are easy to: Evaluate Differentiate, and Integrate 4 http://numericalmethods.eng.usf.edu Direct Method Given ‘n+1’ data points (x0,y0), (x1,y1),………….. (xn,yn), pass a polynomial of order ‘n’ through the data as given below: y a0 a1 x .................... an x . n where a0, a1,………………. an are real constants. Set up ‘n+1’ equations to find ‘n+1’ constants. To find the value ‘y’ at a given value of ‘x’, simply substitute the value of ‘x’ in the above polynomial. 5 http://numericalmethods.eng.usf.edu Example 1 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 direct method for linear interpolation. Table 1 Velocity as a function of time. 6 t , s vt , m/s 0 0 10 227.04 15 362.78 20 517.35 22.5 602.97 30 901.67 Figure 2 Velocity vs. time data for the rocket example http://numericalmethods.eng.usf.edu Linear Interpolation vt a0 a1t y v15 a0 a1 15 362.78 v20 a0 a1 20 517.35 Solving the above two equations gives, a0 100.93 a1 30.914 x1 , y1 x0 , y0 f1 x x Figure 3 Linear interpolation. Hence vt 100.93 30.914t, 15 t 20. v16 100.93 30.91416 393.7 m/s 7 http://numericalmethods.eng.usf.edu Example 2 The upward velocity of a rocket is given as a function of time in Table 2. Find the velocity at t=16 seconds using the direct method for quadratic interpolation. Table 2 Velocity as a function of time. 8 t , s vt , m/s 0 0 10 227.04 15 362.78 20 517.35 22.5 602.97 30 901.67 Figure 5 Velocity vs. time data for the rocket example http://numericalmethods.eng.usf.edu Quadratic Interpolation y vt a0 a1t a2t 2 x1 , y1 v10 a0 a1 10 a2 10 227.04 x2 , y2 2 v15 a0 a1 15 a2 15 362.78 2 v20 a0 a1 20 a2 20 517.35 2 f 2 x x0 , y 0 x Figure 6 Quadratic interpolation. Solving the above three equations gives a0 12.05 a1 17.733 a2 0.3766 9 http://numericalmethods.eng.usf.edu Quadratic Interpolation (cont.) 517.35 vt 12.05 17.733t 0.3766t , 10 t 20 550 500 2 v16 12.05 17.73316 0.376616 2 450 ys 400 f ( range) f x desired 392.19 m/s 350 300 250 227.04 200 10 10 12 14 16 18 x s range x desired The absolute relative approximate error a obtained between the results from the first and second order polynomial is 392.19 393.70 100 392.19 0.38410% a 10 http://numericalmethods.eng.usf.edu 20 20 Example 3 The upward velocity of a rocket is given as a function of time in Table 3. Find the velocity at t=16 seconds using the direct method for cubic interpolation. Table 3 Velocity as a function of time. 11 t , s vt , m/s 0 0 10 227.04 15 362.78 20 517.35 22.5 602.97 30 901.67 Figure 6 Velocity vs. time data for the rocket example http://numericalmethods.eng.usf.edu Cubic Interpolation y vt a0 a1t a2t a3t 2 x3 , y3 3 x1, y1 v10 227.04 a0 a1 10 a2 10 a3 10 2 3 v15 362.78 a0 a1 15 a2 15 a3 15 2 3 x0 , y0 v20 517.35 a0 a1 20 a2 20 a3 20 2 x2 , y2 f 3 x x 3 Figure 7 Cubic interpolation. v22.5 602.97 a0 a1 22.5 a2 22.5 a3 22.5 2 a0 4.2540 12 a1 21.266 3 a2 0.13204 a3 0.0054347 http://numericalmethods.eng.usf.edu Cubic Interpolation (contd) vt 4.2540 21.266t 0.13204t 2 0.0054347t 3 , 10 t 22.5 v16 4.2540 21.26616 0.1320416 0.005434716 392.06 m/s 2 602.97 700 The absolute percentage relative approximate error a between second and third order polynomial is 600 ys 3 500 f ( range) f x desired 400 300 227.04 200 10 10 13 392.06 392.19 100 392.06 0.033269% a 12 14 16 18 x s range x desired 20 22 24 22.5 http://numericalmethods.eng.usf.edu Comparison Table Table 4 Comparison of different orders of the polynomial. 14 t(s) v (m/s) 0 0 10 227.04 15 362.78 20 517.35 22.5 602.97 30 901.67 Order of Polynomial 1 2 3 vt 16 m/s 393.7 392.19 392.06 Absolute Relative Approximate Error ---------- 0.38410 % 0.033269 % http://numericalmethods.eng.usf.edu Distance from Velocity Profile Find the distance covered by the rocket from t=11s to t=16s ? vt 4.3810 21.289t 0.13064t 2 0.0054606t 3 , 10 t 22.5 16 s16 s11 vt dt 11 16 4.2540 21.266t 0.13204t 2 0.0054347t 3 dt 11 16 t2 t3 t4 4.2540t 21.266 0.13204 0.0054347 2 3 4 11 1605 m 15 http://numericalmethods.eng.usf.edu Acceleration from Velocity Profile Find the acceleration of the rocket at t=16s given that t 4.2540 21.266t 0.132042 0.0054347t 3 ,10 t 22.5 at d vt dt d 4.2540 21.266t 0.13204t 2 0.0054347t 3 dt 21.289 0.26130t 0.016382t 2 , 10 t 22.5 a16 21.266 0.2640816 0.01630416 2 29.665 m/s 2 16 http://numericalmethods.eng.usf.edu Additional Resources For all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit http://numericalmethods.eng.usf.edu/topics/direct_met hod.html THE END http://numericalmethods.eng.usf.edu