LECTURE 2 INTRODUCTION to INTERPOLATION • Interpolation

LECTURE 2 INTRODUCTION to INTERPOLATION • Interpolation

CE 30125 - Lecture 2 LECTURE 2 INTRODUCTION TO INTERPOLATION • Interpolation function: a function that passes exactly through a set of data points. • Interpolating functions to interpolate values in tables x sin(x) 0.0 0.000000 0.5 0.479426 1.0 0.841471 1.5 0.997495 2.0 0.909297 2.5 0.598472 • In tables, the function is only specified at a limited number or discrete set of indepen- dent variable values (as opposed to a continuum function). • We can use interpolation to find functional values at other values of the independent variable, e.g. sin(0.63253) p. 2.1 CE 30125 - Lecture 2 • In numerical methods, like tables, the values of the function are only specified at a discrete number of points! Using interpolation, we can describe or at least approximate the function at every point in space. • For numerical methods, we use interpolation to • Interpolate values from computations • Develop numerical integration schemes • Develop numerical differentiation schemes • Develop finite element methods • Interpolation is typically not used to obtain a functional description of measured data since errors in the data may lead to a poor representation. • Curve fitting to data is handled with a separate set of techniques p. 2.2 CE 30125 - Lecture 2 Linear Interpolation • Linear interpolation is obtained by passing a straight line between 2 data points y g(x) f(x) f(x1) f(x0) x x0 x1 fx = the exact function for which values are known only at a discrete set of data points gx = the interpolated approximation to fx x0 , x1 = the data points (also referred to as interpolation points or nodes) • In tabular form: xo fxo x gx x1 fx1 p. 2.3 CE 30125 - Lecture 2 • If gx is a linear function then gx= Ax+ B (1) where A and B are unknown coefficients • To pass through points xo fxo and x1 fx1 we must have: gxo = fxo Axo + B = fxo (2) gx1 = fx1 Ax1 + B = fx1 (3) • 2 unknowns and 2 equations solve for AB • Using (2) Bfx= o – Axo Substituting into (3) Ax1 + fxo – Axo = fx1 p. 2.4 CE 30125 - Lecture 2 fx– fx A = -----------------------------1 o- x1 – xo fxx – fxx B = ----------------------------------------o 1 1 o- x1 – xo • Substituting for A and B into equation (1) x1 – x xx– o gx= fxo --------------------- + fx1 --------------------- x1 – xo x1 – xo This is the formula for linear interpolation p. 2.5 CE 30125 - Lecture 2 Example 1 • Use values at xo and x1 to get an interpolated value at x = 0.632 using linear interpola- tion Table 1: x fx= sinx xo = 0.5 fxo = 0.47942554 0.632 g0.632 = ? x1 = 1.0 fx1 = 0.84147099 1.0– 0.632 0.632– 0.5 g0.632 = 0.479425-------------------------------+ 0 . 8 4147099------------------------------- 1.0– 0.5 1.0– 0.5 g0.632 = 0.57500 p. 2.6 CE 30125 - Lecture 2 Error for Linear Interpolating Functions • Error is defined as: ex fx– gx •ex represents the difference between the exact function fx and the interpolating or approximating function gx. • We note that at the interpolating points xo and x1 exo = 0 ex1 = 0 • This is because at the interpolating point we have by definition gxo = fxo gx1 = fx1 p. 2.7 CE 30125 - Lecture 2 Derivation of e(x) f(x) f(x) g(x) f(x1) f(x0) x x0 x1 ex fx– gx Step 1 • Expand fx in Taylor Series (T.S.) about xo 2 2 df xx– o d f fx= fx++xx– ------ ----------------------------- where x x (4) o o dx 2! 2 o xx= dx o x = • The third term is the actual remainder term and represents all other terms in the series since it is evaluated at x = ! p. 2.8 CE 30125 - Lecture 2 Step 2 df • Express ------ in terms of fx and fx dx o 1 xx= o • We can accomplish this by simply evaluating the T.S. in (4) at xx= 1 . 2 2 df x1 – xo d f fx= fx++x – x ------ ----------------------- -------- (5) 1 o 1 o dx 2! 2 xx= dx o x = 2 2 df fx1 fxo x1 – xo 1 d f ------ = --------------------- – --------------------- – ----------------------- ----------------------------- (6) dx x – x x – x 2! x – x 2 xx= 1 o 1 o 1 o dx o x = 2 df fx1 fxo x1 – xo d f ------ = --------------------- – --------------------- – ----------------------------- (7) dx x – x x – x 2 2 xx= 1 o 1 o dx o x = • We note that this is a discrete approximation to the first derivative (a F.D. Formula) p. 2.9 CE 30125 - Lecture 2 Step 3 • Substitute Equation 7 into T.S. form of fx, Equation (4). • This gives us an expression for fx in terms of the discrete values fxo and fx1 . 2 2 2 fx1 fxo x1 – xo d f xx– o d f fx = fx + xx– --------------------- – --------------------- – ----------------------------- + ----------------------------- (8) o o 2 2 x1 – xo x1 – xo 2 dx 2 dx x = x = 2 2 xx– o xx– o xx– o –x1 + xo xx– o d f fx = fx ++---------------------fx – ---------------------fx ------------------------------------------- + --------------------- -------- (9) o 1 o 2 x1 – xo x1 – xo 2 2 dx x = 2 fxo fx1 xx– o d f fx = x – x – x + x --------------------- ++xx– --------------------- – x ++x xx– ------------------ -------- (10) 1 o o o 1 o o 2 x1 – xo x1 – xo 2 dx x = 2 x1 – x xx– o xx– o xx– 1 d f fx = fx ---------------- ++fx ---------------- ----------------------------------------------- (11) o 1 2 x1 – xo x1 – xo 2 dx x = p. 2.10 CE 30125 - Lecture 2 • The first part of Equation (11) is simply the linear interpolation formula. The second part is in fact the error. Thus: ex fx– gx x – x xx– xx– xx– d2f ex fx ---------------1 - ++fx ---------------o- -------------------------------------o 1 -------- o 1 2 x1 – xo x1 – xo 2 dx x = x1 – x xx– o –fxo ---------------- – fx1 ---------------- x1 – xo x1 – xo 2 xx– o xx– 1 d f ex= ----------------------------------------------- xo x1 2 dx2 x = • If we assume that the interval xo x1 is small, then the second derivative won’t change dramatically in the interval! 2 2 2 2 d f d f d f d f xo + x1 -------- -------- -------- -------- where xm ---------------- dx2 dx2 dx2 dx2 2 x = xx= o xx= 1 xx= m p. 2.11 CE 30125 - Lecture 2 • Thus we typically evaluate the derivative term in the error expression using the midpoint in the interval 1 d2f ex ---xx– o xx– 1 -------- 2 dx2 xx= m • Another problem is that we typically don’t know the second derivative at the midpoint of the interval, xm • However using finite differencing formulae we can approximate this derivative knowing the functional values at the interpolating points • Maximum error occurs at the midpoint for linear interpolation (where xx– o xx– 1 is the largest) 1 d2f max exx xx ---xm – xo xm – x1 -------- 0 1 2 dx2 xx= m • However hx 1 – xo and h h --- = x – x and --- = x – x 2 m o 2 1 m p. 2.12 CE 30125 - Lecture 2 • Thus h2 d2f max exx xx= ----- -------- 0 1 8 dx2 xm • Notes on Error for linear interpolation • The error expression has a polynomial and a derivative portion. • Maximum error occurs approximately at the midpoint between xo and x1 • Error increases as the interval h increases 2 2 • Error increases as f x increases. Again note that f x can be approximated with finite difference (F.D.) formulae if at least 3 surrounding functional values are available. (We will discuss F.D. formulae later.) p. 2.13 CE 30125 - Lecture 2 Example 2 • Compute an error estimate for the problem in Example 1. • Recall we found that g0.632 = 0.57500 • Error is estimated as: 2 1 d f ex ---xx– o xx– 1 -------- 2 dx2 xx= m • Since x = 0.750 is the midpoint at the interval 0.5 1.0 , we have 2 1 d f e0.632 --- 0.632– 0.5 0.632– 1.0 -------- 2 dx2 x = 0.750 d2f e 0.632 –0.024288-------- 2 dx x = 0.75 p. 2.14 CE 30125 - Lecture 2 • Since we have not yet extensively discussed approximating derivatives using discrete 2 d f values, we will compute -------- using analytical methods: dx2 x = 0.75 2 d f -------- ==–sin0.750 – 0.68164 dx2 x = 0.75 2 d f • Substituting in the value for -------- , we obtain an estimate for the error: dx2 x = 0.75 e0.632 –0.024288 –0.68164 = 0.016555 • Computing the actual error (the actual solution - the estimated error): Ex= sinx – gx E0.632 ==sin0.632 – 0.57500 0.01576 • The estimated error, ex is a good approximation of the actual error Ex! p. 2.15.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    15 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us