Numerical Methods For Slides Thanks to Lecture 6 Interpolation

Slides:



Advertisements
Similar presentations
Numerical Methods.  Polynomial interpolation involves finding a polynomial of order n that passes through the n+1 points.  Several methods to obtain.
Advertisements

Autar Kaw Humberto Isaza
Chapter 18 Interpolation The Islamic University of Gaza
1 Direct Method of Interpolation Electrical Engineering Majors Authors: Autar Kaw, Jai Paul
Differentiation-Discrete Functions
Direct Method of Interpolation
Polynomial Interpolation
7/2/ Differentiation-Discrete Functions Industrial Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati.
1 Chapter 3 INTERPOLATION. 2 WHAT IS INTERPOLATION? Given (x 0,y 0 ), (x 1,y 1 ), …, (x n,y n ), finding the value of ‘y’ at a value of ‘x’ in ( x 0,
8/15/ Differentiation-Discrete Functions Major: All Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati.
EXAMPLE 3 Model with finite differences
CpE- 310B Engineering Computation and Simulation Dr. Manal Al-Bzoor
Simpson’s 1/3 rd Rule of Integration. What is Integration? Integration The process of measuring the area under a.
1 Simpson’s 1/3 rd Rule of Integration. 2 What is Integration? Integration The process of measuring the area under a curve. Where: f(x) is the integrand.
CSE 330 : Numerical Methods
1 Trapezoidal Rule of Integration. What is Integration Integration: The process of measuring the area under a function.
Simpson Rule For Integration.
Curve Fitting and Interpolation: Lecture (I)
10/11/ Differentiation-Discrete Functions Chemical Engineering Majors Authors: Autar Kaw, Sri Harsha Garapati.
Numerical Methods.  If (n+1) number of points are given, (n+1) number of equations can be formed using a (n+1) order polynomial  The equations can be.
1 Interpolation. 2 What is Interpolation ? Given (x 0,y 0 ), (x 1,y 1 ), …… (x n,y n ), find the value of ‘y’ at a.
1 Lagrangian Interpolation Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
1 Newton’s Divided Difference Polynomial Method of Interpolation Major: All Engineering Majors Authors: Autar Kaw,
Interpolation produces a function that matches the given data exactly. The function then can be utilized to approximate the data values at intermediate.
Trapezoidal Rule of Integration
CSE 330 : Numerical Methods Lecture 15: Numerical Integration - Trapezoidal Rule Dr. S. M. Lutful Kabir Visiting Professor, BRAC University & Professor.
1 Direct Method of Interpolation Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
1 INTERPOLASI. Direct Method of Interpolation 3 What is Interpolation ? Given (x 0,y 0 ), (x 1,y 1 ), …… (x n,y n ), find the value of ‘y’ at a value.
1 Direct Method of Interpolation Computer Engineering Majors Authors: Autar Kaw, Jai Paul
1 Direct Method of Interpolation Mechanical Engineering Majors Authors: Autar Kaw, Jai Paul
1 Spline Interpolation Method Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
5. Interpolation 5.1 Definition of interpolation. 5.2 Formulas for Interpolation. 5.3 Formulas for Interpolation for unequal interval. 5.4 Applications.
1 Spline Interpolation Method Mechanical Engineering Majors Authors: Autar Kaw, Jai Paul
Numerical Methods. Introduction Prof. S. M. Lutful Kabir, BRAC University2  One of the most popular techniques for solving simultaneous linear equations.
Interpolation - Introduction
11/22/ Differentiation-Discrete Functions.
Introduction to Numerical Methods Mathematical Procedures
Polynomial Interpolation
Chapter 7 Numerical Differentiation and Integration
1. 2 What is Integration? Integration The process of measuring the area under a curve. Where: f(x) is the integrand a= lower limit of integration b=
Interpolation.
Differentiation-Discrete Functions
Interpolation Estimation of intermediate values between precise data points. The most common method is: Although there is one and only one nth-order.
Chapter 18.
Advanced Numerical Methods (S. A. Sahu) Code: AMC 51151
Differentiation-Discrete Functions
Reading Between the Lines
Spline Interpolation Method
Chapter 18.
Spline Interpolation Method
Spline Interpolation Method
Direct Method of Interpolation
Chapter 7 Numerical Differentiation and Integration
Today’s class Multiple Variable Linear Regression
MATH 2140 Numerical Methods
POLYNOMIAL INTERPOLATION
Direct Method of Interpolation
INTERPOLASI.
Why Splines ?
Numerical Computation and Optimization
Lagrangian Interpolation
Direct Method of Interpolation
SKTN 2393 Numerical Methods for Nuclear Engineers
Numerical Computation and Optimization
Integrated Math 3 – Mod 3 Test Review
Reading Between the Lines
Numerical Computation and Optimization
Differentiation-Discrete Functions
Newton’s Divided Difference Polynomial Method of Interpolation
Lagrangian Interpolation
Presentation transcript:

Numerical Methods For Slides Thanks to Lecture 6 Interpolation Direct Method & Lagrange Method For Slides Thanks to Dr. S. M. Lutful Kabir Visiting Professor, BRAC University & Professor, BUET

What is interpolation? Many times, data is given only at discrete points such as ........... . So, how then does one find the value of y at any other value of x ? Well, a continuous function f(x) may be used to represent the n+1 data values with f(x) passing through the n+1 points (Figure 1). Then one can find the value of y at any other value of x. This is called interpolation. y (x3,y3) (x1,y1) Figure 1 (x2,y2) f(x) (x0,y0) x

Polynomial interpolation? Of course, if new ‘x’ falls outside the range of x for which the data is given, it is no longer interpolation but instead is called extrapolation. So what kind of function f(x) should one choose? A polynomial is a common choice for an interpolating function because polynomials are easy to evaluate, differentiate, and integrate relative to other choices such as a trigonometric and exponential series Polynomial interpolation involves finding a polynomial of order n that passes through the n+1 points

Direct Method of Interpolation One of the methods of interpolation is called the direct method. Other methods include the Lagrangian interpolation method and Newton’s divided difference polynomial method The direct method of interpolation is based on the following premise. Given n+1 data points, fit a polynomial of order n as given below (1) through the data, where a0, a1, a2,....... an+1, an are real constants.

Direct Method of Interpolation (continued) Since values of f(x) are given at values of x, one can write equations

Direct Method of Interpolation (continued) Then the constants, can be found by solving the simultaneous linear equations. To find the value of f(x) at a given value of x, simply substitute the value of x in Equation 1. But, it is not necessary to use all the data points. How does one 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

Example 1 The upward velocity of a rocket is given as a function of time in Table 1. Corresponding graph is shown in Figure 1 Table 1: Velocity as function of time Figure 1: Graph of Velocity Time (s) Velocity (m/s) 10 227.04 15 362.78 20 517.35 22.5 602.97 30 901.67 Determine the value of the velocity at t = 16seconds using the direct method of interpolation and a first order polynomial.

Solution to example 1 For first order polynomial interpolation (also called linear interpolation), the velocity is given by y (x1 , y1) f1(x) (x0 , y0) x Figure 3 Linear interpolation

Solution to example 1 (continued) Since we want to find the velocity at t=16 sec, and we are using a first order polynomial, we need to choose the two data points that are closest to t = 16 sec that also bracket t=16 sec to evaluate it. The two points are t0=15 sec and t1=20 sec Then t0=15, v(t0)=362.78 a0=-100.93 t1=20, v(t1)=517.35 a1=30.914 Gives v(15)=a0+a1 x 15=362.78 v(t)=ao+a1t v(20)=a0+a1 x 20=517.35 v(16)=393.7

Example 2 Determine the value of the velocity at t = 16 seconds using the direct method of interpolation and a second order polynomial. Solution For second order polynomial interpolation (also called quadratic interpolation), the velocity is given by v(t)=a0+a1t+a2t2 y x1 , y1 x2 , y2 f(x) x0 , y0 x

Solution to example 2 (continued)  Since we want to find the velocity at t=16, and we are using a second order polynomial, we need to choose the three data points that are closest to t = 16 that also bracket t = 16 to evaluate it. The three points are t0=10, t1=15 and t2=20 Then v(10)=227.04=a0+a1 x 10+a2 x 102 v(15)=362.78=a0+a1 x 15+a2 x 152 v(20)=517.35=a0+a1 x 20+a2 x 202 They gives, a0=12.05 a1=17.733 a2=0.3766

Solution to example 2 (continued) Hence v(t)=12.05+17.733t+0.3766t2 V(16)=392.19 m/s The absolute relative approximate error obtained between the results from the first and second order polynomial is

Example 3 For the rocket problem of the previous examples a) Determine the value of the velocity at t=16 seconds using the direct method of interpolation and a third order polynomial. b) Find the absolute relative approximate error for the third order polynomial approximation. c) Using the third order polynomial interpolant for velocity from part (a), find the distance covered by the rocket from t=11 s to t=16 s. d) Using the third order polynomial interpolant for velocity from part (a), find the acceleration of the rocket at t=16s.

