You are on page 1of 34

CHAPTER 6f.

NUMERICAL INTERPOLATION
A. J. Clark School of Engineering Department of Civil and Environmental Engineering

by

Dr. Ibrahim A. Assakkaf


Spring 2001

ENCE 203 - Computation Methods in Civil Engineering II Department of Civil and Environmental Engineering University of Maryland, College Park

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 164

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 165

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 166

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Origin of Spline Concept

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 167

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Need for Splines f(x)

x
Abrupt change indicates oscillation in interpolating polynomial.
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 168

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Need for Splines f(x)

x
Abrupt change indicates oscillation in interpolating polynomial.
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
Assakkaf

Slide No. 169

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Need for Splines f(x)

x
Abrupt change indicates oscillation in interpolating polynomial.
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
Assakkaf

Slide No. 170

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Need for Splines f(x)

x
The spline provides a much more acceptable approximation.
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 171

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Types of Splines
1. Linear (simplest), 2. Quadratic, and 3. Cubic (most popular)

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 172

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Linear or First-order Splines

f (x ) S1 S2 S3

x
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 173

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Quadratic or Second-order Splines

f (x ) S1 S2 x
Assakkaf

S3

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 174

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Cubic or Third-order Splines

f (x ) S1 S2 S3

x
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 175

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 176

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 177

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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 )

For i = 1,2, ", n 1


(2)
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 178

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 1 (Linear Splines)


Fit the following set of data with first-order (linear) splines. Evaluate the function at x = 5. Also plot the spline functions.
x f (x ) 3 2.5 4.5 1 7 2.5 9 0.5

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 179

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 1 - Linear Splines


For the first pairs of data:
f1 (x ) = f (x1 ) + f1 (x ) = 2.5 + f (x 2 ) f (x1 ) (x x1 ) x 2 x1

x 3 4.5

f(x) 2.5 1

1 2.5 (x 3) 4.5 3 f1 (x ) = 2.5 ( x 3) f (x ) = 5.5 x For 3 x 4.5

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 180

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 1 (contd) - Linear Splines


For the second pairs of data:
f 2 (x ) = f (x 2 ) + f 2 (x ) = 1 + f (x3 ) f (x 2 ) (x x2 ) x3 x 2
x 4.5 7 f(x) 1 2.5

2.5 1 (x 4.5) 7 4 .5 f1 (x ) = 1 + 0.6( x 4.5) f (x ) = 1.7 + 0.6 x For 4.5 x 7

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 181

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 1 (contd) - Linear Splines


For the third pairs of data:
f 3 (x ) = f (x3 ) + f 2 (x ) = 2.5 + f (x 4 ) f (x3 ) (x x3 ) x 4 x3
x 7 9 f(x) 2.5 0.5

0.5 2.5 (x 7 ) 97 f1 (x ) = 2.5 ( x 7) f (x ) = 9.5 x For 7 x 9

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 182

10

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 1 (contd) - Linear Splines


Finding the value of the function when x = 5 If x = 5, then the following spline applies:
f (x ) = 1.7 + 0.6 x For 4.5 x 7

Thus,

f (5) = 1.7 + 0.6 x = 1 .3

= 1.7 + 0.6(5)
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 183

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 1 (contd) - Linear Splines


Plot of the linear spline functions:
3 2.5 2 f (x ) 1.5 1 0.5 0 0 2 4 x 6 8 10
Assakkaf

f1

f2 f3

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 184

11

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 185

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

For i = 1,2, ", n 1


(3)

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 186

12

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 187

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 188

13

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 189

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 190

14

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 191

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 Quadratic Splines


Fit the following set of data with secondorder (quadratic) splines. Evaluate the function at x = 5. Also plot the spline functions.
i x f(x) 1 3 2.5 2 4.5 1 3 7 2.5 4 9 0.5
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 192

15

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


For the first data pairs, Eqs. 4a and 4b apply as follows:
i 1 x 3 4.5 f(x) 2.5 1

ai xi2 + bi xi + ci = f (xi ) ai x
2 i +1

for i = 1,2,3," , n 1 for i = 1,2,3," , n 1

+ bi xi +1 + ci = f (xi +1 )
2

a1 (4.5) + b1 (4.5) + c1 = 1
2
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

a1 (3) + b1 (3) + c1 = 2.5

(7)
Assakkaf

Slide No. 193

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


For the second data pairs, Eqs. 4a and 4b apply as follows:
i 2 x 4.5 7 f(x) 1 2.5

ai xi2 + bi xi + ci = f (xi ) ai x
2 i +1

for i = 1,2,3," , n 1 for i = 1,2,3," , n 1

+ bi xi +1 + ci = f (xi +1 )
2

