Interpolation Used to estimate values between data points difference from regression - goes through...

22
Interpolation •Used to estimate values between data points •difference from regression - •goes through data points •no error in data points
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    235
  • download

    2

Transcript of Interpolation Used to estimate values between data points difference from regression - goes through...

Interpolation

•Used to estimate values between data points

•difference from regression -

•goes through data points

•no error in data points

Most common method is polynomial interpolation

nnxaxaxaaxf ...2

210

Given n+1 data points, a unique nth order polynomial fits them.

Polynomial interpolation determines a’s of this polynomial

A number of methods

Newton divided difference interpolating polynomials

Start with linear interpolation

9.6

9.65

9.7

9.75

9.8

9.85

9.9

9.95

10

10.05

11 12 13 14 15 16 17 18

9.6

9.65

9.7

9.75

9.8

9.85

9.9

9.95

10

10.05

11 12 13 14 15 16 17 18

x0 x x1

f(x0)

f1(x)

f(x1)

From similar triangles

01

01

0

01

xx

xfxf

xx

xfxf

Can rearrange to get linear interpolation formula

001

0101 xx

xx

xfxfxfxf

Example: Interpolate exp(2) using 1) exp(1) and exp(6) and 2) exp(1.5) and exp (2.5)

1) 86.8215

72.243.40372.212

16

1exp6exp1exp21

f

2) 33.85.0

1

48.418.1248.45.12

5.15.2

5.1exp5.2exp5.1exp21

f

39.7)2exp(

Quadratic interpolation - need three points

Use parabola 1020102 xxxxbxxbbxf

This is the same as 22102 xaxaaxf

with

22

120211

1020100

ba

xbxbba

xxbxbba

To get b’s

1) set x=x0 in quadratic 001002001002 xfbxxxxbxxbbxf

2) use b0 and x=x1 in quadratic

01

011

111012011012

xx

xfxfb

xfxxxxbxxbxfxf

3) use b0 and b1 and x=x2

02

01

01

12

12

2

2120220201

01022

xx

xx

xfxf

xx

xfxf

b

xfxxxxbxxxx

xfxfxfxf

b0 is a constant (0th order)

b1 gives slope (finite difference)

b2 give curvature (difference of finite differences)

Example: interpolate exp(2) using exp(1), exp(3) and exp(4)

60.54 4

09.20 3

72.2 1

22

11

00

xfx

xfx

xfx

61.8

68.8

72.2

2

1

0

b

b

b

79.23212*61.812*68.872.222 f

39.7)2exp(

Example: interpolate exp(2) using exp(1), exp(1.5) and exp(2.5)

18.12 5.2

48.4 5.1

72.2 1

22

11

00

xfx

xfx

xfx

78.2

53.3

72.2

2

1

0

b

b

b

63.75.1212*78.212*53.372.222 f

39.7)2exp(

General form for Newton’s interpolating polynomials

1210102010 ...... nnn xxxxxxxxbxxxxbxxbbxf

011

0122

011

00

,,...,,

,,

,

xxxxfb

xxxfb

xxfb

xfb

nnn

Bracketed functions are finite differences

First finite difference

ji

jiji xx

xfxfxxf

,

Second finite difference

ki

kjjikji xx

xxfxxfxxxf

,,,,

The difference of two finite differences

The nth finite difference

0

01111011

,,...,,...,,,,...,,

xx

xxxfxxxfxxxxf

n

nnnnn

An interative proceedure

1) make all first order finite differences; save f(x0) for b0

2) make second order from firsts; save f[x1,x0] for b1

3) continue to nth order, saving needed ones

Example: estimate exp(2) using 6 points - 0,1, 3, 4, 5, 6

43.403 6

41.148 5

60.54 4

09.20 3

72.2 1

1 0

25

24

23

22

11

00

xfx

xfx

xfx

xfx

xfx

xfx

51.34

1

09.2060.54,

68.82

72.209.20,

72.11

172.2,

23

2332

12

1221

101

0110

xx

xfxfxxf

xx

xfxfxxf

bxx

xfxfxxf

02.255

1

42.14843.403,

81.931

60.5442.148,

45

4554

34

3443

xx

xfxfxxf

xx

xfxfxxf

Do first differences, get b1

100 xfb

Use firsts to get seconds and save b2

60.80

46

82.9302.255,,,,

65.2935

51.3482.93,,,,

61.814

68.851.34,,,,

32.203

72.168.8,,,,

02

1021210

02

1021210

02

1021210

202

1021210

xx

xxfxxfxxxf

xx

xxfxxfxxxf

xx

xxfxxfxxxf

bxx

xxfxxfxxxf

Use seconds to get thirds and get b3

98.16

36

65.2960.80,,,,,,,

26.515

61.865.29,,,,,,,

57.104

32.261.8,,,,,,,

25

4325435432

14

3214324321

303

2103213210

xx

xxxfxxxfxxxxf

xx

xxxfxxxfxxxxf

bxx

xxxfxxxfxxxxf

Use thirds to get fourths and b4

34.2

16

26.598.16,,,,,,,,,,

73.005

57.126.5,,,,,,,,,,

15

4321543254321

404

3210432143210

xx

xxxxfxxxxfxxxxxf

bxx

xxxxfxxxxfxxxxxf

Use fourths to get the fifth finite difference and b5

5

05

4321054321543210 27.0

06

73.034.2,,,,,,,,,,,,, b

xx

xxxxxfxxxxxfxxxxxxf

So

432105

32104

21031020105

xxxxxxxxxxb

xxxxxxxxb

xxxxxxbxxxxbxxbbxf

0

50

100

150

200

250

300

350

400

450

0 1 2 3 4 5 6 7

exp(x)

interp

-4

1

6

11

16

21

1 1.5 2 2.5 3

exp(x)

interp

Blow up

67.525 f

Error for Newton’s polynomial

- estimate from

nnnnn xxxxxxxxxxfR ...,...,,, 10011

Thinking of interpolation like a Taylor series

Example: use exp(2.5)=12.18

Calculate 04.0,...,,, 011 xxxxf nnn

82.162*52*42*32*)12(*02*04.0

72.167.52exp

Matlab code

Excel code