52
Newton-Cotes Formulas Newton-Cotes Formulas Newton-Cotes Newton-Cotes 2 Trapezoidal Rule Trapezoidal Rule 2 Simpson’s 1/3 rule Simpson’s 1/3 rule 2 Simpson’s 1/3 rule 3 Simpson’s 3/8 rule Composite Rules Euler-McClaurin Romberg Integration Improper Integrals Gram-Schmidt orthogonalization Gaussian Quadrature Gauss-Legendre- Laguerre Paul Lim Numerical Integration: Part 1 – 1 / 52

Integration 1

Embed Size (px)

Citation preview

Page 1: Integration 1

Newton-Cotes Formulas

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 1 / 52

Page 2: Integration 1

Newton-Cotes Formulas

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 2 / 52

Consider

I DZ b

a

f .x/ dx: (1)

We seek a quadrature formula ofthe form

I �n

X

iD1

Wi fi ;

where xi are the evaluation points,fi D f .xi /, Wi is the weightgiven the i -th point. We assumeequally spaced evaluation pointsseparated by a distance h D .b �a/=.n � 1/.

Next we approximate f .x/ by apolynomial of degree n � 1 that in-tersects all the nodes. Lagrange’sform of this polynomial is

Pn�1.x/ Dn

X

iD1

f .xi /li;n.x/:

Page 3: Integration 1

Newton-Cotes Formulas 2

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 3 / 52

Therefore, an approximation to the integral in Eq. (1) is

I DZ b

a

Pn�1.x/ dx Dn

X

iD1

"

f .xi /

Z b

a

li;n.x/ dx

#

Dn

X

iD1

Wif .xi /; (2)

where

Wi DZ b

a

li;n.x/ dx; i D 1; 2; : : : ; n: (3)

Eq. (2) are the Newton-Cotes formulas. Classical examples ofthese formulas are the trapezoidal rule (n D 2), Simpson’s rule(n D 3) and Simpson’s 3/8 rule (n D 4).

Page 4: Integration 1

Trapezoidal Rule

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 4 / 52

Page 5: Integration 1

Trapezoidal Rule 2

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 5 / 52

If n D 2 , we have l1;2 D .x � x2/=.x1 � x2/ D �.x � b/=h.Therefore,

W1 D �1

h

Z b

a

.x � b/ dx D 1

2h.b � a/2 D h

2:

Also l2;2 D .x � x1/=.x2 � x1/ D .x � a/=h, so that

W2 D 1

h

Z b

a

.x � a/ dx D 1

2h.b � a/2 D h

2:

Thus,

I D Œf .a/ C f .b/�h

2:

Page 6: Integration 1

Simpson’s 1/3 rule

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 6 / 52

Page 7: Integration 1

Simpson’s 1/3 rule 2

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 7 / 52

Simpson’s 1/3 rule can be obtained from Newton-Cotes formulaswith n D 3; assume the three points are at x1 D a,x2 D .a C b/=2 and x3 D b, with h D .b � a/=2. Lagrange’sthree-point interpolation are

l1;3.x/ D .x � x2/.x � x3/

.x1 � x2/.x1 � x3/l2;3.x/ D .x � x1/.x � x3/

.x2 � x1/.x2 � x3/

l3;3.x/ D .x � x1/.x � x2/

.x3 � x1/.x3 � x2/

Introducing the variable � with origin at x2, the coordinates of thenodes are �1 D �h, �2 D 0, �3 D h, and Eq. (3) becomes

Wi DZ b

a

li;n.x/ dx DZ h

�h

li;n.�/ d�:

Page 8: Integration 1

Simpson’s 1/3 rule 3

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 8 / 52

Therefore,

W1 DZ h

�h

.� � 0/.� � h/

.�h/.�2h/d� D 1

2h2

Z h

�h

.�2 � h�/ d� D h

3

W2 DZ h

�h

.� C h/.� � h/

.h/.�h/d� D � 1

h2

Z h

�h

.�2 � h2/ d� D 4h

3

W3 DZ h

�h

.� C h/.� � 0/

.2h/.h/d� D 1

2h2

Z h

�h

.�2 C h�/ d� D h

3

Thus

I D3

X

iD1

