Top Banner
Computers in Civil Computers in Civil Engineering Engineering 53:081 Spring 2003 53:081 Spring 2003 Lecture #14 Lecture #14 Interpolation Interpolation
23

Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Jan 20, 2016

Download

Documents

Corey Small
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Computers in Civil Computers in Civil EngineeringEngineering

53:081 Spring 200353:081 Spring 2003

Lecture #14Lecture #14

InterpolationInterpolation

Page 2: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Interpolation: OverviewInterpolation: Overview Objective: estimate intermediate values

between precise data points using simple functions

Solutions– Newton Polynomials– Lagrange Polynomials– Spline Interpolation

Interpolation Curve Fitting

x

y

multiple values

Curve need not go through data

points

x

y

single value

Curve goes through data

points

Page 3: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

?)( ixy

?)( xf

xix

y

High-precision data points

ExampleExample

Page 4: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

BraidwoodBraidwoodLaSalleLaSalle

DresdenDresden

QuadQuadCitiesCities

Page 5: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Jain's TMC-1

y = -5.594406E-18x4 - 1.100233E-13x3 + 3.470629E-08x2 - 1.251748E-03x + 1.691667E+01R2 = 0.9999

0

1

2

3

4

5

6

7

8

9

0 5000 10000 15000 20000 25000 30000 35000

Miss. R. Discharge (cfs)

Del

ta T

(deg

F)

DT

Poly. (DT)

Poly. (DT)

Quad-Cities Nuke Station Diffuser CurveQuad-Cities Nuke Station Diffuser Curve

Page 6: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Examples of Simple Examples of Simple PolynomialsPolynomials

Fist-order (linear) Second-order (quadratic) Third-order (cubic)

Page 7: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Newton’s Divided-Difference Newton’s Divided-Difference Interpolating PolynomialsInterpolating Polynomials

General comments Linear Interpolation Quadratic Interpolation General Form

Page 8: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Linear Interpolation Linear Interpolation FormulaFormula

)( 1xf

)(1 xf

)( 0xf

0x x 1x

01

01

0

01 )()()()(

xx

xfxf

xx

xfxf

)()(

)()()(

)()(

00

001

0101

xxmxf

xxxx

xfxfxfxf

By similar triangles:

Rearrange:

)(1 xfThe notation: means the first order interpolating polynomial

Page 9: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Estimate ln(2) (the true value is 0.69)

We know that: at x = 1 ln(x) =0 at x = e ln(x) =1 (e=2.718...)

Thus,

ExampleExampleProblem:

Solution:

58.0)12(1178.2

010

)12(1

)1()()1(

)()()(

)()( 001

0101

e

feff

xxxx

xfxfxfxf

Page 10: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

General form:

Equivalent form:

To solve for ,three points are needed:

22102 )( xaxaaxf

))(()()( 1020102 xxxxbxxbbxf

Quadratic InterpolationQuadratic Interpolation

))(,(),(,()),(,( 221100 xfxxfxxfx

210 ,, bbb and

(f2(x) means second-order interpolating polynomial)

Page 11: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

02

01

01

12

12

2

)()()()(

xx

xx

xfxf

xx

xfxf

b

01

011

)()(

xx

xfxfb

(1) ))(()()( 1020102 xxxxbxxbbxf

)( 00 xfb Set in (1) to find0xx

0bSubstitute in (1) and evaluate at to find:1xx

10 ,bbSubstitute in (1) and evaluate at to find:2xx

Quadratic InterpolationQuadratic Interpolation

Note: this looksNote: this lookslike a second like a second derivative…derivative…

Page 12: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

ExampleExample

Estimate ln(2) (the true value is 0.69)

We know that: at x = x0 = 1 ln(x) =0 at x = x1 = e ln(x) =1 (e=2.718...) at x = x2 = e2 ln(x) = 2

ProblemSolution

05.0

)()()()(

02

01

01

12

12

2

xx

xx

xfxf

xx

xfxf

b

58.017183.2

01

1

)1ln()ln(1

e

eb0)1ln()( 00 xfb

62.0))(()()2( 1020102 xxxxbxxbbf

Page 13: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

How to Generalize This?How to Generalize This?

It would get pretty tedious to do this for third, fourth, fifth, sixth, etc order polynominal

We need a plan:Newton’s Interpolating Polynomials

Page 14: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

)())(()()( 110010 nnn xxxxxxbxxbbxf

To solve for , n+1 points are needed:

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

nbbb ,, 10

Solution

],,,,[

],,[

],[

)(

011

0122

011

00

xxxxfb

xxxfb

xxfb

xfb

nnn

General form of Newton’s General form of Newton’s Interpolating PolynomialsInterpolating Polynomials

What does this [ ] notation mean?

Page 15: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

First finite divided difference:

nth finite divided difference:

Finite Divided DifferencesFinite Divided Differences

ji

jiji xx

xfxfxxf

)()(],[

ki

kjjikji xx

xxfxxfxxxf

],[],[

],,[

0

02111011

],,,[],,,[],,,,[

xx

xxxfxxxfxxxxf

n

nnnnnn

Second finite divided difference:

],,,[)())((

],,[))((],[)()(

01110

012100100

xxxfxxxxxx

xxxfxxxxxxfxxbxf

nnn

n

Page 16: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

)(3

],[)(2

],,[],[)(1

],,,[],,[],[)(0

thirdsecondfirst)(

33

2322

1231211

01230120100

xfx

xxfxfx

xxxfxxfxfx

xxxxfxxxfxxfxfx

xfxi ii

],,,[)())((

],,[))((],[)()(

01110

012100100

xxxfxxxxxx

xxxfxxxxxxfxxbxf

nnn

n

Finite divided difference table, case n = 3:

3210 ,,, bbbb

Finite Divided DifferencesFinite Divided Differences

Page 17: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Divided Differences Pseudo CodeDivided Differences Pseudo Code

do i=0,n-1 fdd(i,1)=f(i) enddo do j=2,n do i=1,n-j+1 fdd(i,j)=(fdd(i+1,j-1)-fdd(i,j-1))/& (x(i+j-1)-x(i)) enddo enddo

)(3

],[)(2

],,[],[)(1

],,,[],,[],[)(0

thirdsecondfirst)(

33

2322

1231211

01230120100

xfx

xxfxfx

xxxfxxfxfx

xxxxfxxxfxxfxfx

xfxi ii

3210 ,,, bbbb

Page 18: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Example – ln(2) againExample – ln(2) again

)(3

],[)(2

],,[],[)(1

],,,[],,[],[)(0

thirdsecondfirst)(

33

2322

1231211

01230120100

xfx

xxfxfx

xxxfxxfxfx

xxxxfxxxfxxfxfx

xfxi ii

6094.153

1823.07918.162

0204.02027.03863.141

0079.00518.04621.0010

thirdsecondfirst)(

ii xfxi

4621.014

)1ln()4ln(],[ 01

xxf

0079.015

)0518.0(204.0],,,[ 0123

xxxxf

3210 ,,, bbbb

Page 19: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

],,,[))()((

],,[))((

],[)()(

0123210

01210

0100

xxxxfxxxxxx

xxxfxxxx

xxfxxbxfn

6094.153

1823.07918.162

0204.02027.03863.141

0079.00518.04621.0010

thirdsecondfirst)(

ii xfxi

)6)(4)(1(0079.0)4)(1(0518.0)1(4621.0)( xxxxxxxfn

6289.0

)62)(42)(12(0079.0)42)(12(0518.0)12(4621.0)2(

nf

Page 20: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Newton Interpolation Pseudo CodeNewton Interpolation Pseudo Code

See the textbook!

Page 21: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Features of Newton Divided-Features of Newton Divided-Differences to get Interpolating Differences to get Interpolating

PolynomialPolynomial Data need not be equally spaced Arrangement of data does not have to be

ascending or descending, but it does influence error of interpolation

Best case is when the base points are close to the unknown value

Estimate of relative error:

)()(1 xfxfR nnn

Error estimate for Error estimate for nnth-order polynomial is the difference th-order polynomial is the difference between the (between the (nn+1)th and +1)th and nnth-order prediction.th-order prediction.

Page 22: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Relative Error As a Function of Relative Error As a Function of OrderOrder

0.5

50

-0.5

Order

Estimated error

Estimated error (reversed)

True Error

Error Example 18.5 in text

x f(x)=ln(x) 1 4 6 5 3 1.5 2.5 3.5

0 1.3863 1.7918 1.6094 1.0986 0.4055 0.9163 1.2528

Determine ln(2) using the following table

MATLAB function interp1 is very MATLAB function interp1 is very useful for thisuseful for this

Page 23: Computers in Civil Engineering 53:081 Spring 2003 Lecture #14 Interpolation.

Tuesday 15 AprilTuesday 15 April

Midterm 2Midterm 2