Spline Interpolation Method Power Point - Mathematics for...

32
http:// numericalmethods.eng.usf.edu 1 Spline Interpolation Method Major: All Engineering Majors Authors: Autar Kaw, Jai Paul http://numericalmethods.eng.u sf.edu Transforming Numerical Methods Education for STEM Undergraduates

Transcript of Spline Interpolation Method Power Point - Mathematics for...

http://numericalmethods.eng.usf.edu 1

Spline Interpolation Method

Major: All Engineering Majors

Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.eduTransforming Numerical Methods Education for STEM

Undergraduates

Spline Method of Interpolation

http://numericalmethods.eng.usf.edu

http://numericalmethods.eng.usf.edu3

What is Interpolation ?Given (x0,y0), (x1,y1), …… (xn,yn), find the value of ‘y’ at a value of ‘x’ that is not given.

http://numericalmethods.eng.usf.edu4

Interpolants Polynomials are the most

common choice of interpolants because they are easy to:

EvaluateDifferentiate, and Integrate.

Rocket Example Results

http://numericalmethods.eng.usf.edu5

t (s)

v (m/s)

0 010 227.0415 362.7820 517.35

22.5 602.9730 901.67

Polynomial Order

Velocity at t=16 in m/s

Absolute Relative Approximate Error

Least Number of Significant Digits Correct

1 393.69 -------------2 392.19 0.38% 23 392.05 0.036% 34 392.07 0.0051% 35 392.06 0.0026% 4

http://numericalmethods.eng.usf.edu6

Why Splines ?2251

1)(x

xf

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

Figure : 5th order polynomial vs. exact function

x 22511x

y

-1.0 0.038461

-0.6 0.1

-0.2 0.5

0.2 0.5

0.6 0.1

1.0 0.038461

http://numericalmethods.eng.usf.edu7

Why Splines ?

Figure : Higher order polynomial interpolation is a bad idea

-0.8

-0.4

0

0.4

0.8

1.2

-1 -0.5 0 0.5 1

x

y

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

http://numericalmethods.eng.usf.edu8

Linear InterpolationGiven nnnn yxyxyxyx ,,,......,,,, 111100 , fit linear splines to the data. This simply involves

forming the consecutive data through straight lines. So if the above data is given in an ascending

order, the linear splines are given by )( ii xfy

Figure : Linear splines

http://numericalmethods.eng.usf.edu9

Linear Interpolation (contd)

),()()(

)()( 001

010 xx

xxxfxf

xfxf

10 xxx

),()()(

)( 112

121 xx

xxxfxf

xf

21 xxx

.

.

.

),()()(

)( 11

11

nnn

nnn xx

xxxfxf

xf nn xxx 1

Note the terms of

1

1 )()(

ii

ii

xxxfxf

in the above function are simply slopes between 1ix and ix .

http://numericalmethods.eng.usf.edu10

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)0 010 227.0415 362.7820 517.35

22.5 602.9730 901.67

t )(tv

http://numericalmethods.eng.usf.edu11

Linear Interpolation

10 12 14 16 18 20 22 24350

400

450

500

550517.35

362.78

y s

f range( )

f x desired

x s110x s0

10 x s range x desired

,150 t 78.362)( 0 tv

,201 t 35.517)( 1 tv

)()()(

)()( 001

010 tt

tttvtv

tvtv

)15(1520

78.36235.51778.362

t

)15(913.3078.362)( ttv

At ,16t

)1516(913.3078.362)16( v

7.393 m/s

http://numericalmethods.eng.usf.edu12

Quadratic InterpolationGiven nnnn yxyxyxyx ,,,,......,,,, 111100 , fit quadratic splines through the data. The splines

are given by

,)( 112

1 cxbxaxf 10 xxx

,222

2 cxbxa 21 xxx

.

.

.

,2nnn cxbxa nn xxx 1

Find ,ia ,ib ,ic i 1, 2, …, n

http://numericalmethods.eng.usf.edu13

Quadratic Interpolation (contd)

Each quadratic spline goes through two consecutive data points

)( 01012

01 xfcxbxa

)( 11112

11 xfcxbxa .

.

.

)( 112

1 iiiiii xfcxbxa

)(2iiiiii xfcxbxa .

.

.

)( 112

1 nnnnnn xfcxbxa

)(2nnnnnn xfcxbxa

This condition gives 2n equations

http://numericalmethods.eng.usf.edu14

Quadratic Splines (contd)The first derivatives of two quadratic splines are continuous at the interior points.

For example, the derivative of the first spline

112

1 cxbxa is 112 bxa

The derivative of the second spline

222

2 cxbxa is 222 bxa

and the two are equal at 1xx giving

212111 22 bxabxa

022 212111 bxabxa

http://numericalmethods.eng.usf.edu15

Quadratic Splines (contd)Similarly at the other interior points,

022 323222 bxabxa

.

.

.

022 11 iiiiii bxabxa

.

.

.

022 1111 nnnnnn bxabxa

We have (n-1) such equations. The total number of equations is )13()1()2( nnn .

We can assume that the first spline is linear, that is 01 a

http://numericalmethods.eng.usf.edu16

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,

,)( 112

1 cxbxaxf 10 xxx

,222

2 cxbxa 21 xxx

.

.

.

,2nnn cxbxa nn xxx 1

http://numericalmethods.eng.usf.edu17

Quadratic Spline ExampleThe upward velocity of a rocket is given as a function of time. Using quadratic splinesa) Find the velocity at t=16 secondsb) Find the acceleration at t=16 secondsc) Find the distance covered between t=11 and t=16 secondsTable Velocity as a

