Professional Documents
Culture Documents
NUMERICAL INTERPOLATION
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
by
ENCE 203 - Computation Methods in Civil Engineering II Department of Civil and Environmental Engineering University of Maryland, College Park
Generally, the higher-order polynomial gives higher accuracy. However, this is not true in some situations, especially when the data points include local abrupt changes in f(x) values for steady changes in x values. In these situations, the accuracy decreases.
Assakkaf
In these cases, the function can lead to erroneous results because of round-off error and overshoot. An alternative approach is to use a lower-order polynomial to subsets of the data points. Such connecting polynomials are called splines functions.
Assakkaf
The concept of spline came from the drafting technique of using thin flexible strip, called spline, to draw smooth curves through a set of points as shown in the figure of the viewgraph. The drafter places paper over wooden board and hammer nails into the paper and the board at the locations of the data points.
Assakkaf
Assakkaf
x
Abrupt change indicates oscillation in interpolating polynomial.
Assakkaf
x
Abrupt change indicates oscillation in interpolating polynomial.
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
Assakkaf
x
Abrupt change indicates oscillation in interpolating polynomial.
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
Assakkaf
x
The spline provides a much more acceptable approximation.
Assakkaf
Types of Splines
1. Linear (simplest), 2. Quadratic, and 3. Cubic (most popular)
Assakkaf
f (x ) S1 S2 S3
x
Assakkaf
f (x ) S1 S2 x
Assakkaf
S3
f (x ) S1 S2 S3
x
Assakkaf
Linear Splines
Linear or first-order splines are the simplest to construct. They are straight lines connecting two pair of the data points. Therefore, an algorithm for straight lines that connect each pair of the data points can be developed very easily.
Assakkaf
Linear Splines
The interpolation function can be expressed as
f1 (x ) = f (x1 ) + f 2 (x ) = f (x 2 ) + ! f i (x ) = f (xi ) + f (x2 ) f (x1 ) (x x1 ) x2 x1 for x1 x x2 for x 2 x x3 f (x3 ) f (x 2 ) (x x2 ) x3 x2
(1)
f (xi +1 ) f (xi ) (x xi ) xi +1 xi
for xi x xi +1 for x n 1 x xn
Assakkaf
f n 1 (x ) = f (xn 1 ) +
f (xn ) f (xn 1 ) (x xn 1 ) xn x n 1
Linear Splines
Requirements for Linear Splines:
The linear spline functions as presented by the previous equations are to satisfy the following condition:
f i (xi ) = f i +1 (xi )
Assakkaf
x 3 4.5
f(x) 2.5 1
Assakkaf
Assakkaf
Assakkaf
10
Thus,
= 1.7 + 0.6(5)
Assakkaf
f1
f2 f3
11
Quadratic Splines
The quadratic splines provide a quadratic equation connecting any two adjacent data points within the data set of the type
[xi , f (xi )]
i x f(x) 1 x1 f(x1) 2 x2 f(x2)
for i = 1,2,3," , n
3 x3 f(x3) 4 x4 f(x4) n xn f(xn)
Assakkaf
Quadratic Splines
The general form of a quadratic equation between point [xi, f(xi)] and [xi+1, f(xi+1)] is
f i (x ) = ai x 2 + bi x + ci
Assakkaf
12
Quadratic Splines
Every two adjacent data points have an interpolation equation given by Eq. 3, with three constants ai, bi, and ci. As a result, there are 3(n 1)unknowns that need to be determined using the data set, requiring 3(n 1) conditions
Assakkaf
Quadratic Splines
Conditions for Quadratic Splines:
1. The splines must pas through the data points. For the ith spline, this condition can be expressed as
f i (xi ) = ai xi2 + bi xi + ci = f (xi ) f i (xi +1 ) = ai xi2+1 + bi xi +1 + ci = f (xi +1 ) for i = 1,2,3, " , n 1 for i = 1,2,3, " , n 1
(4a) (4b)
Assakkaf
13
Quadratic Splines
Conditions for Quadratic Splines:
2. The splines must be continuous at the interior data points. This condition can be expressed using the first derivatives of the quadratic splines as
2ai xi +1 + bi = 2ai +1 xi +1 + bi +1 for i = 1,2,3, " , n 2
(5)
Assakkaf
Quadratic Splines
Conditions for Quadratic Splines:
3. The last condition can be arbitrary. The second derivative for the spline between the first two data points can be set equal to zero. Since the second derivative for the first spline is 2a1, this condition can be written as
2a1 = 0 a1 = 0
(6)
Assakkaf
14
Quadratic Splines
Equations 4 to 6 provide the needed 3(n 1) conditions to solve for the 3(n 1) unknowns ai, bi, and ci, i = 1,2,, n 1. The resulting quadratic splines provide the desired continuity while passing through the data points.
Assakkaf
15
ai xi2 + bi xi + ci = f (xi ) ai x
2 i +1
+ bi xi +1 + ci = f (xi +1 )
2
a1 (4.5) + b1 (4.5) + c1 = 1
2
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
(7)
Assakkaf
ai xi2 + bi xi + ci = f (xi ) ai x
2 i +1
+ bi xi +1 + ci = f (xi +1 )
2
(8)
Assakkaf
16
ai xi2 + bi xi + ci = f (xi ) ai x
2 i +1
+ bi xi +1 + ci = f (xi +1 )
2
(9)
Assakkaf
2ai xi +1 + bi = 2ai +1 xi +1 + bi +1
for i = 1,2,3," , n 2
(10)
Assakkaf
17
a1 = 0
Since a1 = 0, the resulting system of 3(n-1) - 1= 3(4 1)-1 = 8 equations can be obtained as follows:
Assakkaf
(11)
18
(12)
Assakkaf
Assakkaf
19
Thus,
= 0.66
Assakkaf
f1
f2
f3
x
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
Slide No. 202
20
Cubic Splines
The cubic splines provide a cubic equation connecting any two adjacent data points within the data set of the type
[xi , f (xi )]
i x f(x) 1 x1 f(x1) 2 x2 f(x2)
for i = 1,2,3," , n
3 x3 f(x3) 4 x4 f(x4) n xn f(xn)
Assakkaf
Cubic Splines
The general form of a cubic equation between point [xi, f(xi)] and [xi+1, f(xi+1)] is
f i (x ) = ai x 3 + bi x 2 + ci x + d i For i = 1,2," , n 1
(14)
Assakkaf
21
Cubic Splines
Every two adjacent data points have an interpolation equation given by Eq. 14, with three constants ai, bi, ci,and di. As a result, there are 4(n 1)unknowns that need to be determined using the data set, requiring 4(n 1) conditions
Assakkaf
Cubic Splines
Conditions for Cubic Splines:
1. The splines must pas through the data points. For the ith spline, this condition can be expressed as for i = 1,2,3, " , n 1 (15a) f i (xi ) = ai xi3 + bi xi2 + ci xi + d i = f (xi )
f i (xi +1 ) = ai xi3+1 + bi xi2=1 + ci xi + d i = f (xi +1 ) for i = 1,2,3, ", n 1 (15b)
Assakkaf
22
Cubic Splines
Conditions for Quadratic Splines:
2. The splines must be continuous at the interior data points. This condition can be expressed using the first derivatives of the cubic splines as
Assakkaf
Cubic Splines
Conditions for Quadratic Splines:
3. The splines must satisfy the second derivative continuity at the interior points. This condition can expressed as
(17)
Assakkaf
23
Cubic Splines
Conditions for Quadratic Splines:
4. The last condition can be set as the second derivative at the first and last data points to be zero. This condition is as follows:
(18)
Assakkaf
Cubic Splines
Equations 15 to 18 provide the needed 4(n 1) conditions to solve for the 4(n 1) unknowns ai, bi, ci,and di, i = 1,2,, n 1. The resulting cubic splines provide the desired continuity while passing through the data points.
Assakkaf
24
For the first data pairs, Eqs. 15a and 15b apply as follows: 3 i x f(x) f i (xi ) = ai xi + bi xi2 + ci xi + d i = f (xi ) for i = 1,2,3," , n 1
f i (xi +1 ) = ai xi3+1 + bi xi2+1 + ci xi + d i = f (xi +1 )
3 2
3 4.5
2.5 1
(19)
Assakkaf
25
For the second data pairs, Eqs. 15a and 15b apply as follows: 3 i x f i (xi ) = ai xi + bi xi2 + ci xi + d i = f (xi ) for i = 1,2,3," , n 1
f i (xi +1 ) = ai xi3+1 + bi xi2+1 + ci xi + d i = f (xi +1 )
3 2
4.5 7
(20)
Assakkaf
For the third data pairs, Eqs. 15a and 15b apply as follows: 3 i x f(x) f i (xi ) = ai xi + bi xi2 + ci xi + d i = f (xi ) for i = 1,2,3," , n 1
f i (xi +1 ) = ai xi3+1 + bi xi2+1 + ci xi + d i = f (xi +1 )
3 2
7 9
2.5 0.5
(21)
Assakkaf
26
2 3
4.5 7
(22)
Assakkaf
2 3
4.5 7
(23)
Assakkaf
27
i 3 4
x 7 9
6a1 xi + 2b1 = 0 6an 1 xn + 2bn 1 = 0 6a3 (9 ) + 2b3 = 0 6a1 (3) + 2b1 = 0 (24)
I
27a1 +
343a3 + 49b3 + 7c3 + d 3 = 2.5 729a3 + 81b3 + 9c3 + d 3 = 0.5 60.75a1 + 27a1 + 18a1 + 2b1 54a3 + 2b3
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
9b1 + c1 2b1
60.75a 2 9b2 c2 147a 2 + 14b2 + c2 27a 2 2b2 42a 2 + 2b2 42a3 2b3 147a3 14b3 c3
=0 =0 =0 =0 =0 =0
(25)
Assakkaf
28
0 0 0 60.75 0 0 0 0 0 147 27 42 0 0
0 0 1 0 1 0 0 0 0 0 0 0 0 0
a1 0.172 b 1.547 1 c1 3.253 d1 2.020 a2 0.177 b2 3.163 = c 17.941 2 d 2 33.813 a3 0.0528 b3 0.554 c3 0.326 d 8.813 3
29
f (x ) 1.5 1 0.5 0 0 2
f1
f2
f3
4 x
10
Assakkaf
Comparison among Linear, Quadratic, and Cubic Splines for Examples 1, 2, and 3
Splines 3.5 3 2.5 f (x ) 2 1.5 1 0.5 0 0 1 2 3 4 5 x
Assakkaf
10
30
Comparison among Linear, Quadratic, and Cubic Splines for Examples 1, 2, and 3 with Third-order Polynomial
Linear Quadratic Cubic 3rd Degree
6 x
10
Assakkaf
Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
f (x1 , x2 , x3 , ", xn )
I
Assakkaf
31
Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
The previously introduced methods for one-dimensional case can be applied to multidimensional interpolation. However, with increased computational difficulties. To illustrate the concept, linear interpolation is introduced for twodimensional interpolation.
Assakkaf
Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
Two-dimensional Interpolation
Example 4
The following table gives the values of the gravitational acceleration, g, in feet per second squared as a function of altitude L (in degrees) and elevation E (in feet). Find the value of g when L = 12.50 and E = 500 feet.
Assakkaf
32
Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
Two-dimensional Interpolation
Example 4 E = 0 ft 32.0877 32.0890 32.0928 32.0991 32.1075 E = 1000 ft 32.0847 32.0859 32.0897 32.0960 32.1044 E = 2000 ft 32.0816 32.0829 32.086 32.0929 32.1013
Assakkaf
Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
Two-dimensional Interpolation
Example 4 (contd)
f (x1 , x2 ) = g (L, E )
First, we interpolate for E at L = 10 to obtain g(100, 500 feet).
E 0 500 1000 g 32.0928 g1 32.0897
Assakkaf
33
Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
Two-dimensional Interpolation
Example 4 (contd)
Second, we interpolate for E at L = 15 to obtain g(150, 500 feet).
E 0 500 1000 g 32.0991 g1 32.0960 g 2 32.0991 500 0 = g 2 = 32.09755 1000 0 32.0960 32.0991
Assakkaf
Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering
Two-dimensional Interpolation
Example 4 (contd)
Using the values of g1 and g2, we interpolate for L at E = 500 to obtain g(12.50, 500 feet).
L 10 12.5 15 g 32.09125 g3 32.09755 g 2 32.09125 12.5 10 = g 3 = 32.0944 15 10 32.09755 32.09125
34