a 2 (4.5) + b2 (4.5) + c2 = 1 a 2 (7 ) + b2 (7 ) + c2 = 2.5


2
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

(8)
Assakkaf

Slide No. 194

16

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


For the third data pairs, Eqs. 4a and 4b apply as follows:
i 3 x 7 9 f(x) 2.5 0.5

ai xi2 + bi xi + ci = f (xi ) ai x
2 i +1

for i = 1,2,3," , n 1 for i = 1,2,3," , n 1

+ bi xi +1 + ci = f (xi +1 )
2

a3 (7 ) + b3 (7 ) + c3 = 2.5 a3 (9) + b3 (9) + c3 = 0.5


2
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

(9)
Assakkaf

Slide No. 195

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


For the first and second data pairs, Eqs. 5 applies as follows:
i 2 3 x 4.5 7 f(x) 1 2.5

2ai xi +1 + bi = 2ai +1 xi +1 + bi +1

for i = 1,2,3," , n 2

2a1 (4.5) + b1 = 2a 2 (4.5) + b2 2a 2 (7 ) + b2 = 2a3 (7 ) + b3

(10)
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 196

17

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


The last condition comes from Eq. 6 as

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 197

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


3b1 + c1 4.5b1 + c1 20.25a 2 + 4.5b2 + c 2 49a 2 + 7b2 + c2 = 2. 5 =1 =1 = 2. 5

(11)

49a3 + 7b3 + c3 = 2.5 81a3 + 9b3 + c3 = 0.5 b1 9a 2 14a 2 b2 + b2 14a3 b3 =0 =0


Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 198

18

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


Eq. 11 can be rewritten in a matrix form as
3 4.5 0 0 0 0 1 0 1 0 0 1 0 0 0 20.25 4.5 0 49 7 0 0 0 0 0 0 9 14 0 0 1 1 0 0 1 1 0 0 0 0 0 b1 2.5 0 c1 1 0 a 2 1 0 b2 2.5 = 49 7 1 c2 2.5 81 9 1 a3 0.5 0 0 0 b3 0 14 1 0 0 c3 0 0 0 0 0 0 0 0

(12)

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 199

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) Quadratic Splines


Therefore,
f1 (x ) = x + 5.5 f 2 (x ) = 0.64 x 2 6.76 x + 18.46 f 3 (x ) = 1.6 x 2 + 24.6 x 91.3 for 3 x 4.5 for 4.5 x 7 for 7 x 9

b1 1 c 1 5.5 a 2 0.64 b2 = 6.76 c 2 18.46 a3 1.6 b 24.6 3 91.3 c3

(13a) (13b) (13c)

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 200

19

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 1 (contd) - Quadratic Splines


Finding the value of the function when x = 5 If x = 5, then the following spline of Eq. 13b applies:
f 2 (x ) = 0.64 x 2 6.76 x + 18.46 for 4.5 x 7

Thus,

f (5) = 0.64(5) 6.76(5) + 18.46


2

= 0.66
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 201

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 2 (contd) - Quadratic Splines


Plot of the quadratic spline functions:
3.5 3 2.5 2 f (x ) 1.5 1 0.5 0
0 2 4 6 8 10
Assakkaf

f1

f2

f3

x
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION
Slide No. 202

20

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 203

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 204

21

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 205

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 206

22

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

3ai xi2+1 + 2bi xi +1 + ci = 3ai +1 xi2+1 + 2bi +1 xi +1 + ci +1 (16) for i = 1,2,3,", n 2

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 207

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Cubic Splines
Conditions for Quadratic Splines:
3. The splines must satisfy the second derivative continuity at the interior points. This condition can expressed as

6ai xi +1 + 2bi = 6ai +1 xi +1 + 2bi +1 for i = 1,2,3, ", n 2


ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

(17)

Assakkaf

Slide No. 208

23

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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:

6a1 xi + 2b1 = 0 6a n 1 x n + 2bn 1 = 0


ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

(18)

Assakkaf

Slide No. 209

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 210

24

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 Cubic Splines


Fit the following set of data with third-order (cubic) splines. Evaluate the function at x = 5. Also plot the spline functions.
i x f(x) 1 3 2.5 2 4.5 1 3 7 2.5 4 9 0.5
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 211

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines

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

for i = 1,2,3, ", n 1

a1 (3) + b1 (3) + c1 (3) + d1 = 2.5


3 2

a1 (4.5) + b1 (4.5) + c1 (4.5) + d1 = 1


ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

(19)
Assakkaf

Slide No. 212

25

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines


f(x) 1 2.5

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

for i = 1,2,3, ", n 1