Wif .xi / D�

f .a/ C 4f

a C b

2

C f .b/

h

3:

Page 9: Integration 1

Simpson’s 3/8 rule

Newton-CotesFormulas

❖ Newton-Cotes

❖ Newton-Cotes 2

❖ Trapezoidal Rule

❖ Trapezoidal Rule 2

❖ Simpson’s 1/3 rule

❖ Simpson’s 1/3 rule 2

❖ Simpson’s 1/3 rule 3

❖ Simpson’s 3/8 rule

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 9 / 52

Simpson’s 3/8th rule (with n D 4) is given by

Z x4

x1

f .x/dx D4

X

iD1

Wif .xi /

D 3h

8Œf .x1/ C 3f .x2/ C 3f .x3/ C f .x4/�

Page 10: Integration 1

Composite Rules

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 10 / 52

Page 11: Integration 1

Composite Trapezoidal Rule

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 11 / 52

In practice the trapezoidal rule is applied in a piecewise fashion. Theregion .a; b/ is divided into n � 1 panels, each of width h. Theapproximate area of a typical i th panel

Ii D Œf .xi / C f .xiC1/�h

2:

Hence total area is

I Dn�1X

iD1

Ii D Œf .x1/C2f .x2/C2f .x3/C� � �C2f .xn�1/Cf .xn/�h

2: (4)

Page 12: Integration 1

MatLab Code: Composite TR

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 12 / 52

function trapez()

%trapez(a, b, n) approximates the integral of a function f(x)%in the interval [a;b], by the composite trapezoidal rule

a=1; b=4; %limits of integration.n=10; %n is the number of subintervals

h = (b-a)/n;

sum = 0;for i = 1:n-1

x(i) = a + i*h;sum = sum + f(x(i));

end

integral = h*(f(a) + 2*sum + f(b))/2

function y = f(x)y = 2 + sin(2*sqrt(x));

Page 13: Integration 1

Recursive Trapezoidal Rule

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 13 / 52

Let Ik be the integral evaluated with the composite trapezoidal ruleusing 2k�1 panels. Note that if k is increased by one, the numberof panels is doubled. Using the notation H D b � a, we obtainfrom Eq. (4), the following results for k D 1, 2 and 3.

k D 1 (1 panel):

I1 D Œf .a/ C f .b/�H

2

k D 2 (2 panels):

I2 D�

f .a/ C 2f

a C H

2

C f .b/

H

4

D 1

2I1 C f

a C H

2

H

2

Page 14: Integration 1

Recursive Trapezoidal Rule 2

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 14 / 52

k D 3 (4 panels):

I3 D�

f .a/ C 2f

a C H

4

C 2f

a C H

2

C 2f

a C 3H

4

C f .b/

H

8

D 1

2I2 C

f

a C H

4

C f

a C 3H

4

��

H

4

For arbitrary k > 1, we have

Ik D 1

2Ik�1 C H

2k�1

2k�2X

iD1

f

a C .2i � 1/H

2k�1

; k D 2; 3; : : :

which is the recursive trapezoidal rule. The summation containsonly the new nodes that were created when the number of panelswas doubled. It allows us to monitor convergence and terminatethe process when the difference between Ik�1 and Ik becomessufficiently small.

Page 15: Integration 1

MatLab Code: RT Rule

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 15 / 52

function Ih = trapezoid(func,a,b,I2h,k)% Recursive trapezoidal rule.% USAGE: Ih = trapezoid(func,a,b,I2h,k)% func = handle of function being integrated.% a,b = limits of integration.% I2h = integral with 2^(k-2) panels.% Ih = inegral with 2^(k-1) panels.

if k == 1fa = feval(func,a); fb = feval(func,b);Ih = (fa + fb)*(b - a)/2.0;

elsen = 2^(k -2 ); % Number of new pointsh = (b - a)/n/2 ;x = a + h; % Coord. of 1st new pointsum = 0.0;for i = 1:n

fx = feval(func,x);sum = sum + fx;x = x + 2*h;

endIh = I2h/2 + h*sum;

end

Page 16: Integration 1

Composite Simpson’s 1/3 rule

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 16 / 52

For two adjacent panels, we have

Z xiC2

