+ All Categories
Home > Documents > CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

Date post: 20-Feb-2016
Category:
Upload: sonora
View: 62 times
Download: 3 times
Share this document with a friend
Description:
CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:. KFUPM Read Chapter 18, Sections 1-5. L ecture 20 Introduction to Interpolation. Introduction Interpolation Problem Existence and Uniqueness Linear and Quadratic Interpolation Newton’s Divided Difference Method - PowerPoint PPT Presentation
Popular Tags:
48
CISE301_Topic5 KFUPM 1 CISE301: Numerical Methods Topic 5: Interpolation Lectures 20-22: KFUPM Read Chapter 18, Sections 1-5
Transcript
Page 1: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 1

CISE301: Numerical Methods

Topic 5: InterpolationLectures 20-22:

KFUPM

Read Chapter 18, Sections 1-5

Page 2: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 2

Lecture 20Introduction to Interpolation

IntroductionInterpolation ProblemExistence and UniquenessLinear and Quadratic Interpolation Newton’s Divided Difference MethodProperties of Divided Differences

Page 3: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 3

Introduction Interpolation was used for

long time to provide an estimate of a tabulated function at values that are not available in the table.

What is sin (0.15)?

x sin(x)0 0.00000.1 0.09980.2 0.19870.3 0.29550.4 0.3894

Using Linear Interpolation sin (0.15) ≈ 0.1493 True value (4 decimal digits) sin (0.15) = 0.1494

Page 4: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 4

The Interpolation Problem Given a set of n+1 points,

