Docsity

Spline Interpolation Method - Numerical Methods - Lecture Slides, Slides of Mathematical Methods for Numerical Analysis and Optimization

Partial preview of the text

Download Spline Interpolation Method - Numerical Methods - Lecture Slides and more Slides Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Spline Interpolation Method

What is Interpolation?

Given (x

,y

), (x

,y

), …… (x

n

,y

n

), find the

value of ā€˜y’ at a value of ā€˜x’ that is not given.

Why Splines?

2 1 25

1 ( )

x

f x

=

Table : Six equidistantly spaced points in [-1, 1]

Figure : 5

th order polynomial vs. exact function

x (^) 2 1 25

1

x

y

=

  • 1.0 0.
  • 0.6 0.
  • 0.2 0.

0.2 0.

0.6 0.

1.0 0.

Why Splines?

Figure : Higher order polynomial interpolation is a bad idea

-0.

-0.

0

-1 -0.5 0 0.5 1

x

y

19th Order Polynomial f (x) 5th Order Polynomial

Linear Interpolation (contd)

( ),

( ) ( ) ( ) ( ) 0 1 0

1 0 0 x x x x

f x f x f x f x āˆ’ āˆ’

āˆ’ = + x (^) 0 ≤ x ≤ x 1

( ),

( ) ( ) ( ) 1 2 1

2 1 1 x x x x

f x f x f x āˆ’ āˆ’

āˆ’ = + x 1 (^) ≤ x ≤ x 2

.

.

.

( ),

( ) ( ) ( ) 1 1

1 1 āˆ’ āˆ’

āˆ’ āˆ’ āˆ’ āˆ’

āˆ’ = + n n n

n n n x x x x

f x f x f x x (^) n āˆ’ 1 ≤ x ≤ xn

Note the terms of

1

( ) ( 1 )

āˆ’

āˆ’ āˆ’

āˆ’

i i

i i x x

f x f x

in the above function are simply slopes between xi āˆ’ 1 and x i.

Example

The upward velocity of a rocket is given as a function

of time in Table 1. Find the velocity at t=16 seconds

using linear splines.

Table Velocity as a

function of time

Figure. Velocity vs. time data
for the rocket example
(s) (m/s)

t v ( t )

Quadratic Interpolation

Given ( x (^) 0 , y 0 ) (, x 1 , y 1 ),......, ( xn āˆ’ 1 , yn āˆ’ 1 ) (, xn , yn ), fit quadratic splines through the data. The splines

are given by

( ) 1 1 ,

2 f x = a 1 x + bx + c x (^) 0 ≤ x ≤ x 1

2 2 ,

2 = a (^) 2 x + b x + c x 1 (^) ≤ x ≤ x 2

.

.

.

,

2 = a (^) n x + bnx + c n x (^) n āˆ’ 1 ≤ x ≤ xn

Find a i , bi , ci , i =1, 2, …, n

Quadratic Interpolation (contd)

Each quadratic spline goes through two consecutive data points

1 0 1 (^0 )

2 a 1 (^) x 0 + bx + c = f x

1 1 1 (^1 )

2 a 1 (^) x 1 + bx + c = f x.

.

.

1 (^1 )

2 ai xi āˆ’ 1 + bixi āˆ’ + ci = f xi āˆ’

( )

2 a (^) i xi + bixi + ci = f x i.

.

.

1 (^1 )

2 an xn āˆ’ 1 + bnxn āˆ’ + cn = f xn āˆ’

( )

2 a (^) n xn + bnxn + cn = f x n

This condition gives 2n equations

Quadratic Splines (contd)

Similarly at the other interior points,

2 a 2 x 2 + b 2 āˆ’ 2 a 3 x 2 āˆ’ b 3 = 0

.

.

.

2 ai xi + bi āˆ’ 2 ai + 1 xi āˆ’ bi + 1 = 0

.

.

.

2 an āˆ’ 1 xn āˆ’ 1 + bn āˆ’ 1 āˆ’ 2 anxn āˆ’ 1 āˆ’ bn = 0

We have (n-1) such equations. The total number of equations is ( 2 n ) + ( n āˆ’ 1 )=( 3 n āˆ’ 1 ).

We can assume that the first spline is linear, that is a 1 = 0

Quadratic Splines (contd)

This gives us ā€˜3n’ equations and ā€˜3n’ unknowns. Once we find the ā€˜3n’ constants,
we can find the function at any value of ā€˜x’ using the splines,

( ) 1 1 ,

2 f x = a 1 x + b x + c x 0 (^) ≤ x ≤ x 1

2 2 ,

2 = a (^) 2 x + b x + c x 1 (^) ≤ x ≤ x 2

.

.

.

,

2 = a (^) n x + bnx + c n x (^) n āˆ’ 1 ≤ x ≤ xn

Solution

1 1

2

1

v t = a t + b t + c 0 ≤ t ≤ 10

, 2 2

2

2

= a t + b t + c 10 ≤ t ≤ 15

, 3 3

2

3

= a t + b t + c 15 ≤ t ≤ 20

, 4 4

2

4

= a t + b t + c 20 ≤ t ≤ 22. 5

, 5 5

2

5

= a t + b t + c 22. 5 ≤ t ≤ 30

Let us set up the equations

Each Spline Goes Through Two

Consecutive Data Points

( ) , 1 1

2

1

v t = a t + b t + c 0 ≤ t ≤ 10

( 0 ) ( 0 ) 0 1 1

2

1

a + b + c =

( 10 ) ( 10 ) 227. 04 1 1

2

1

a + b + c =

Derivatives are Continuous at

Interior Data Points

v t = a t + b t + c^0 ≤^ t ≤^10

2 2

2

2

= a t + b t + c 10 ≤ t ≤ 15

t t

a t b t c

dt

d

a t b t c

dt

d

t t

a t b a t b

2 a 10 + b = 2 a 10 + b

a + b āˆ’ a āˆ’ b =

Derivatives are continuous at

Interior Data Points

2 ( 10 ) 2 ( 10 ) 0 1 1 2 2

a + b āˆ’ a āˆ’ b =

2 ( 15 ) 2 ( 15 ) 0 2 2 3 3

a + b āˆ’ a āˆ’ b =

2 ( 20 ) 2 ( 20 ) 0 3 3 4 4

a + b āˆ’ a āˆ’ b =

2 ( 22. 5 ) 2 ( 22. 5 ) 0 4 4 5 5

a + b āˆ’ a āˆ’ b =

At t=

At t=

At t=

At t=22.