xi

f .x/ dx � Œf .xi / C 4f .xiC1/ C f .xiC2/�h

3:

Thus,Z b

a

f .x/ dx D

Z xn

x1

f .x/ dx D

n�2X

iD1;3;:::

"

Z xiC2

xi

f .x/ dx

#

;

Z b

a

f .x/ dx � I D Œf .x1/ C 4f .x2/ C 2f .x3/ C 4f .x4/ C � � �

C2f .xn�2/ C 4f .xn�1/ C f .xn/�h

3:

Page 17: Integration 1

MatLab Code: Composite SR

Newton-CotesFormulas

Composite Rules

❖ Trapezoidal

❖ Matlab Code

❖ Recursive

❖ Recursive 2

❖ Matlab Code

❖ Simpson 1/3

❖ Matlab Code

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 17 / 52

function simps()

%approximates the integral of a function f(x) in the%interval [a;b] by the composite simpson rulea=1; b=4; %limits of integration.n=10; %n is the EVEN number of subintervals

%%%%%%%%%%%%%%%%%%%%%%%%%%%h = (b-a)/n;sum_odd = 0;for i = 1:n/2-1

x(i) = a + 2*i*h;sum_odd = sum_odd + f(x(i));

endsum_even = 0;for i = 1:n/2

x(i) = a + (2*i-1)*h;sum_even = sum_even + f(x(i));

endintegral = h*(f(a)+ 2*sum_odd + 4*sum_even +f(b))/3

function y = f(x)y = 2 + sin(2*sqrt(x));

Page 18: Integration 1

Euler-McClaurin

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

❖ Euler-McClaurin

❖ Euler-McClaurin 2

❖ Euler-McClaurin 3

❖ Euler-McClaurin 4

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 18 / 52

Page 19: Integration 1

Euler-McClaurin

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

❖ Euler-McClaurin

❖ Euler-McClaurin 2

❖ Euler-McClaurin 3

❖ Euler-McClaurin 4

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 19 / 52

Consider the integral of Eq. (1), and expand the function f .x/ in a Taylorseries about x D a:

Z b

a

f .x/ dx D

Z b

a

f .a/ C .x � a/f 0.a/ C.x � a/2

2Šf 00.a/

C.x � a/3

3Šf 000.a/ C

.x � a/4

4Šf Œ4�.a/ C � � �

dx

D hf .a/ Ch2

2Šf 0.a/ C

h3

3Šf 00.a/ C

h4

4Šf 000.a/

Ch5

5Šf Œ4�.a/ C � � � :

Expanding about x D b, we obtain

Z b

a

f .x/ dx D

Z b

a

f .b/ C .x � b/f 0.b/ C.x � b/2

2Šf 00.b/

C.x � b/3

3Šf 000.b/ C

.x � b/4

4Šf Œ4�.b/ C � � �

dx

D hf .b/ �h2

2Šf 0.b/ C

h3

3Šf 00.b/ �

h4

4Šf 000.b/

Ch5

5Šf Œ4�.b/ C � � � :

Page 20: Integration 1

Euler-McClaurin 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

❖ Euler-McClaurin

❖ Euler-McClaurin 2

❖ Euler-McClaurin 3

❖ Euler-McClaurin 4

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 20 / 52

Adding these two equations, we have

Z b

a

f .x/ dx D h

2Œf .a/ C f .b/� C h2

4

f 0.a/ � f 0.b/�

C h3

12

f 00.a/ C f 00.b/�

C h4

48

f 000.a/ � f 000.b/�

C h5

240

h

f Œ4�.a/ C f Œ4�.b/i

C � � � : (5)

Making a Taylor series expansion of f 0.x/ about the point x D a, wehave

f 0.x/ D f 0.a/C.x�a/f 00.a/C .x � a/2

2f 000.a/C .x � a/3

6f Œ4�.a/C� � �

In particular, at x D b,

f 0.b/ D f 0.a/ C hf 00.a/ C h2

2f 000.a/ C h3

6f Œ4�.a/ C � � �

Page 21: Integration 1

Euler-McClaurin 3

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

❖ Euler-McClaurin

❖ Euler-McClaurin 2

❖ Euler-McClaurin 3