Find an nth order polynomial that passes through all points, such that:

)(,....,,)(,,)(, 1100 nn xfxxfxxfx

)(xfn

niforxfxf iin ,...,2,1,0)()(

Page 5: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 5

Example An experiment is used to determine

the viscosity of water as a function of temperature. The following table is generated:

Problem: Estimate the viscosity when the temperature is 8 degrees.

Temperature(degree)

Viscosity

0 1.792

5 1.519

10 1.308

15 1.140

Page 6: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 6

Interpolation ProblemFind a polynomial that fits the data points

exactly.

)V(TV

TaV(T)

ii

n

k

kk

0

tscoefficien Polynomial:eTemperatur:

Viscosity:

kaTV

Linear Interpolation: V(T)= 1.73 − 0.0422 TV(8)= 1.3924

Page 7: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 7

Existence and Uniqueness Given a set of n+1 points:

Assumption: are distinct

Theorem:There is a unique polynomial fn(x) of order ≤ n

such that:,...,n,iforxfxf iin 10)()(

nxxx ,...,, 10

)(,....,,)(,,)(, 1100 nn xfxxfxxfx

Page 8: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 8

Examples of Polynomial InterpolationLinear Interpolation

Given any two points, there is one polynomial of order ≤ 1 that passes through the two points.

Quadratic Interpolation

Given any three points there is one polynomial of order ≤ 2 that passes through the three points.

Page 9: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 9

Linear InterpolationGiven any two points,

The line that interpolates the two points is:

Example :Find a polynomial that interpolates (1,2) and (2,4).

)(,,)(, 1100 xfxxfx

001

0101

)()()()( xxxx

xfxfxfxf

xxxf 2112242)(1

Page 10: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 10

Quadratic Interpolation Given any three points: The polynomial that interpolates the three points is:

)(, ,)(,,)(, 221100 xfxandxfxxfx

02

01

01

12

12

2102

01

01101

00

1020102

)()()()(

],,[

)()(],[

)(:

)(

xxxx

xfxfxx

xfxf

xxxfb

xxxfxfxxfb

xfbwhere

xxxxbxxbbxf

Page 11: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 11

General nth Order InterpolationGiven any n+1 points:The polynomial that interpolates all points is:

)(,..., ,)(,,)(, 1100 nn xfxxfxxfx

],...,,[....

],[)(

......)(

10

101

00

10102010

nn

nnn

xxxfb

xxfbxfb

xxxxbxxxxbxxbbxf

Page 12: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 12

Divided Differences

0

1102110

02

1021210

01

0110

],...,,[],...,,[],...,,[

............

DDorder Second],[],[],,[

DDorder First ][][],[

DDorder Zeroth )(][

xxxxxfxxxfxxxf

xxxxfxxfxxxf

xxxfxfxxf

xfxf

k

kkk

kk

Page 13: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 13

Divided Difference Table x F[ ] F[ , ] F[ , , ] F[ , , ,]

x0 F[x0] F[x0,x1] F[x0,x1,x2] F[x0,x1,x2,x3]x1 F[x1] F[x1,x2] F[x1,x2,x3]x2 F[x2] F[x2,x3]x3 F[x3]

n

i

i

jjin xxxxxFxf

0

1

010 ],...,,[)(

Page 14: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 14

Divided Difference Table f(xi)

0 -51 -3-1 -15

ixx F[ ] F[ , ] F[ , , ]0 -5 2 -41 -3 6-1 -15

Entries of the divided difference table are obtained from the data table using simple operations.

Page 15: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 15

Divided Difference Table

f(xi)

0 -51 -3-1 -15

ixx F[ ] F[ , ] F[ , , ]

0 -5 2 -41 -3 6-1 -15

The first two column of the table are the data columns.Third column: First order differences.Fourth column: Second order differences.

Page 16: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 16

Divided Difference Table

0 -51 -3-1 -15

iyixx F[ ] F[ , ] F[ , , ]0 -5 2 -41 -3 6-1 -15

201

)5(3

01

0110

][][],[xx

xfxfxxf

Page 17: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 17

Divided Difference Table

0 -51 -3-1 -15

iyixx F[ ] F[ , ] F[ , , ]0 -5 2 -41 -3 6-1 -15

611

)3(15

12

1221

][][],[xx

xfxfxxf

Page 18: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 18

Divided Difference Table

0 -51 -3-1 -15

iyixx F[ ] F[ , ] F[ , , ]0 -5 2 -41 -3 6-1 -15

4)0(1

)2(6

02

1021210

],[],[],,[xx

xxfxxfxxxf

Page 19: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 19

Divided Difference Table

0 -51 -3-1 -15

iyixx F[ ] F[ , ] F[ , , ]0 -5 2 -41 -3 6-1 -15

)1)(0(4)0(25)(2 xxxxf

f2(x)= F[x0]+F[x0,x1] (x-x0)+F[x0,x1,x2] (x-x0)(x-x1)

Page 20: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 20

Two Examples

x y1 02 33 8

Obtain the interpolating polynomials for the two examples:

x y2 31 03 8

What do you observe?

Page 21: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 21

Two Examples

1

)2)(1(1)1(30)(2

2

x

xxxxP

x Y1 0 3 12 3 53 8

x Y2 3 3 11 0 43 8

1

)1)(2(1)2(33)(2

2

x

xxxxP

Ordering the points should not affect the interpolating polynomial.

Page 22: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 22

Properties of Divided Difference

],,[],,[],,[ 012021210 xxxfxxxfxxxf

Ordering the points should not affect the divided difference:

Page 23: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 23

Example Find a polynomial to

interpolate the data.x f(x)

2 3

4 5

5 1

6 6

7 9

Page 24: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 24

Examplex f(x) f[ , ] f[ , , ] f[ , , , ] f[ , , , , ]2 3 1 -1.6667 1.5417 -0.67504 5 -4 4.5 -1.83335 1 5 -16 6 37 9

)6)(5)(4)(2(6750.0)5)(4)(2(5417.1)4)(2(6667.1)2(134

xxxxxxxxxxf

Page 25: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 25

Summary

.polynomial inginterpolat affect thenot should points theOrdering

methodsOther - 2] 18.[Section ion Interpolat Lagrange -

] 18.1[Section Difference DividedNewton - itobtain toused becan methodsDifferent *

unique. is Polynomial inginterpolat The * ..., ,2 ,1 ,0)()(:Condition ingInterpolat niforxfxf ini

Page 26: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 26

Lecture 21Lagrange Interpolation

Page 27: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 27

The Interpolation Problem Given a set of n+1 points:

Find an nth order polynomial: that passes through all points, such that:

)(,....,,)(,,)(, 1100 nn xfxxfxxfx

)(xfn

niforxfxf iin ,...,2,1,0)()(

Page 28: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 28

Lagrange InterpolationProblem: Given

Find the polynomial of least order such that:

Lagrange Interpolation Formula:

niforxfxf iin ,...,1,0)()( )(xfn

…. ….

1x nx

0y 1y nyix

iy

n

ijj ji

ji

n

iiin

xxxx

x

xxfxf

,0

0

)(

)()(

0x

Page 29: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 29

Lagrange Interpolation

jiji

x

x

ji

th

i

10

)(

:spolynomialorder n are cardinals The

cardinals. thecalled are)(

Page 30: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 30

Lagrange Interpolation Example x 1/3 1/4 1

y 2 -1 7

)4/1)(3/1(27

)1)(3/1(161)1)(4/1(182)(4/114/1

3/113/1)(

14/11

3/14/13/1)(

13/11

4/13/14/1)(

)()()()()()()(

2

12

1

02

02

21

2

01

01

20

2

10

10

2211002

xxxxxxxP

xxxxxx

xxxxx

xxxxxx

xxxxx

xxxxxx

xxxxx

xxfxxfxxfxP

Page 31: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 31

ExampleFind a polynomial to interpolate:

Both Newton’s interpolation method and Lagrange interpolation method must give the same answer.

x y

0 1

1 3

2 2

3 5

4 4

Page 32: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 32

Newton’s Interpolation Method0 1 2 -3/2 7/6 -5/8

1 3 -1 2 -4/3

2 2 3 -2

3 5 -1

4 4

Page 33: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 33

Interpolating Polynomial

)3)(2)(1(85

)2)(1(67)1(

23)(21)(4

xxxx

xxxxxxxf

Page 34: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 34

Interpolating Polynomial Using Lagrange Interpolation Method

343

242

141

040

434

232

131

030

424

323

121

020

414

313

212

010

404

303

202

101

4523)()(

4

3

2

1

0

43210

4

04

xxxx

xxxx

xxxx

xxxx

xxxx

xfxfi

ii

Page 35: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 35

Lecture 22Inverse Interpolation Error in Polynomial

Interpolation

Page 36: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 36

Inverse Interpolation

.)( :such that Find

. and tableGiven the :Problem

ggg

g

yxfx

y

…. ….

1xnx

0y 1y nyix

iy

One approach: Use polynomial interpolation to obtain fn(x) to interpolate the data then use Newton’s method to find a solution to:

ggn yxf )(

0x

Page 37: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 37

Inverse InterpolationAlternative Approach

….

….1x nx

0y 1y nyix

iyInverse interpolation: 1. Exchange the rolesof x and y.

2. Perform polynomial Interpolation on the new table. 3. Evaluate

)( gn yf

…. ….

iy 0y 1y ny

ix 0x 1x nx

0x

Page 38: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 38

Inverse Interpolation

x

y

y

x

Page 39: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 39

Inverse Interpolation

Question:

What is the limitation of inverse interpolation?

• The original function has an inverse.

• y1, y2, …, yn must be distinct.

Page 40: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 40

Inverse Interpolation Example

5.2)(such that Find table.Given the

:Problemgg xfx

x 1 2 3y 3.2 2.0 1.6

3.2 1 -.8333 1.04162.0 2 -2.51.6 3

2187.1)5.0)(7.0(0416.1)7.0(8333.01)5.2()2)(2.3(0416.1)2.3(8333.01)(

2

2

fyyyyf

Page 41: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 41

-5 -4 -3 -2 -1 0 1 2 3 4 5-0.5

0

0.5

1

1.5

2

true function

10 th order interpolating polynomial

10th Order Polynomial Interpolation

Page 42: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 42

Errors in polynomial Interpolation Polynomial interpolation may lead to large

errors (especially for high order polynomials). BE CAREFUL

When an nth order interpolating polynomial is used, the error is related to the (n+1)th order derivative.

Page 43: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 43

1

)1(1

)1(4

:Then points). end the(including b][a,in points spacedequally 1at esinterpolatthat

n degree of polynomialany beLet

. and b],[a,on continuous is

:such thatfunction a beLet

n

n)(n

nab

nMf(x)-P(x)

nfP(x)

Mf(x)f

f(x)

Errors in polynomial InterpolationTheorem

Page 44: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 44

Example 1

910

1

)1(

th

1034.19

6875.1)10(4

1

)1(4

9 ,1

01

.[0,1.6875] interval in the points) spacedequally 01 (using f(x) einterpolat topolynomialorder 9 use want toWe

sin

f(x)-P(x)

nab

nMf(x)-P(x)

nM

nforf

(x) f(x)

n

n

Page 45: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 45

Interpolation Error

n

iinn

n

n

xxxxxxfxff(x)

xxxxnf

010

10

],,...,,[)(

:node anot any for then ,,...,, nodes at the f(x)function the

esinterpolat that degree of polynomial theis (x) If

Not useful. Why?

Page 46: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 46

Approximation of the Interpolation Error

n

iinnn

nn

n

n

xxxxxxfxff(x)

xfxxxxf(x)

nf

0110

11

10

],,...,,[)(

:by edapproximat iserror ion interpolat The

point. additionalan be))(,(Let .,...,, nodes at the function the

esinterpolat that degree of polynomial theis (x) If

Page 47: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 47

Divided Difference Theorem

)(10

10)(

!1],...,,[

:b][a, somefor then b],[a,in pointsdistinct 1any are,...,, if and b],[a,on continuous is

nn

nn

fn

xxxf

nxxxfIf

10],...,,[:then

,order of polynomial a is )(

10 nixxxf

nxfIf

i

1 4 1 0 02 5 1 03 6 14 7

xxf 3)(

Page 48: CISE301 : Numerical Methods Topic 5: Interpolation Lectures 20-22:

CISE301_Topic5 KFUPM 48

Summary The interpolating polynomial is unique. Different methods can be used to obtain it.

Newton’s divided difference Lagrange interpolation Others

Polynomial interpolation can be sensitive to data.

BE CAREFUL when high order polynomials are used.


Recommended