Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
GENG2140 Modelling and Computer
Analysis for Engineers
Lectures 29 & 30:
Gaussian quadrature
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA) 1
Content
• Definition of Gaussian quadrature
• 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 2
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
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:
• wi – weight factors, xi – evaluation points
3
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
(1) 1
b
a
n
i
ii )f(xwf(x)dx
• 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 (wi and xi , i = 1 … n) (see eq. 1)
4
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
• 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
• The Gaussian quadrature algorithms are conventionally stated for the integration domain [-1, 1], with symmetrical weights and points:
5
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
(2) 2
1 , oddfor ][
1
11
00
n-kn)xf()f(xw)f(xwf(x)dx
k
i
iii
(3) 2
,even for ][1
11
nkn)xf()f(xwf(x)dx
k
i
iii
Computation of weights and points for 2-point Gaussian quadrature
• n=2, the parameters are w1 and x1 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, x2, x3
• If the procedure is exact for any polynomial of
degree up to 3, it has to be exact for the above monomials as well
6
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
constants - xcxb1a 32 a,b,c,dxdp(x)
• By substituting the 4 monomials in eq. 3:
• Relations (5) and (7) are automatically satisfied because of the symmetry of weights and points
• From eq. 4 and 6: w1 = 1 and x12 = 1/3
7
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
(7) ][0
(6) ][3/2
(5) ][0
(4) ]11[21
1
1
3
1
3
11
3
1
1
2
1
2
11
2
1
1111
1
11
xxwdxx
xxwdxx
xxwxdx
wdx
• The 2-point Gaussian quadrature:
• Although very simple, eq. 8 is exact for polynomials up to 3rd 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 3rd degree
8
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
(8) )3
1()
3
1()(
1
1
ffdxxf
• Example:
– Exact integral:
– Gaussian quadrature:
• 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
9
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
1
1
1
1..6829.1)1sin()1sin()sin()cos( xdxx
1.6758..)3
1cos()
3
1cos()cos(
1
1
dxx
Change of interval for Gaussian quadrature
• If the integration interval is not [-1, 1], a change of variable can be used to modify it:
10
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
(11)
2
2
1
1
(10) ,
(9) )(
abn
abm
nmb
nma
zbx
zax
dzm dxnzmx
dxxfIb
a
• From eq. 9 - 11:
• Example:
11
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
(12) 2
)22
( )(1
1
dz
ababz
abfdxxfI
b
a
quadratureGaussian - 0.571423/1
5.0
23/1
5.0
2
5.0
2
5.050
1)5.15.0(2
1
12
1
;50 ;5.15.0
512
502
2; 1;
eexact valu - 5493.0)12ln(2
1
12
1
1
1
1
1
1
1
2
1
2
1
2
1
dzz
dzz
dz.z
dxx
dz.dxznzmx
;.ab
; n .b-a
m ba
xdxx
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 quadratures for each sub-domain
• A combination of the above
12
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
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
13
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
Multidimensional integrals
14
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
• 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)
15
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
Example: 4-point Gaussian quadrature in 2D
)23
1
2,
23
1
2()
23
1
2,
23
1
2(
)23
1
2,
23
1
2()
23
1
2,
23
1
2(
22
t)22
,23
1
2()
22,
23
1
2(
22
y),23
1
2(),
23
1
2(
2
y2
),22
(
y)),(( y),(
1
1
1
1
cdcdababf
cdcdababf
cdcdababf
cdcdababf
cdab
dcd
tcdabab
fcd
tcdabab
fcdab
dyabab
fyabab
fab
ddzab
yab
zab
f
ddxyxfddxyxfI
d
c
d
c
d
c
b
a
d
c
b
a
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:
16
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
V
TEBdVBK
17
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
• The integration domain is divided in smaller sub-domains – the elements
• The integral over each element is computed using Gaussian quadrature (usually 1 or 2 points in each dimension)
e
V
eT
e
e
V
T
eEBdVBKEBdVBK
Improper integrals
• Infinite integration limits
• Integrals of functions with vertical asymptotes (the function becomes unbounded within the integration domain)
18
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
• Improper integral on a finite domain:
• Improper integral on an infinite domain:
• Oscillatory improper integral:
• Improper integrals that do not converge:
19
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
22x
1 1
0
1
0 xdx
11
x
1
11 2
xdx
2)(
x
sin(x)00
xSidx
dxdx
1
1
0 x
1
x
1
• 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.
20
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
integralproper a - e1
1ee
1
1 ;
1 ;1
1
1ee
1
0
1-1
2
0
1 2
11
-
0
x-
2
0
x-
0
x-
dtt
dtt
dx
xtdt
t-dx
tx
dx
t
t
• 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.
21
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
8.5570...I 1.9785... I
quadratureGaussian points 40
7.1954...I 1.9575... I
quadratureGaussian points 20
ln1
I 221
I
21
21
1
0
1
02
1
0
1
01
(x)dxx
xdxx
• 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
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
22
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
36754.121
I1
1.0
1
1.01 xdx
x
An adaptive method of numerical integration: • Compute the following integrals using one of the
numerical integration methods that uses only interior points:
• We expect that I≈I1+I2, and if the equation holds with reasonable accuracy we accept I1+I2 as the value of the integral
• If the 2 values are not close enough, we calculate I1+I2 separately using the same method
23
GENG2140
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA)
dxxf
dxxf
dxxf
b
ba
ba
a
b
a
2
2
21
)( I
)( I
)(I
Thank you!
Created by Grand Roman Joldes, PhD (School of Mechanical Engineering, UWA) 24