Académique Documents
Professionnel Documents
Culture Documents
LECTURE 5 INTRODUCTION TO INTERPOLATION Interpolation function: a function that passes exactly through a set of data points. Interpolating functions to interpolate values in tables
x 0.0 0.5 1.0 1.5 2.0 2.5 sin(x) 0.000000 0.479426 0.841471 0.997495 0.909297 0.598472
In tables, the function is only specied at a limited number or discrete set of independent variable values (as opposed to a continuum function). We can use interpolation to nd functional values at other values of the independent variable, e.g. sin(0.63253)
p. 5.1
In numerical methods, like tables, the values of the function are only specied 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 nite 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 tting to data is handled with a separate set of techniques
p. 5.2
Linear Interpolation Linear interpolation is obtained by passing a straight line between 2 data points
y f(x1) f(x0) x0 x1 x g(x) f(x)
f ( x ) = the exact function for which values are known only at a discrete set of data points g ( x ) = the interpolated approximation to f ( x ) x 0 , x 1 = the data points (also referred to as interpolation points or nodes)
In tabular form:
xo x x1 f ( xo ) g( x) f ( x1 )
p. 5.3
where A and B are unknown coefcients To pass through points ( x o, f ( x o ) ) and ( x 1, f ( x 1 ) ) we must have:
g ( xo ) = f ( xo ) g ( x1 ) = f ( x1 )
Ax o + B = f ( x o ) Ax 1 + B = f ( x 1 )
(2) (3)
solve for A, B
B = f ( x o ) Ax o
p. 5.4
f ( x1 ) f ( xo ) A = --------------------------------x1 xo f ( xo ) x1 f ( x1 ) xo B = -------------------------------------------x1 xo
p. 5.5
Example 1 Use values at x o and x 1 to get an interpolated value at x = 0.632 using linear interpolation
Table 1:
( 1.0 0.632 ) ( 0.632 0.5 ) g ( 0.632 ) = 0.479425 ------------------------------- + 0.84147099 ------------------------------( 1.0 0.5 ) ( 1.0 0.5 )
g ( 0.632 ) = 0.57500
p. 5.6
e ( x ) represents the difference between the exact function f ( x ) and the interpolating or approximating function g ( x ) . We note that at the interpolating points x o and x 1
e ( xo ) = 0 e ( x1 ) = 0
p. 5.7
Derivation of e(x)
f(x) g(x)
x1
e( x) f ( x) g( x)
where x o x
x=
(4)
x = xo
The third term is the actual remainder term and represents all other terms in the series since it is evaluated at x = !
p. 5.8
Step 2
df Express ----dx
x = xo
in terms of f ( x o ) and f ( x 1 )
x = xo
( x1 xo ) d 2 f + ----------------------- -------2 2! dx
(5)
x=
df ----dx
x = xo
(6)
x=
df ----dx
x = xo
(7)
x=
We note that this is a discrete approximation to the rst derivative (a F.D. Formula)
p. 5.9
Step 3 Substitute Equation 7 into T.S. form of f ( x ) , Equation (4). This gives us an expression for f ( x ) in terms of the discrete values f ( x o ) and f ( x 1 ) .
( x1 xo ) d 2 f f ( x1 ) f ( xo ) - -------f ( x ) = f ( x o ) + ( x x o ) -------------------- -------------------- -------------------2 2 ( x1 xo ) ( x1 xo ) dx
x=
( x xo ) d 2 f - -------+ -------------------2 2 dx
(8)
x=
(9)
x=
(10)
x=
(11)
x=
The rst part of Equation (11) is simply the linear interpolation formula. The second part is in fact the error. Thus:
e( x) f ( x) g( x)
x=
( x xo ) ( x x1 ) d 2 f - -------e ( x ) = --------------------------------------2 2 dx
xo x1
x=
If we assume that the interval [ x o, x 1 ] is small, then the second derivative wont change dramatically in the interval!
d f -------2 dx
2
d f -------2 dx x=
x = xo
d f -------2 dx
x = x1
d f -------2 dx
where
x = xm
xo + x1 x m ---------------2
p. 5.11
Thus we typically evaluate the derivative term in the error expression using the midpoint in the interval
1 d f - ( x x o ) ( x x 1 ) -------e ( x ) -2 2 dx
2
x = xm
Another problem is that we typically dont know the second derivative at the midpoint of the interval, x m However using nite 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 ( x x o ) ( x x 1 ) is the largest)
1 d f - ( x m x o ) ( x m x 1 ) -------max e ( x ) x < x < x -2 0 1 2 dx
2
x = xm
However
h x1 xo
and
h h -- = x m x o and -- = x1 xm 2 2
p. 5.12
Thus
max e ( x )
x0 < x < x1
h d f = ----- -------8 d x2
2 2
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 x o and x 1 Error increases as the interval h increases
) (2) Error increases as f ( 2( x ) increases. Again note that f ( x ) can be approximated with nite difference (F.D.) formulae if at least 3 surrounding functional values are available. (We will discuss F.D. formulae later.)
p. 5.13
Example 2 Compute an error estimate for the problem in Example 1. Recall we found that
g ( 0.632 ) = 0.57500
x = xm
x = 0.750
x = 0.75
p. 5.14
Since we have not yet extensively discussed approximating derivatives using discrete
f -------values, we will compute d 2 dx d f -------2 dx
2 2
Computing the actual error (the actual solution - the estimated error):
E ( x ) = sin ( x ) g ( x ) E ( 0.632 ) = sin ( 0.632 ) 0.57500 = 0.01576