Solution to example 3 For third order polynomial interpolation (also called cubic interpolation), we choose the velocity given by y (x3 , y3) (x1 , y1) (x2 , y2) f3(x) (x0 , y0) x

Solution to example 3 (continued) Since we want to find the velocity at t=16, and we are using a third order polynomial, we need to choose the four data points closest to and also bracket that. The four points are (t0, v0)=(10, 227.04), (t1, v1)=(15, 362.78), (t2, v2)=(20, 517.35) and (t3, v3)=(22.5, 602.97) Solving the above four equations gives a0= - 4.2540 a1= 21.266 a2= 0.13204 a3= 0.0054347 Hence, v(t) = - 4.2540 + 21.266 t + 0.13204 t2 + 0.0054347 t3 So, v(16)= 392.06 m/s

Solution to example 3 (continued) b) The absolute percentage relative approximate error for the value obtained for v(16) between second and third order polynomial is c) The distance covered by the rocket between t=11s and t=16s can be calculated from the interpolating polynomial Note that the polynomial is valid between t = 10 s and t = 22.5 s and hence includes the limits of integration of t = 11 s and t = 16 s

Solution to example 3 (continued) = = 1605m d) The acceleration at t=16sec is given by, So, a(16) = 29.665 m/s2

Solving the coefficients of polynomial having high order If the polynomial is of nth order, there are n numbers of unknowns, how to find out them? One way is to arrange the equations in matrix form as shown below: [Y] = [C] [A] Since [Y] = [C] [A] So, [A] = [C]-1 [Y]

