07 interpolation

Post on 17-Jun-2015

2.380 views 1 download

Tags:

Transcript of 07 interpolation

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Interpolation/Curve Fitting

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Objectives

• Understanding the difference between regression and interpolation

• Knowing how to “best fit” a polynomial into a set of data

• Knowing how to use a polynomial to interpolate data

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Measured Data

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Polynomial Fit!

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Line Fit!

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Which is better?

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Curve Fitting

• If the data measured is of high accuracy and it is required to estimate the values of the function between the given points, then, polynomial interpolation is the best choice.

• If the measurements are expected to be of low accuracy, or the number of measured points is too large, regression would be the best choice.

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Interpolation

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Why Interpolation?

• When the accuracy of your measurements are ensured

• When you have discrete values for a function (numerical solutions, digital systems, etc …)

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Acquired Data

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

But, how to get the equation of a function that passes by all the

data you have!

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Equation of a Line: Revision

xaay 21 If you have two points

1211 xaay

2212 xaay

2

1

2

1

2

1

1

1

y

y

a

a

x

x

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Solving for the constants!

12

122

12

21121 &

xx

yya

xx

yxyxa

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

What if I have more than two points?

• We may fit a polynomial of order one less that the number of points we have. i.e. four points give third order polynomial.

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Third-Order Polynomial

34

2321 xaxaxaay

For the four points

314

2131211 xaxaxaay

324

2232212 xaxaxaay

334

2333213 xaxaxaay

344

2434214 xaxaxaay

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

In Matrix Form

4

3

2

1

4

3

2

1

34

224

33

223

32

222

31

211

1

1

1

1

y

y

y

y

a

a

a

a

xxx

xxx

xxx

xxx

Solve the above equation for the constants of the polynomial.

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Newton's Interpolation Polynomial

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Newton’s Method

• In the previous procedure, we needed to solve a system of linear equations for the unknown constants.

• This method suggests that we may just proceed with the values of x & y we have to get the constants without setting a set of equations

• The method is similar to Taylor’s expansion without differentiation!

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Equation of a Line: Revision

xaay 21 If you have two points

1211 xaay

2212 xaay

2

1

2

1

2

1

1

1

y

y

a

a

x

x

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

For the two points

12

12

1

1

xx

yy

xx

yy

12

12

1

1

xx

yy

xx

yxf

112

121 xx

xx

yyyxf

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

For the three points

213

121

xxxxa

xxaaxf

11 ya

12

122 xx

yya

13

12

12

23

23

3 xx

xxyy

xxyy

a

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Using a table

xiyi

x1y1

x2y2

x3y3

13

12

12

23

23

xx

xxyy

xx

yy

12

12

xx

yy

23

23

xx

yy

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

In General

• Newton’s Interpolation is performed for an nth order polynomial as follows

nn xxxxa

xxxxaxxaaxf

...... 11

213121

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Example

• Find a 3rd order polynomial to interpolate the function described by the given points

xY

-11

02

15

216

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Solution: System of equations

• A third order polynomial is given by:

34

2321 xaxaxaaxf

11 4321 aaaaf

20 1 af

51 4321 aaaaf

168422 4321 aaaaf

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

In matrix form

16

5

2

1

8421

1111

0001

1111

4

3

2

1

a

a

a

a

1

1

1

2

4

3

2

1

a

a

a

a

322 xxxxf

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Newton’s Method

• Newton’s methods defines the polynomial in the form:

3214

213121

xxxxxxa

xxxxaxxaaxf

11

11

4

321

xxxa

xxaxaaxf

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Newton’s Method

xY

-11111

0234

1511

216

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Newton’s Method

• Finally:

11

111

xxx

xxxxf

xxxxxxf 3211

322 xxxxf

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Advantage of Newton’s Method

• The main advantage of Newton’s method is that you do not need to invert a matrix!

ENEM602 Spring 2007

Dr. Eng. Mohammad Tawfik

Homework #6

• Chapter 18, pp. 505-506, numbers:18.1, 18.2, 18.3, 18.5.