a 2 (4.5) + b2 (4.5) + c2 (4.5) + d 2 = 1 a 2 (7 ) + b2 (7 ) + c2 (7 ) + d 2 = 2.5


3 2
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

(20)
Assakkaf

Slide No. 213

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines

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

for i = 1,2,3, ", n 1

a3 (7 ) + b3 (7 ) + c3 (7 ) + d 3 = 2.5 a3 (9) + b3 (9 ) + c3 (9 ) + d 3 = 0.5


3 2
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

(21)
Assakkaf

Slide No. 214

26

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines


For the second and third data pairs, Eq. 16 applies as follows:
i x f(x) 1 2.5

3ai xi2+1 + 2bi xi +1 + ci = 3ai +1 xi2+1 + 2bi +1 xi +1 + ci +1 for i = 1,2,3, ", n 2

2 3

4.5 7

3a 2 (7 ) + 2b2 (7 ) + c2 = 3a3 (7 ) + 2b3 (7 ) + c3


2 2
ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

3a1 (4.5) + 2b1 (4.5) + c1 = 3a 2 (4.5) + 2b2 (4.5) + c2


2 2

(22)
Assakkaf

Slide No. 215

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines


For the second and third data pairs, Eq. 17 applies as follows:
i x f(x) 1 2.5

6ai xi +1 + 2bi = 6ai +1 xi +1 + 2bi +1 for i = 1,2,3, ", n 2


6a1 (4.5) + 2b1 = 6a 2 (4.5) + 2b2 6a 2 (7 ) + 2b2 = 6a3 (7 ) + 2b3

2 3

4.5 7

(23)
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 216

27

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines


The last condition comes from Eq. 18 as
f(x) 2.5 0.5

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)

Therefore, the 12 equations [4(4-1)] are as follows:


Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 217

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

I
27a1 +

Example 3 (contd) Cubic Splines


9b1 + 3c1 + d1 91.125a2 + 20.25b2 + 4.5c2 + d 2 343a2 + 49b2 + 7c2 + d 2 = 2.5 =1 =1 = 2.5

91.125a1 + 20.25b1 + 4.5c1 + d1

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

Slide No. 218

28

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines


1 1 0 0 0 0 0 91.125 343 0 0 0 49 0 0 9 14 2 2 0 0 0 0 7 0 0 0 1 0 20.25 4.5 1 0 a1 2.5 0 b1 1 0 0 0 0 c1 1 0 0 0 0 d1 2.5 343 49 7 1 a 2 2.5 729 81 9 1 b2 0.5 = 0 0 0 0 c 2 0 147 14 1 0 d 2 0 0 0 0 0 a3 0 42 2 0 0 b3 0 0 0 0 0 c3 0 0 0 54 2 d 3 0 0 0 0 0 0 0
Assakkaf

9 3 27 91.125 20.25 4.5 0 0 0 0 0 0 0 0 0 0 0 0 60.75 9 1 0 0 0 27 2 0 0 0 0 2 0 18 0 0 0

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 219

Interpolation Using Splines


I
A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines


Therefore,
f1 (x ) = 0.172 x 3 1.547 x 2 + 3.253 x + 2.02 f 2 (x ) = 0.177 x 3 + 3.163 x 2 17.941x + 33.813 f 3 (x ) = 0.0528 x 3 + 0.554 x 2 + 0.326 x 8.813 for 3 x 4.5 for 4.5 x 7 for 7 x 9

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

f (5) = 0.177(5) 3 + 3.163(5) 2 17.941(5) + 33.813 = 1.058


Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 220

29

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

Example 3 (contd) Cubic Splines


3 2.5 2

f (x ) 1.5 1 0.5 0 0 2

f1

f2

f3

4 x

10
Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 221

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

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

Linear Quadratic Cubic

10

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 222

30

Interpolation Using Splines


A. J. Clark School of Engineering Department of Civil and Environmental Engineering

3.5 3 2.5 2 f (x ) 1.5 1 0.5 0

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 223

Multidimensional Interpolation
A. J. Clark School of Engineering Department of Civil and Environmental Engineering

In general, the function of interest can take the following form:

f (x1 , x2 , x3 , ", xn )
I

In most engineering applications, twodimensional interpolation is required.

Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 224

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 225

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 226

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

L = 00 L = 50 L = 100 L = 150 L = 200

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 227

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

g1 32.0928 500 0 = g1 = 32.09125 1000 0 32.0897 32.0928

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 228

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

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 229

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

Therefore, g(12.50, 500 feet) = g3 = 32.0944 ft/s2


Assakkaf

ENCE 203 CHAPTER 6f. NUMERICAL INTERPOLATION

Slide No. 230

34

You might also like