❖ Euler-McClaurin 4

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 21 / 52

And of course, we could have expanded about x D b, and havefound

f 0.a/ D f 0.b/ � hf 00.b/ C h2

2f 000.b/ � h3

6f Œ4�.b/ C � � �

These expressions can be combined to yield

f 00.a/ C f 00.b/ D 2

h

f 0.b/ � f 0.a/�

� h

2

f 000.a/ � f 000.b/�

�h2

6

h

f Œ4�.a/ C f Œ4�.b/i

C � � � :

(6)

We could also expand the f 000.x/ about x D a and x D b to find

f Œ4�.a/ C f Œ4�.b/ D 2

h

f 000.b/ � f 000.a/�

C � � � : (7)

Page 22: Integration 1

Euler-McClaurin 4

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

❖ Euler-McClaurin

❖ Euler-McClaurin 2

❖ Euler-McClaurin 3

❖ Euler-McClaurin 4

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 22 / 52

Using Eqs. (6) and (7), the even-order derivatives can now be eliminatedfrom Eq. (5), so that we have

Z b

a

f .x/ dx D h

2Œf .a/ C f .b/� C h2

12

f 0.a/ � f 0.b/�

� h4

720

f 000.a/ � f 000.b/�

C � � � :

(8)

A new composite formula can now be developed by dividing theintegration region from a to b into many smaller segments, and applyingEq. (8) to each of these segments.

)

Z xN

x0

f .x/ dx D h.f0=2 C f1 C f2 C � � � C fN �1 C fN =2/C

h2

12Œf 0

0 � f 0N � � h4

720Œf 000

0 � f 000N � C � � � :

This is the Euler-McClaurin integration rule. It is the trapezoid rule,Eq. (4), with correction terms.

Page 23: Integration 1

Romberg Integration

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

❖ RombergR

❖ RombergR

2

❖ Matlab Code

❖ Example

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 23 / 52

Page 24: Integration 1

Romberg Integration: Trapezoid + Richardson

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

❖ RombergR

❖ RombergR

2

❖ Matlab Code

❖ Example

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 24 / 52

Denote the result obtained from the trapezoid rule with n D 2m

intervals as Tm;1, which has an O.h2/ error. If we use an intervalhalf as large, Richardson extrapolation gives

TmC1;2 D 2pTmC1;1 � Tm;1

2p � 1

) TmC1;2 D 4TmC1;1 � Tm;1

3.Simpson0s Rule/

with an O.h4/ error. If we halve the interval size again, the nextapproximation yields

TmC2;3 D 16TmC2;2 � TmC1;2

15C O.h6/

Page 25: Integration 1

Romberg Integration 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

❖ RombergR

❖ RombergR

2

❖ Matlab Code

❖ Example

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 25 / 52

In this way a triangular array of increasingly accurate results canbe obtained, with the general entry in the array given by

TmCk;kC1 D4kTmCk;k � TmCk�1;k

4k � 1.Romberg integration scheme/

(set p D 2k)

Thus the method computes a lower-triangular table of the form:

T1;1

T2;1 T2;2

T3;1 T3;2 T3;3:::

::::::

: : :

Page 26: Integration 1

MatLab Code: Romberg Integration

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

❖ RombergR

❖ RombergR

2

❖ Matlab Code

❖ Example

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 26 / 52

function I = romberg(func,a,b,tol)% Romberg integration; func: handle of function being integrated.% INPUT:% a,b = limits of integration.kMax = 20; %limit on the number of panel doublingstol=1e-8; %error tolerance.r = zeros(kMax); r(1) = trapezoid(func,a,b,0,1);rOld = r(1);for k = 2:kMax

r(k) = trapezoid(func,a,b,r(k-1),k);r = richardson(r,k);if abs(r(1) - rOld) < tol

numEval = 2^(k-1) + 1; I = r(1);return

endrOld = r(1);

enderror(’Romberg failed to converge’)

function r = richardson(r,k)for j = k-1:-1:1

c = 4^(k-j); r(j) = (c*r(j+1) - r(j))/(c-1);end

Page 27: Integration 1

Example: Romberg Integration

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

❖ RombergR

❖ RombergR

2

❖ Matlab Code

