Вы находитесь на странице: 1из 24

GENG2140

Modelling and Computer

Analysis for Engineers

Lectures 29 & 30:

Content

GENG2140

Computation of weights and points for 2-point Gaussian quadrature

Change of interval for Gaussian quadrature

Ways of increasing integration accuracy

Multidimensional integrals

Real life example of usage

Improper integrals

GENG2140

Definition:

A quadrature rule is an approximation of the definite integral of a function, usually stated as a weighted sum of function

values at specified points within the domain of integration

The numerical integration algorithms presented so far (Trapezoidal rule, Simpson’s rule) worked on evenly spaced points

Trapezoidal rule: b

a

f(x)dx

n

i 1

w

i

f(x )

i

(1)

w i weight factors, x i evaluation points

GENG2140

Carl Friedrich Gauss (German mathematician and scientist) noticed that by suitable choosing both the weights and the evaluation points the accuracy of the integral can be improved

He proposed to choose the weights and points so that the procedure should be exact for polynomials of a degree as high as possible

If the procedure requires the evaluation of the function in n points, it has 2n parameters to be determined (w i and x i , i = 1 … n) (see eq. 1)

GENG2140

Because a general polynomial of degree N has

N+1 coefficients, the Gaussian quadrature with n points is required to be exact for any

polynomial of degree N = 2n-1 (which also

have 2n parameters) or less

1

1

conventionally stated for the integration

domain [-1, 1], with symmetrical weights and points:

k

n- 1

2

(3)

f(x)dx

f(x )

0

k

i 1

[

f(x )

i

f(

x )

i

]

for odd

n k

,

n

2

w

0

w

i

w

i

i 1

[ f(x )

i

1

1

f(x)dx

f(

x )

i

n k

,

] for even

(2)

GENG2140

Computation of weights and points

n=2, the parameters are w 1 and x 1 according to eq. 3, and the procedure should be exact for polynomials of degree up to N = 2n-1 = 3

Any polynomial of degree up to N = 3 can be written as a linear combination of the following monomials: 1, x, x 2 , x 3

p(x)

a 1

b

x

c

x

2

3

d x

a,b,c,d

- constants

If the procedure is exact for any polynomial of degree up to 3, it has to be exact for the above monomials as well

GENG2140

By substituting the 4 monomials in eq. 3:

1

1

1

1

1

1

1

1

1 dx  

2

w

1

[1

1]

xdx

0

w

1

[

x

1

x

1

]

x

x

2 2 / 3

dx

3 0

dx

 

w [

1

w

1

[

x

1

3

x

1

2

x

1

3

(4)

x

1

]

2

]

(5)

(7)

(6)

Relations (5) and (7) are automatically satisfied because of the symmetry of weights

and points

From eq. 4 and 6: w 1 = 1 and x 1 2 = 1/3

GENG2140 1
1
f
(
x dx
)
f
(
)
1
3 1
f
(
)
3

(8)

Although very simple, eq. 8 is exact for

polynomials up to 3 rd degree!

If the function that is integrated is not a

polynomial of degree 3 or less, eq. 8 will give

an approximation only the accuracy depends

on how much the function resembles a polynomial of 3 rd degree

Example:

Exact integral:

1

1

cos(x)dx

sin(x)

1

1

1

1

cos(

)

x

dx

cos( 1
)
3

sin(1)

sin(

1)

 

1.6829

cos( 1
)
3

1.6758

GENG2140

The same procedure can be applied to find the weights and points for higher degree Gaussian quadratures (n = 3,4,…) – very tedious

The weights and points are usually given in

tabular form

GENG2140

Change of interval for Gaussian

If the integration interval is not [-1, 1], a change of variable can be used to modify it:

I

b

a

f

x m

x dx

)

(

z

n

,

x

   1

a

z

x

b

  1

z

b a

m

2

b a

n

2

(9)

dx

m dz

a

m

 

n

b

m

n

(11)

(10)

GENG2140

From eq. 9 - 11:

b

a

f

1 b a

1

f

x

(

2

2

1)

1

b-a

b a

2

b a

2

I

(

x dx

)

)

dz

z

Example:

1

 2 x  1  1; b  m  z 1 2 x  1

dx

2;

n

1

2

m

2

1

