Docsity

Numerical analysis 12, Slides of Mathematical Methods for Numerical Analysis and Optimization

Partial preview of the text

Download Numerical analysis 12 and more Slides Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Interpolation

Topic: Direct Method

Dr. Nasir M Mirza

Numerical Numerical

Methods Methods

Email: [email protected]

What is Interpolation? Let us suppose we are given with data (x 0 , y 0 ), (x 1 , y 1 ), …… (xn, yn), then we are asked to find the value of ‘y’ at a value of ‘x’ that is not given in the data. So, we need to do the interpolation in the data. ( x 1 , y 1 ) ( x 2 , y 2 ) ( x 0 , y 0 ) ( xn , yn ) ( x 3 , y 3 )

Interpolation

  • Data from experimental/observational measurements
    • (^) Classic gravity drop: location changes with time
    • (^) Pressure varies with depth
    • (^) Wind speed varies with time
    • (^) Temperature varies with location
    • (^) Census data population 1950 1960^ year What was the population at 1964? The relationship looks linear :
  • (^) so look at Global information ( that is look at trends)

Applications Science, Engineering, Statistics,

etc.

  • (^) Scientific method (Also used in

Engineering)

  • (^) Identify the underlying relationship in your

data (patterns/trends)

  • (^) Deal with noise in the data
  • (^) Make predictions about the behavior of a

process

  • (^) Remember distributions in statistics
    • (^) Tools used in social science, political science,

etc.

Interpolation

  • (^) Assumptions:
    • (^) No error in the data
      • (^) Round-off is assumed to be negligible
    • (^) We don’t know the underlying function f ( x )
  • (^) Given n +1 points [ xi, yi ]; x 0 , x 1 ,…, xi ,…, xn : xj > xj- - (^) Spacing may or may not be even - (^) All values of x i are distinct
  • (^) Interpolation
    • (^) Develop a simple function f ( x ) that
      • (^) Approximates f ( x )
      • (^) Passes through all the points xi (i.e., an interpolant)
    • (^) Evaluate f ( x t ) where^ x 0 < xt < xn

Modeling Choices

  • (^) How do we choose the simple function f ( x )???
    • (^) Polynomials
    • (^) Splines
    • (^) Trigonometric functions (Data looks periodic)
      • (^) Fourier Transform representations
    • (^) Least-squares
      • (^) Error minimization

1 2 1 2 1 1 ( ) ( ) ( ) ( ) x x x x y x y x y x y x      For first and second point we write two equations : y ( x )  cm x Here m is the slope and c is the y-intercept of line. 2 2 1 1 ( ) ( ) y x c m x y x c m x     Subtracting we get the slope m and intercept c as Consider a linear interpolate as: 2 1 ( 2 ) ( 1 ) x x y x y x m    1 2 1 2 1 1 ( ) ( ) ( ) x x x y x y x c y x     Then final equation is : Linear Interpolation

Quadratic Interpolation Suppose we take three data points [ x 0 , y 0 ], [ x 1 , y 1 ], [ x 2 , y 2 ], Then put points in a polynomial : y(x) = a 0 + a 1 x + a 2 x^2 y(x 0 ) = y 0 = a 0 + a 1 x 0 + a 2 x 02 + a 3 x 03 y(x 1 ) = y 1 = a 0 + a 1 x 1 + a 2 x 12 + a 3 x 13 y(x 2 ) = y 2 = a 0 + a 1 x 2 + a 2 x 22 + a 3 x 23

  • (^) Express this as a matrix problem: A X = B. Then Solve for A.

Linear Interpolation   0 2 1 2 1 1

( ) ( ) x x x x y x y x y x y x  

Example 1: How would you approach estimating the density at 17 o C for the data using linear interpolation? The equation of straight line that passes through two points (x 1 , y 1 ) and (x 2 , y 2 ) The two known points are following: x 1 = 15 , y 1 = 999.1 and x 2 = 20 , y 2 = 998. Temperature ( C ) Density ( kg/m^3 ) 0 999. 5 1000. 10 999. 15 999. 20 998. 0 999.

Linear Interpolation The equation of straight line that passes through two points (x 1 , y 1 ) and (x 2 , y 2 ) forms linear interpolation. This changes for intervals as shown in figure. Example 1 (continued) :

Examples on linear interpolation

t v(t) s m/s 0 0 10 227. 15 362. 20 517. 22.5 602. 30 901. Table 1: Fig. Velocity vs. time data for the rocket. Example 4 : 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.

Examples on linear interpolation (continued)

v  t   a 0  a 1 t

v  15   a 0  a 1  15   362. 78  20   20  517. 35 0 1 vaa  Solving the above two equations gives, 1 30. 913

  1. 91 ; 0     a a Hence for t = 16, vt   100. 91  30. 913 t , 15  t  20. v  16   100. 91  30. 913  16   393. 7 m / s 13 14 15 16 17 18 19 20 21 320 360 400 440 480 520 560 600 velocity (m /s) time (sec) data points Example 2 : Let us consider two points and an equation : t = 15, v = 362. t = 20, v = 517.

  2 0 1 2

v t  a  a t  a t

             20   20   20  517. 35 15 15 15 362. 78 10 10 10 227. 04 2 0 1 2 2 0 1 2 2 0 1 2             v a a a v a a a v a a a Solving the above three equations or the matrix form will give the answer

Examples on Quadratic Interpolation

(continued)

2 1 0 a a a AX B Example 3 :

First steps without pivoting are: Row2 = Row2 - Row Row3 = Row3 – Row Next steps without pivoting are: Row1 = Row1 - (2)Row Row3 = Row3 – (2)Row

Examples on Quadratic Interpolation

(continued)

2 1 0

a

a

a

2 1 0 a a a

2 1 0 a a a AX B Example 3 :