Professional Documents
Culture Documents
value of
the
n 1
xn , yn
,
x0 , y0 , x1 , y1
f x
f x
at any other
n 1
x3 , y3
x1, y1
x2 , y2
x0 , y0
f x
x
x
Of course, if
falls outside the range of
for which the data is given, it is
no longer interpolation but instead is called extrapolation. So what kind of
f x
function
should one choose? A polynomial is a common choice for an
interpolating function because polynomials are easy to
evaluate,
differentiate, and
integrate.
n 1
that
(ii)
(iii)
NEWTONS
METHOD
DIVIDED
DIFFERENCE
POLYNOMIAL
LINEAR INTERPOLATION
-simplest form of interpolation is to connect two data points with a
straight line.
Eg 1: Using linear interpolation, estimate ln 2 given
(a) ln 1=0 and ln 6=1.791759.
(b) ln 1=0 and ln 4=1.386294.
For each of the interpolations, compute the percentage error based on
the true value of ln 2, where ln 2= 0.6931472.
Sol:
(a)
(b)
y0 1.386294
=
21
41
y=0.462098
y 0 1.7917590
=
21
61
( 0.69314720.462098
) x 100
0.6931472
Error , =
33.3
y=0.3583518
( 0.69314720.3583518
) x 100
0.6931472
Error , =
48.3
QUADRATIC INTERPOLATION
The error in the above example, resulted from a curve with a straight line.
Consequently, a strategy for improving the estimate is to introduce some
curvature into the line connecting the points. If three data points are
available, this can be accomplished with a second order polynomial
(quadratic polynomial or parabola). A particularly convenient form for this
purpose is
f 2 ( x )=b o+ b1 ( xx o ) +b2 ( xx o ) ( xx 1 )
where
b0 , b1 ,
and
b2
b2=f [ x 2 , x 1 , x o ] =
f ( x1 ) f ( x o )
x 1x o
f [ x 2 , x 1 ]f [ x 1 , x o ]
x 2x o
(4, 1.386294)
(6, 1.791759)
y
x
1,0
f ( x 2 )f ( x1 ) 1.7917591.386294
=
=0.2027
x 2x 1
64
3rd
divided dif
f [ x 2 , x 1 ]f [ x 1 , x o ] 0.20270.4620981
f [ x 2 , x 1 , x o ]=
=
=0.052 b2
x 2x o
61
Error , =
18.36
-1
3
0
-4
1
5
2
-6
Sol:
43
=7 b1
0(1)
f [ x 2 , x 1 ]=
f [ x 3 , x 2 ]=
f ( x 2 )f ( x1 )
x 2x 1
9+7
=8 b2
1+ 1
f [ x 3 , x 2 , x 1 ]=
f [ x 3 , x 2 ]f [ x 2 , x 1 ] 119
=
=10
x 3x 1
20
5+4
=9
10
Thus,
f ( x 3 )f ( x 2 ) 65
=
=11
x 3x 2
21
f n ( x ) = Li ( x ) f ( x i )
i=0
where Li ( x )=
j=0
j i
xx j
designated the product of .
x ix j
24
21
( 0 )+
( 1.386294 )=0.4620981.
14
41
( 21 )( 26 )
( 21 )( 24 )
( 1.386294 ) +
( 1.791760 )
( 41 )( 46 )
( 61 )( 64 )
= 0.5658444.
SPLINE INTERPOLATION
In Mathematics, a spline is a special function defined piecewise by
polynomials. Therefore, spline interpolation is a form of interpolation
where the interpolant is a special type of piecewise polynomial. In the
previous sections, nth order-polynomials were used to interpolate between
n+1 data points. For example, for 4 points, we can derive a perfect thirdorder polynomial. This would capture all the meanderings suggested by
the points. However, there are cases where these functions can lead to
erroneous results because of round-off error and overshoot. An alternative
approach is to apply lower order polynomials to subset of data points.
Such connecting polynomials are called spline function. The main
advantages of spline interpolation are its stability and calculation
simplicity.
First-order spline/linear interpolation
Eg 7: Fit the data below with first-order splines. Hence, evaluate the
function at x=5.
X
3.0
4.5
7.0
9.0
f(x)
2.5
1.0
2.5
0.5
y
(7, 2.5)
(3, 2.5)
(4.5, 1)
(9, 0.5)
x
x+5.5 ,3 x 4.5
f ( x ) = 0.6 x 1.7 , 4.5 x 7
x +9.5
,7 x 9
Therefore,
f ( 5 ) =0.6 ( 5 )1.7=1.3 .
QUADRATIC SPLINES
The objective of the quadratic splines is to derive a second-order
polynomial for each interval between data points. The polynomial for each
interval can be represented generally as
f i ( x )=a i x 2+ bi x+ ci
the a' s , b' sc ' s are arbitrary constants .
where
3.0
7.0
2.5
2.5
4.5
9.0
1.0
0.5
Sol:
Step 1: State the piecewise function
a1 x 2+ b1 x +c 1 ,3.0 x 4.5
f ( x )= a2 x 2+ b2 x +c 2 , 4.5 x 7.0
a3 x 2+ b3 x +c 3 ,7.0 x 9.0
There should be 9 equations to find the values of as, bs and cs.
Step 2: Substitute the boundary values into f(x).
f ( 3 ) =9 a1 +3 b1 +c 1=2.5
f ( 4.5 )=20.25 a1 + 4.5b 1+ c 1=1.0
20.25 a2 +4.5 b 2+ c2 =1.0
f (7)=49 a 2+7 b2+ c 2=2.5
49 a3 +7 b 3+ c 3=2.5
f (9)=81 a3 +9 b 3+ c 3=0.5
and at x=7,
d
d
(a2 x 2+ b2 x +c 2 )|x=7= (a3 x 2 +b 3 x +c 3)|x=7
dx
dx
14
a2 +b 2=14 a3 + b3
14 a2 +b 214 a 3b3 =0
Step 4: Assume that the second derivative is zero at the first point via
setting a1=0 and write down all the 8 equations.
3 b1 +c 1=2.5
4.5 b 1+ c1=1.0
20.25 a2 +4.5 b 2+c2 =1.0
49 a 2+7 b 2+ c 2=2.5
49 a 3+7 b3 +c 3=2.5
81 a3 +9 b3 + c3 =0.5
9 a2b1 +b2=0
14 a2 14 a3 +b 2b3 =0
[][ ]
b1
1
c1
5.5
a2
0.641
b2 6.76
The values of the unknows are
=
witha 1=0.
c2
18.46
1.6
a3
24.6
b3
91.3
c3
At x=5,
The total spline fit is depicted in Figure (a) below. Notice that there are two
shortcomings that detract from the fit:
(i)
the straight line connecting the first two points, and
(ii)
the spline for the last interval seems to swing too high.
To overcome these shortcomings, the cubic splines (Figure b) are more
preferable and as a consequence, are better method for spline
interpolation.
x+1,
1x 2
x 3 x +5, 2 x 3
2
1 3 3 2 3
x x + x +1, 1 x 2
4
4
2
Ans : f ( x ) =
1 3 9 2 9
x + x x +5, 2 x 3
4
4
2