❖ Example

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 27 / 52

EvaluateZ 4

1

sin.3p

x/�2

dx:

There are 2m subintervals.

m Tm;1 Tm;2 Tm;3 Tm;4 Tm;5

1 1:572047311

2 1:633952455 1:654587503

3 1:635604518 1:636155206 1:634926386

4 1:635562001 1:635547828 1:635507336 1:635516557

5 1:635531240 1:635520987 1:635519198 1:635519386 1:635519397

Page 28: Integration 1

Improper Integrals

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

❖ Improper Integrals

❖ Improper Integrals 2

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 28 / 52

Page 29: Integration 1

Improper Integrals

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

❖ Improper Integrals

❖ Improper Integrals 2

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 29 / 52

Consider the integral

I DZ

1

0

f .x/ dx: (9)

You may try a substitution

x D 1 C y

1 � y

which maps the interval Œ0; 1� into Œ�1; 1� or

x D y

1 � y

which maps the interval Œ0; 1� into Œ0; 1�.

Just worth trying really... Because of the boundaries
Aother helpful one is, between a and infinity, it might be worth trying substituting x = 1/y
Page 30: Integration 1

Improper Integrals 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

❖ Improper Integrals

❖ Improper Integrals 2

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 30 / 52

Sometimes, it is useful to rewriteR

f .x/ dx asR f .x/

g.x/g.x/ dx and

choose g.x/ so that f .x/=g.x/ gives a “nicer” expression, andthen use the substitution g.x/ dx D dy.

For example, consider

Z

1

0

1

.1 C x/p

xdx and choose

g.x/ D 1=p

x:

Z

1

0

dx

.1 C x/p

xD

Z

1

0

� px

.1 C x/p

x

� �

dxpx

:

We have dy D dx=p

x, or y D 2p

x, or x D y2=4.

)

Z

1

0

dx

.1 C x/p

xD

Z

1

0

1

1 C y2=4dy .D �/

Do the substitution here and then solve
Page 31: Integration 1

Gram-Schmidt orthogonalization

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

❖ A way of findingabscissas and weights

❖ A way of ... 2

❖ A way of ... 3

❖ Gram-Schmidt

❖ Gram-Schmidt 2

❖ Gram-Schmidt 3

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 31 / 52

Page 32: Integration 1

A way of finding abscissas and weights

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

❖ A way of findingabscissas and weights

❖ A way of ... 2

❖ A way of ... 3

❖ Gram-Schmidt

❖ Gram-Schmidt 2

❖ Gram-Schmidt 3

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 32 / 52

Approximate the integral by a quadrature of the form

Z b

a

f .x/ dx �

NX

mD1

Wmf .xm/:

Both Wm and xm are unknowns, giving a total of 2N unknowns. Werequire that the quadrature be exact for f .x/ D 1; x; x2; : : : ; x2N �1.

For example, considering N D 2,

.b � a/ D W1 C W2;

1

2.b2

� a2/ D W1x1 C W2x2;

1

3.b3

� a3/ D W1x21 C W2x2

2 ;

1

4.b4

� a4/ D W1x31 C W2x3

2 :

Page 33: Integration 1

A way of finding abscissas and weights 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

❖ A way of findingabscissas and weights

❖ A way of ... 2

❖ A way of ... 3

❖ Gram-Schmidt

❖ Gram-Schmidt 2

❖ Gram-Schmidt 3

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 33 / 52

Any finite interval Œa; b� can be mapped onto the interval [-1,1] by asubstitution

y D �1 C 2x � a

b � a:

Thus it is sufficient for us to consider only this normalizedintegration region, in terms of which the nonlinear equations canbe expressed as

2 D W1 C W2; (10)

0 D W1x1 C W2x2; (11)

2=3 D W1x21 C W2x2

2 ; (12)

0 D W1x31 C W2x3

2 : (13)

Important to learn
Page 34: Integration 1

A way of finding abscissas and weights 3

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

❖ A way of findingabscissas and weights

❖ A way of ... 2

❖ A way of ... 3

❖ Gram-Schmidt

❖ Gram-Schmidt 2

❖ Gram-Schmidt 3

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 34 / 52

