Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed...

22
Chapter 4, Integration of Functions

Transcript of Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed...

Page 1: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Chapter 4, Integration of Functions

Page 2: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Open and Closed Formulas

x1=a x2 x3 x4 x5=b

1 1 2 2 3 3 4 4 5 5( ) b

a

f x dx w f w f w f w f w f

Closed formula uses end points, e.g.,

3 3( ) f x fOpen formulas - use interior points only.

Extended formulas – piecewise sum of integration formula.

Page 3: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Deriving Integration Formulas

A. Given N function values fi, i=1,2,…N, interpolate with the N−1 degree polynomial, and integrate the polynomial analytically.

B. Assuming a form Σwifi, determine the weights wj by requiring that all polynomials of degree N−1 or less integrate exactly.

Page 4: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Closed Newton-Cotes Formulas

• Equally spaced abscissas, xj=x1+(j-1)h

• Lagrange’s interpolation formula

• Integrating, gives

1

( ) ( ) ( )N

j jj

P x f l x f x

1

1

1

1

( ) ,

( )

N

N

x NN

j jjx

x

j j j

x

f x dx w f O h

w l x dx h

Where lj(x) is a polynomial of degree N-1 such that lj(xj) = 1 and lj(xk) = 0 if k ≠ j.

Page 5: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Special Cases, N=2,3,4 : the Integration Rules

• Trapezoidal rule

• Simpson’s rule

• 3/8 rule

3

1

5 (4)1 2 3

1 4 1( ) ( )

3 3 3

x

x

f x dx h f f f O h f

2

1

31 2

1 1( ) ( )

2 2

x

x

f x dx h f f O h f

4

1

5 (4)1 2 3 4

3 9 9 3( ) ( )

8 8 8 8

x

x

f x dx h f f f f O h f

linear interpolation

parabola

Page 6: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Open Formula in a Single Interval

• These formulas are useful to construct extended formulas with open interval

1

0

1

0

21

31 2

( ) ( ),

3 1( ) ( )

2 2

x

x

x

x

f x dx h f O h f

f x dx h f f O h f

Open formulas are useful for integrals where the end-point is singular, e.g.,

1

0

1 dxx

Page 7: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Extended Formulas

• Using trapezoidal rule in intervals [x1,x2], [x2,x3], [x3,x4], …, and [xN-1,xN ], we get

• Using Simpson’s rule in intervals [x1,x3], [x3,x5], etc, we get

x1 x2 x3 x4 … xN

1

31

1 2 3 1 2

( )1 1( )

2 2

Nx

NN N

x

x x ff x dx h f f f f f O

N

1

1 2 3 4 1 4

1 4 2 4 4 1 1( )

3 3 3 3 3 3

Nx

N N

x

f x dx h f f f f f f ON

Page 8: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Trapezoidal Routine

• Sequence of points used for each n

n = 1

n = 2

n = 3

n = 4

Subdivide the intervals and compute fi only at points that have not computed before.

n = …

Page 9: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Recursive Computation of Trapezoidal sum

• If n = 1 (two points, one interval)

• else if (n > 1)

1newpoints

1

1,

2

( ) / 2

n n n jj

nn

T T h f

h b a

1

1( ) ( ) ( )2

T b a f a f b

Page 10: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

trapzd( )

Page 11: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Romberg Integration

• Compute trapezoidal sum

for different values of h, e.g., h0, h0/2, h0/4, h0/8, etc.

• Extrapolate T(h) in polynomial of h2 to h → 0. The justification for this is due to the Euler-Maclaurin formula.

1 2 3 1

1 1( )

2 2N NT h h f f f f f

Page 12: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Euler-Maclaurin Summation Formula

1

1 2 3 1

22(2 1) (2 1)22

1 1

2 4

1 1( )

2 2

( )2! (2 )!

1 1, ,6 30

N

N N

x kk kk

N N

x

T h h f f f f f

B hB hf x dx f f f f

k

B B

The important point is that T(h) is in powers of h2.

Page 13: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

qromb( )

Page 14: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Theory of Gaussian Quadrature

• Find best wj and xj [integrate exactly for all polynomials f(x) up to degree 2N-1]:

where the weight function W(x) is assumed positive and continuous.

1

( ) ( ) ( )b N

j jja

f x W x dx w f x

Page 15: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Orthogonal Polynomials

• Two polynomials are said orthogonal with respect to a fixed weight function W(x) and fixed interval [a,b], if

is zero.

• One can construct orthogonal polynomial set {pj(x), j=0,1, 2, …}.

| ( ) ( ) ( )b

a

f g W x f x g x dx

Page 16: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Example of Orthogonal Polynomials

• With weight W(x) = 1 in interval [-1,1], the corresponding orthogonal polynomials are the Legendre polynomials:

2

0 1

22

1( ) 1 , 0,1,2,

2 !2

|2 1

( ) 1, ( ) ,

1( ) 3 1 ,

2

kk

k k k

i j ij

dP x x k

k dx

P Pj

P x P x x

P x x

Page 17: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Constructing Orthogonal Polynomials

• Start with the first one, P0(x)=1• Let P1(x)=c0+c1x, determine the coefficients

by requiring <P0|P1>=0, For weight W(x)=1 in interval [-1,1], this gives P1(x)=x

• Determine P2(x)= c0+c1x+c2x2 by requiring <P0|P2>=0, <P1|P2>=0

• In general

Pj+1(x) = (x-aj) Pj(x) – bj Pj-1(x)

Page 18: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Abscissas in Gaussian Quadrature

• For an N-point integration formula, choose the root of N-th orthogonal polynomial xj as the abscissas.

• Choose wj to satisfy

0

1

( ) ( ) , if 0,( ) ( ) ( )

0, if 0 .

bb N

i j i j aja

W x p x dx iW x p x dx w p x

i N

It turns out that the ‘integration equal to 0’ is true also for i up to 2N-1.

Page 19: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Gaussian integration formula is exact for all polynomials of degree

2N-1 • Let f(x) be any polynomial of degree 2N-1,

we can write

f(x) = q(x) PN(x) + r(x)

where r(x) and q(x) are degree N-1.

• Considering the left- and right-hand side of the integration formula with function f(x), show that they are equal.

Page 20: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Solution for the Weight wj

1 1

1

|

( ) ( )N N

jN j N j

p pw

p x p x

This formula assumes that the polynomials are normalized according to Eqs.(4.5.6) & (4.57), page 149 of NR.

Page 21: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Reading, References

• Read Chapter 4 of NR

• For an in-depth treatment of numerical methods, see, e.g., J. Stoer and R. Bulirsch, “Introduction to Numerical Analysis”.

• See also M. T. Heath, “Scientific Computing, an introductory survey”.

Page 22: Chapter 4, Integration of Functions. Open and Closed Formulas x 1 =a x 2 x 3 x 4 x 5 =b Closed formula uses end points, e.g., Open formulas - use interior.

Problems for Lecture 41. Prove the Euler-Maclaurin summation formula for the first three terms,

i.e.,

1

1 2 3 1

2 46

1 1

1 1[ ]

2 2

( ) ( )12 720

N

N N

x

N N

x

T h h f f f f f

h hf x dx f f f f O h

where h = (xN-x1)/(N-1). (Hint: Taylor expansion.)

2. Use the theory of Gaussian quadrature to find a 3-point integration formula for the weight W(x) = 1 and interval [0, 1]. That is, find the abscissas xj and weights wj such that the formula below is exact for all

polynomials of degree 5 or less. 1

1 1 2 2 3 3

0

( ) f x dx w f w f w f