function of time

Figure. Velocity vs. time data for the rocket example

(s) (m/s)0 0

10 227.0415 362.7820 517.35

22.5 602.9730 901.67

t )(tv

http://numericalmethods.eng.usf.edu18

Solution,)( 11

21 ctbtatv 100 t

,222

2 ctbta 1510 t

,332

3 ctbta 2015 t,44

24 ctbta 5.2220 t

,552

5 ctbta 305.22 t

Let us set up the equations

http://numericalmethods.eng.usf.edu19

Each Spline Goes Through Two Consecutive Data

Points,)( 11

21 ctbtatv 100 t

0)0()0( 112

1 cba04.227)10()10( 11

21 cba

http://numericalmethods.eng.usf.edu20

t v(t)s m/s0 0

10 227.0415 362.7820 517.35

22.5 602.9730 901.67

Each Spline Goes Through Two Consecutive Data

Points04.227)10()10( 22

22 cba

78.362)15()15( 222

2 cba78.362)15()15( 33

23 cba

35.517)20()20( 332

3 cba

67.901)30()30( 552

5 cba

35.517)20()20( 442

4 cba97.602)5.22()5.22( 44

24 cba

97.602)5.22()5.22( 552

5 cba

http://numericalmethods.eng.usf.edu21

Derivatives are Continuous at Interior Data Points

,)( 112

1 ctbtatv 100 t

,222

2 ctbta 1510 t

10

222

210

112

1

tt

ctbtadtdctbta

dtd

10221011 22

ttbtabta

2211 102102 baba

02020 2211 baba

http://numericalmethods.eng.usf.edu22

Derivatives are continuous at Interior Data Points

0)10(2)10(2 2211 baba

0)15(2)15(2 3322 baba

0)20(2)20(2 4433 baba

0)5.22(2)5.22(2 5544 baba

At t=10

At t=15

At t=20

At t=22.5

http://numericalmethods.eng.usf.edu23

Last Equation

01 a

http://numericalmethods.eng.usf.edu24

Final Set of Equations

00000

67.90197.60297.60235.51735.51778.36278.36204.22704.227

0

0000000000000010145014500000000000001400140000000000000013001300000000000000120012013090000000000000015.2225.50600000000000000015.2225.506000000000000120400000000000000000120400000000000000115225000000000000000115225000000000000110100000000000000000110100000000000000100

5

5

5

4

4

4

3

3

3

2

2

2

1

1

1

cbacbacbacbacba

http://numericalmethods.eng.usf.edu25

Coefficients of Splinei ai bi ci1 0 22.704 02 0.8888 4.928 88.883 −0.1356 35.66 −141.6

14 1.6048 −33.95

6554.55

5 0.20889 28.86 −152.13

http://numericalmethods.eng.usf.edu26

Quadratic Spline InterpolationPart 2 of 2

http://numericalmethods.eng.usf.edu

http://numericalmethods.eng.usf.edu27

Final Solution,704.22)( ttv 100 t

,88.88928.48888.0 2 tt 1510 t,61.14166.351356.0 2 tt 2015 t,55.554956.336048.1 2 tt 5.2220 t,13.15286.2820889.0 2 tt 305.22 t

http://numericalmethods.eng.usf.edu28

Velocity at a Particular Pointa) Velocity at t=16

,704.22)( ttv 100 t,88.88928.48888.0 2 tt 1510 t

,61.14166.351356.0 2 tt 2015 t,55.554956.336048.1 2 tt 5.2220 t,13.15286.2820889.0 2 tt 305.22 t

m/s24.394

61.1411666.35161356.016 2

v

http://numericalmethods.eng.usf.edu29

Acceleration from Velocity Profile

16)()16(

ttv

dtda

b) The quadratic spline valid at t=16 is given by

)61.14166.351356.0()( 2 ttdtdta

,66.352712.0 t 2015 t

66.35)16(2712.0)16( a 2m/s321.31

,61.14166.351356.0 2 tttv 2015 t

http://numericalmethods.eng.usf.edu30

Distance from Velocity Profile

c) Find the distance covered by the rocket from t=11s to t=16s.

16

11

)(1116 dttvSS

2015,61.14166.351356.0

1510,88.88928.48888.02

2

ttt

ttttv

m9.1595

61.14166.351356.088.88928.48888.0

1116

16

15

215

11

2

16

11

15

11

16

15

dtttdttt

dttvdttvdttvSS

Additional ResourcesFor all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit

http://numericalmethods.eng.usf.edu/topics/spline_method.html

THE END

http://numericalmethods.eng.usf.edu