Langrange Method The Lagrangian interpolating polynomial is given by where n in fn(x) stands for the nth order polynomial that approximates the function y=f(x) given at n+1 data points as (x0,y0), (x1,y1), (x2,y2),……. (xn-1,yn-1), (xn, yn) and Li(x) is a weighting function that includes a product of n-1 terms with terms of j = i omitted. The application of Lagrangian interpolation will be clarified using an example.

Example 4 Determine the value of the velocity of the rocket problem at t=16 seconds using a first order Lagrange polynomial. Solution For first order polynomial interpolation (also called linear interpolation), the velocity is given by Hence, v(16) = 393.69 m/s

Since we want to find the velocity at Solution to example 4 to evaluate it. The three points are . For quadratic approximation, Since we want to find the velocity at t=16 , and we are using a second order polynomial, we need to choose the three data points that are closest to t=16 that also bracket t=16 to evaluate it. The three points are t0=10, t1=15 and t2=20, hence, v(16)=392.19 m/s b) The absolute relative approximate error with respect to direct method is

Flow Chart for Direct Method 1 Start 9 F 5 for i=1..n+1 for i=1..n+1 2 n F T T x(i), y(i), i=1,1,....n+1 10 a(i)=0 6 3 for j=1..n+1 F 11 F T for j=1..n+1 4 7 xu 12 T c(i,j)=x(i)^(j-1) a(i)=a(i)+ci(i,j)*y(j) ci=inv(c) 8 fxu=0 13 F 14 for i=1..n+1 T 17 16 15 fxu=fxu+a(i)*xu^(i-1) End xu, fxu

Flow Chart for Langrage method 1 Start 7 2 n L(i)=1 9 x(i), y(i), i=1...n+1 T j : i 3 for j=1..n+1 = = F 8 4 xu L(i)=L(i)*(xu-x(j))/(x(i)-x(j)) 5 fxu=0 10 fxu=fxu+L(i)*y(i) 11 6 for i=1..n+1 T 12 F xu, fxu End 10

Thanks