Eqs. (11) and (13) can be combined to yield x21 D x2

2 ; since thepoints must be distinct (else we wouldn’t have 4 independentvariables), we have that x1 D �x2.

Then from Eq. (11), we have W1 D W2, and from Eq. (10) we haveW1 D 1. Eq. (12) then gives us

2=3 D 2x21 ;

or that x1 D 1=p

3.

To summarize, we find that the function should be evaluated atxm D ˙1=

p3, and that the evaluations have an equal weighting of

1.

Page 35: Integration 1

Gram-Schmidt orthogonalization

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

❖ A way of findingabscissas and weights

❖ A way of ... 2

❖ A way of ... 3

❖ Gram-Schmidt

❖ Gram-Schmidt 2

❖ Gram-Schmidt 3

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 35 / 52

Suppose that um D xm form a basis set. There exists a set ofpolynomials �m.x/ such that

Z b

a

w.x/�m.x/�n.x/ dx D ımnCm:

For the moment, set w.x/ D 1, and let a D �1 and b D 1.Choose �0.x/ D u0.x/ D 1=

p2 so that all the Cm D 1

(normalization). Take �1 to be a linear combination of u1 and �0,

�1.x/ D u1 C ˛10�0

and make it satisfy

Z 1

�1

�0.x/�1.x/ dx D 0:

Page 36: Integration 1

Gram-Schmidt 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

❖ A way of findingabscissas and weights

❖ A way of ... 2

❖ A way of ... 3

❖ Gram-Schmidt

❖ Gram-Schmidt 2

❖ Gram-Schmidt 3

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 36 / 52

So,

Z 1

�1

�0.x/�1.x/ dx DZ 1

�1

�0.x/Œu1 C ˛10�0.x/� dx

DZ 1

�1

1p2

h

x C ˛10=p

2i

dx

D 0 C ˛10:

Therefore, ˛10 D 0 and hence �1.x/ D x. Normalizing, we have

�1.x/ Dr

3

2x:

The next orthogonal polynomial is found by choosing �2 to be a linearcombination of u2, �0, and �1:

�2.x/ D u2 C ˛21�1.x/ C ˛20�0.x/

D x2 C ˛21

p

3=2x C ˛20=p

2:

Page 37: Integration 1

Gram-Schmidt 3

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

❖ A way of findingabscissas and weights

❖ A way of ... 2

❖ A way of ... 3

❖ Gram-Schmidt

❖ Gram-Schmidt 2

❖ Gram-Schmidt 3

Gaussian Quadrature

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 37 / 52

We require

Z 1

�1

�0.x/�2.x/ dx D 0 and

Z 1

�1

�1.x/�2.x/ dx D 0:

From the first we find ˛20 D �p

2=3, and from the second˛21 D 0. After normalization, we find

�2.x/ Dr

5

2

3x2 � 1

2:

Page 38: Integration 1

Gaussian Quadrature

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

❖ Integration

❖ Integration 2

❖ Integration 3

❖ Integration 4

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 38 / 52

Page 39: Integration 1

Gaussian Integration

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

❖ Integration

❖ Integration 2

❖ Integration 3

❖ Integration 4

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 39 / 52

Consider integrals of the form

Z b

a

f .x/w.x/ dx DN

X

mD1

Wmf .xm/;

where w.x/ is a positive definite (i.e., never negative) weightingfunction. Let f .x/ be a polynomial of degree 2N � 1, and �N .x/

be a specific orthogonal function of order N such that

Z b

a

w.x/�m.x/�n.x/ dx D ımnCm:

We write

f2N �1.x/ D qN �1.x/�N .x/ C rN �1.x/; (14)

where both qN �1.x/ and rN �1.x/ are polynomials of order N � 1.

Any polynomial can be written as this
Page 40: Integration 1

Gaussian Integration 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

❖ Integration

❖ Integration 2

❖ Integration 3

❖ Integration 4

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 40 / 52

Then

Z b

af2N �1.x/w.x/ dx D

Z b

aqN �1.x/�N .x/w.x/ dx C

Z b

arN �1.x/w.x/ dx:

(15)

Since the functions f�mg are a complete set, we can expand thefunction qN �1.x/ as

qN �1.x/ DN �1X

