numerical integration continued --- simpson’s rules - we can add more segments or - we can use a...

21
Numerical integration continued --- Simpson’s rules - We can add more segments OR - We can use a higher order polynomial 0 2 4 6 8 10 12 3 5 7 9 11 13 15

Post on 21-Dec-2015

215 views

Category:

Documents


1 download

TRANSCRIPT

Numerical integration continued ---

Simpson’s rules

- We can add more segments OR

- We can use a higher order polynomial

0

2

4

6

8

10

12

3 5 7 9 11 13 15

Simpson’s 1/3 rule

• use a second order interpolating polynomial

2

0

2

02

x

x

x

xdxxfdxxfI

If we use Lagrange form

dxxf

xxxx

xxxx

xfxxxx

xxxxxf

xxxx

xxxxI

x

x

21202

10

12101

200

2010

212

0

2

201

xxx

Integrate and do some algebra

210 43

xfxfxfh

I

0

2

4

6

8

10

12

3 5 7 9 11 13 15

If we use a=x0 and b=x2, and x1=(b+a)/2

6

4 210 xfxfxfabI

width Average height

Error for Simpson’s 1/3 rule

45

2880f

abE t

As with Trapezoidal rule, can use multiple applications of Simpson’s 1/3 rule

• need even number of segments, odd number of points

-5

0

5

10

15

20

25

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5

9 points, 4 segments

n

xfxfxfxf

abIn

n

i

n

jji

3

241

5,3,1

2

6,4,20

As in multiple trapzoid, break integral up

n

n

x

x

x

x

x

xdxxfdxxfdxxfI

2

4

2

2

0

...

Substitute Simpson’s 1/3 rule for each integral and collect terms

Example: Numerically integrate from 0 to 1 using 1) single trapezoid, 2) multiple trapezoid, 3) single Simpson’s 1/3 and 4) multiple Simpson’s 1/3x y

0 -6.8700.125 1.2530.25 2.0540.375 0.6540.5 -0.167

0.625 0.4040.75 1.5720.875 1.301

1 -3.314 -8

-7

-6

-5

-4

-3

-2

-1

0

1

2

3

0 0.2 0.4 0.6 0.8 1 1.2

-8

-6

-4

-2

0

2

4

0 0.2 0.4 0.6 0.8 1 1.2

True, analytic value of I is 0.4749

09.52

31.387.601

2

bfafabI

Really quite bad

%172,14749.0

09.54749.0

tE

1) Single trapezoidal rule

-8

-6

-4

-2

0

2

4

0 0.2 0.4 0.6 0.8 1 1.2

2) Multiple trapezoidal rule

081.0

1875.075.0...25.0125.0202

25.0

22

1

1

ffffff

bfihafafh

In

i

-8

-6

-4

-2

0

2

4

0 0.2 0.4 0.6 0.8 1 1.2%834749.0

081.04749.0

tE

-8

-6

-4

-2

0

2

4

0 0.2 0.4 0.6 0.8 1 1.2

81.1

15.0403

5.0

43 210

fff

xfxfxfh

I

3) Single Simpson’s 1/3 rule

%4814749.0

081.04749.0

tE

-8

-6

-4

-2

0

2

4

0 0.2 0.4 0.6 0.8 1 1.2

4) Multiple Simpson’s 1/3 rule

n

xfxfxfxf

abIn

n

i

n

jji

3

241

5,3,1

2

6,4,20

4659.08*3

175.05.025.0*2875.0625.0375.0125.0*4001

3

241

5,3,1

2

6,4,20

fffffffffn

xfxfxfxf

abIn

n

i

n

jji

%24749.0

4650.04749.0

tE

Simpson’s 1/3 rule is limited to

• applications with equally-spaced data

• even number of segments

• odd number of points

Simpson’s 3/8 rule used when there are

• odd number of segments

• even number of points

Simpson’s 3/8 rule uses a third order Lagrange polynomial

b

a

b

adxxfdxxfI 3

Four equally spaced points, separated by

3210 338

3xfxfxxfhI

3

abh

or

8

33 3210 xfxfxfxfabI

Can do multiple segment application of Simpson’s 3/8 rule.

Can also mix and match Simpson’s 1/3 and 3/8 to fill up segments

Example:

-15

-10

-5

0

5

10

15

20

25

30

35

0 2 4 6 8 10 12 14

x y1 3.6832 5.5173 1.2224 -5.035 -9.546 -9.577 -3.848 7.0319 20.0210 29.2311 25.3712 -4.64

12 points, 11 segmentsEach 3/8 rule application takes 3 segmentsEach 1/3 rule application takes 2 segments

Neither 2 nor 3 go into 11

But 3 3’s and a 2 do.

-15

-10

-5

0

5

10

15

20

25

30

35

0 2 4 6 8 10 12 14

1/3 rule

3/8 rule

3/8 rule

3/8 rule

17.648

33

8

338

33

6

4

111098811

876558

543225

21002

2

0

11

8

8

5

5

2

xfxfxfxfxx

xfxfxfxfxx

xfxfxfxfxx

xfxfxfxx

dxxfdxxfdxxfdxxfIx

x

x

x

x

x

x

x

Higher order Newton-Cotes closed formulas

Simpson’s 1/3 - 2nd order Lagrange

Simpson’s 3/8 - 3rd order Lagrange

we can keep going

but don’t usually - Simpson is accurate enough when applied in multiple segments

Integration with unequal segments

If all unequal, stuck with multiple trapezoid rule application

If you can find some sets of equal segments, use Simpson’s rules