ln( 2

0.5493 - exact valu e

b a

2

a

0 5

. ; n

15

.

;

1

1

 2 z  1.5; dx  1 z   1

2(0.5

1.5)

x

2

1

0.5

0 5

. dz

;

1

1

0.5

z 2

dx

0 5

. dz

dz

(12)

1 0.5

1

z 2

dz 0.5
1/
3
 2 0.5
1/
3
2

GENG2140

Ways of increasing integration

accuracy

Increase the number of Gauss points

Composite Gaussian quadrature divide the integration domain into sub-domains the

integral value is the sum of Gaussian

A combination of the above

GENG2140

Example of Matlab implementation:

function g = gauss10(f_handle,a,b) %GAUSS10(f_handle,a,b) will integrate the function f_handle % over the interval a<x<b using a 10 point Gauss quadrature

% approximation. Example of use:

% f = @(x) x.^2 + sin(x); g = gauss10(f,0,1).

%======================================================

 x = [0.1488743390;0.4333953941;0.6794095683; 0.8650633667;0.9739065285]; w = [0.2955242247;0.2692667193;0.2190863625; 0.1494513492;0.0666713443]; t = .5*(b+a)+.5*(b-a)*[-x; x]; W = [w; w];

g = sum(W.*f_handle(t))*(b-a)/2;

end

GENG2140

Multidimensional integrals

The multidimensional integral is computed as

repeated one-dimensional integrals

This is valid for all numerical integration

methods, not only for Gaussian quadrature

Numerical integration over more than one dimension is sometimes described as cubature

Different integration methods can be applied

in different dimensions (e.g. 2 points Gaussian

integration in one dimension and 1 point

Gaussian integration in another dimension)

GENG2140

Example: 4-point Gaussian quadrature in 2D

I

 d

c

b

a

f x y dxd

(

,

)

y

 d

c

(

b

a

f x y dx d

(

,

)

)

y

 d

c

1

1

d

c

b

 b  a b  a b  a z  , ) y     2 2 f ( b  a 1 b  a   2 3 2 , 2 y )

f (

dz d

y b  a
1
b  a
(
,
y
)
2
2
3

a

f

2

d

y b
 a
d  c
 f (
b
a
1
b
a d
c
d  c
b  a
 1
b
a d
c
,
t 
)
 f
(
,
t 
d
)
 c
d 
t
 1
 1
2
2
2
2
2
2
2
2
2
2
3
3
b  a
d  c
 f (
b
a
1
b
a d
c
1
d  c
b  a
 1
b
a d
c
1 d  c
,
)
 f
(
,
)
2
2
2
2
2
2
2
2
2
2
3
3
3
3
b  a
1
b
a d
c
 1
d  c
b
 a
 1
b
a d
c
 1
d  c
 f (
,
)
 f
(
,
)
2
2
2
2
2
2
2
2
3
3
3
3

GENG2140

Example of use The Finite

Element Method:

The Finite Element method is a numerical

method for solving partial differential equations

or integral equations

When applied to solid mechanics, it requires

many variables to be integrated over the spatial

domain defining the system. For example, the stiffness matrix of a system is defined as:

K

T

B EBdV

V

GENG2140

The integration domain is divided in smaller sub- domains the elements

K

B EBdV

V

T

 

K

e

V

e

e

e

T

B EBdV

e

The integral over each element is computed

using Gaussian quadrature (usually 1 or 2 points in each dimension) GENG2140

Improper integrals

Infinite integration limits

Integrals of functions with vertical asymptotes

(the function becomes unbounded within the integration domain)  GENG2140

Improper integral on a finite domain: 2 1
x
0

2

Improper integral on an infinite domain:

1

1

dx

x

2

1

x

1

1

Oscillatory improper integral:

0

sin(x)

x

dx

Si x

(

)

0

2

Improper integrals that do not converge:

1

0

1

dx

x

1

1

dx

x

GENG2140

Improper integrals are difficult to integrate.

For the case where there is an infinite interval of

integration, one may make a change of variables that

transforms the infinite range of integration into a finite one.

0

e

-x

dx



e

-x

1

0

1

x  

t

1;

0

e

1

0

-x

dx

1

t

2

1-

1

t
e

0

1

dt

dx

e

-

1

t

1

-

1

t

2

dt

;



1

t

2

t

dt

1

x

1

- a proper integral

GENG2140

Methods such as Gaussian quadrature do not use

the value of the integrand at end points, and

hence integrands that are undefined at end points can be integrated using such methods. 1
I
dx
1
 1
0
x

2 1
x
0

2

I

2

1

0

1

d x

x

ln

(x)

1

0



I

1

1.9575

I

2

I

1

1.9785

I

2

  7.1954  8.557

GENG2140

For a convergent improper integral we can get better approximations by using more and more Gauss points this is wasteful

In general, an improper integral is easy to calculate away from its singularity

For example, for 1
I
 1
dx
1
0.1
x

2 1
x
0.1

1.36754

we get a similar value using the 20 points Gaussian quadrature

We want to use lots of Gauss points near the singularity but not so many elsewhere

GENG2140

An adaptive method of numerical integration:

Compute the following integrals using one of the

numerical integration methods that uses only

interior points:

b

a

I

f

(

x dx

)

I

1

I

2

a

b

a

2

a

b

b

2

 f ( x dx ) f ( x dx )

We expect that I≈I 1 +I 2 , and if the equation holds with reasonable accuracy we accept I 1 +I 2 as the value of the integral

If the 2 values are not close enough, we calculate I 1 +I 2 separately using the same method

Thank you!