iD0

qi �i .x/;

where the qi are constants. The first integral on the right side ofEq. (15) is then

Z b

aqN �1.x/�N .x/w.x/ dx D

N �1X

iD0

qi

Z b

a�i .x/�N .x/w.x/ dx

DN �1X

iD0

qi ıiN Cn D 0: (16)

Page 41: Integration 1

Gaussian Integration 3

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

❖ Integration

❖ Integration 2

❖ Integration 3

❖ Integration 4

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 41 / 52

The product qN �1.x/�N is also a polynomial of order 2N � 1, soit must be true that

Z b

a

qN �1.x/�N .x/w.x/ dx DN

X

mD1

WmqN �1.xm/�N .xm/

D 0; from Eq: (16):

As qN �1.x/ is arbitrary, the only way to guarantee that this sumwill be zero is to require that all the �N .xm/ be zero. That is, xm

are chosen such that the orthogonal polynomial �N .x/ is zero atthese points.

The weight cannot be zero otherwise everything would have been zero
Could not be zero as it is completely arbitrary
Therefore phi is the zero
Page 42: Integration 1

Gaussian Integration 4

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

❖ Integration

❖ Integration 2

❖ Integration 3

❖ Integration 4

Gauss-Legendre-Laguerre

P aul Lim Numerical Integration: Part 1 – 42 / 52

The integration formula is to be exact for polynomials of order2N � 1, so surely it must be exact for a function of lesser order aswell. In particular, it must be true for the .N � 1/-th orderpolynomial li;N .x/, defined as

li;N .x/ D .x � x1/ � � � .x � xi�1/.x � xiC1/ � � � .x � xN /

.xi � x1/ � � � .xi � xi�1/.xi � xiC1/ � � � .xi � xN /;

where

li;N .xj / D�

0; j ¤ i

1; j D i:

We thus have the exact result

Z b

a

li;N .x/w.x/ dx DN

X

mD1

Wmli;N .xm/ D Wi : (17)

Check Newton Cotes - same idea
Page 43: Integration 1

Gauss-Legendre-Laguerre

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 43 / 52

Page 44: Integration 1

Gauss-Legendre Quadrature

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 44 / 52

As an example, let’s develop an integration rule for the integral

I DZ 1

�1

f .x/ dx;

using two function evaluations. Since the limits of the integrationare a D �1, b D 1, and w.x/ D 1, Legendre functions are theappropriate orthogonal polynomials to use. Now

�2.x/ Dr

5

2

3x2 � 1

2:

The abscissas for the Gauss-Legendre integration are the zeros ofthis function:

x1 D �r

1

3and x2 D C

r

1

3:

Page 45: Integration 1

Gauss-Legendre Quadrature 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 45 / 52

The weights are then evaluated by performing the integral ofEq. (17), namely,

W1 DZ 1

�1

l1;N .x/ dx DZ 1

�1

x � x2

x1 � x2dx

D 1

x1 � x2

x2

2� x2x

�1

�1

D �2x2

x1 � x2D 1

and

W2 DZ 1

�1

l2;N .x/ dx DZ 1

�1

x � x1

x2 � x1dx

D 1

x2 � x1

x2

2� x1x

�1

�1

D �2x1

x2 � x1D 1:

Page 46: Integration 1

Gauss-Legendre Quadrature 3

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 46 / 52

Z 1

�1

f .�/ d� �n

X

iD1

Wif .�i /

˙�i Wi ˙�i Wi

n D 2 n D 5

0:577350 1:000000 0:000000 0:568889

n D 3 0:538469 0:478629

0:000000 0:888889 0:906180 0:236927

0:774597 0:555556 n D 6

n D 4 0:238619 0:467914

0:339981 0:652145 0:661209 0:360762

0:861136 0:347855 0:932470 0:171324

Page 47: Integration 1

Gauss-Legendre Quadrature 4

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 47 / 52

To apply Gauss-Legendre quadrature to the integralR b

a f .x/ dx,we must first map the integration range .a; b/ into the range.�1; 1/. Thus is accomplished using the transformation

x D b C a

2C b � a

2�;

so that

Z b

a

f .x/ dx D b � a

2

Z 1

�1

f .x/ d� � b � a

2

nX

iD1

Wif .xi /

Page 48: Integration 1

MatLab Code: GL

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 48 / 52

function gq()

% approximate the definite integral of an arbitrary function% using the composite three-point Gauss-Legendre quadrature rulea=0; b=pi; %limits of integrationn=10; %number of uniformly sized subintervals into which

%integration interval is to be divided%%%%%%%%%%%%%%%%%%%%%%%%h2 = (b-a)/(2*n);sq35 = sqrt(0.6); %abscissaw1 = 5/9; %weights, x=+- sqrt(0.6)w2 = 8/9; %weights, x=0;x = linspace ( a, b, n+1 );sum = 0.0;for i = 1:n

%x =[x_{i+1}+x_i]/2+ [x_{i+1}-x_i]/2*newxsum = sum + w1 * f(x(i) + h2 - sq35 * h2 );

sum = sum + w2 * f(x(i) + h2);sum = sum + w1 * f(x(i) + h2 + sq35 * h2 );endintegral=h2* sumfunction f=f(x)f=(sin(x)/x).^2;

Page 49: Integration 1

Gauss-Laguerre Quadrature

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 49 / 52

Consider

I DZ

1

0

e�xf .x/ dx:

We shall use the Gram-Schmidt procedure to find a set of functionsthat are orthogonal over the region Œ0; 1� with the weightingfunction w.x/ D e�x .

Set um D xm, and considering the function �0 D ˛00u0, theorthogonality condition gives

Z

1

0

w.x/�0.x/�0.x/ dx D ˛200

Z

1

0

e�x dx D ˛200 D C0:

With C0 set to unity, we find �0.x/ D 1.

Page 50: Integration 1

Gauss-Laguerre Quadrature 2

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 50 / 52

We then consider the next polynomial,

�1.x/ D u1.x/ C ˛10�0.x/;

and require that

Z

1

0

e�x�0.x/�1.x/ dx D 0;

and so on. This process constructs the Laguerre polynomials.

Page 51: Integration 1

Gauss-Laguerre Quadrature 3

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 51 / 52

Z

1

0

e�xf .x/ dx �n

X

iD1

Wi f .xi /

xi Wi xi Wi

n D 2 n D 50:585786 0:853554 0:263560 0:5217563:414214 0:146447 1:413403 0:398667

n D 3 3:596426 .�1/0:7594240:415775 0:711093 7:085810 .�2/0:3611752:294280 0:278517 12:640801 .�4/0:2336706:289945 .�1/0:103892 n D 6

n D 4 0:222847 0:4589640:322548 0:603154 1:188932 0:4170001:745761 0:357418 2:992736 0:1133734:536620 .�1/0:388791 5:775144 .�1/0:1039929:395071 .�3/0:539295 9:837467 .�3/0:261017

15:982874 .�6/0:898548

Multiply numbers by 10k , where k is given in parentheses.

Page 52: Integration 1

Gauss-Hermite quadrature

Newton-CotesFormulas

Composite Rules

Euler-McClaurin

Romberg Integration

Improper Integrals

Gram-Schmidtorthogonalization

Gaussian Quadrature

Gauss-Legendre-Laguerre

❖ Gauss-Legendre

❖ Gauss-Legendre 2

❖ Gauss-Legendre 3

❖ Gauss-Legendre 4

❖ Matlab Code

❖ Gauss-Laguerre

❖ Gauss-Laguerre 2

❖ Gauss-Laguerre 3

❖ Gauss-Hermite

P aul Lim Numerical Integration: Part 1 – 52 / 52

Z

1

�1

e�x2

f .x/ dx �n

X

iD1

Wif .xi /

xi Wi xi Wi

n D 2 n D 50:707107 0:886227 0:000000 0:945308

n D 3 0:958572 0:3936190:000000 1:181636 2:020183 .�1/0:1995321:224745 0:295409 n D 6

n D 4 0:436077 0:7246290:524648 0:804914 1:335849 0:1570671:650680 .�1/0:813128 2:350605 .�2/0:453001

Multiply numbers by 10k , where k is given in parentheses.

The nodes are placed symmetrically about x D 0, each symmetric pairhaving the same weight.