Lecture Note (14) Gauss Quadrature Formula
Lecture Note (14) Gauss Quadrature Formula
Gauss quadrature implements a strategy of positioning any two points on a curve to define a straight line that
would balance the positive and negative errors.
Hence the area evaluated under this straight line provides an improved estimate of the integral.
Affine Transformation
2 x x0 x x0 x x0
t x f , t [ 1, 1] x f t f
x f x0 x f x0 2 2
Using Affine transformation we can redefine above integration as
2 x x0
dt dx dx f dt
x f x0 2
xf x f x0 1 x f x0 x f x0 x f x0 1
I f ( x)dx 1 2
f t dt g (t )dt
x0 2 2 2 1
1
3. Derivation of Gauss Quadrature Formula
If we use the standard form, the integration can be estimated by integrating the following form
1
I f ( x)dx
1
w0 f x0 w1 f x1 w2 f x2 w3 f x3 w4 f x4 wn 1 f xn 1
where
xj, j 0,1,2, , n 1 : Gauss Quadrature points
x j ' s, w j ' s should be determined to balance the positive and negative errors
1
(3-1) Two-point Gauss quadrature formula to exactly integrate I
1
f ( x)dx with f ( x ) 1, x, x 2 , x 3
I w0 f ( x0 ) w1 f ( x1 )
1
f ( x) 1 w0 f ( x0 ) w1 f ( x1 ) w0 w1 1dx 2
1 w0 w1 2
1
f ( x) x w0 f ( x0 ) w1 f ( x1 ) w0 x0 w1 x1 xdx 0 w0 x0 w1 x1
1
2
2 2 2
f ( x) x 2 w0 f ( x0 ) w1 f ( x1 ) w0 x0 w1x1 x 2 dx
2 2 1 w0 x0 w1x1
1 3 3
3 3
1 w0 x0 w1 x1
f ( x) x w0 f ( x0 ) w1 f ( x1 ) w0 x0 w x x dx 0
3 3 3 3
1 1 1
2
From the 2nd and 4th equations,
2 2
x0 x1 x0 x1
From the 2nd equation,
w0 x0 w1 x1 w0 x0 w1 x0 x0 ( w0 w1 ) 0 w0 w1 since x0 0
From the 1st equation,
2 w0 2 w0 w1 1
From the 3rd equation
1
x0 0.5773503
2 2 2 2 2 3
w0 x0 w1 x1 2 x0
3 3 1
x1 0.5773503
3
Therefore the integration formula becomes
I w0 f ( x0 ) w1 f ( x1 )
1 1
f f
3 3
1 2
I (a bx cx 2 )dx 2a c
1 3
- Gauss Quadrature formula results in the same value
1 1
I w0 f ( x0 ) w1 f ( x1 ) f f
3 3
1 1 1 1 2
a b c a b c 2a c
3 3 3 3 3
(b) 3rd order polynomial function: f ( x ) a bx cx 2 dx 3
1 2
- Exact integration: I (a bx cx 2 dx3 )dx 2a c
1 3
- Gauss Quadrature formula results in the same value
1 1
I w0 f ( x0 ) w1 f ( x1 ) f f
3 3
1 1 1 1 1 1 2
a b c d a b c d 2a c
3 3 3 3 3 3 3 3 3
3
(c) 4th order polynomial function: f ( x ) a bx cx 2 dx 3 ex 4
1 2 2
- Exact integration: I (a bx cx 2 dx3 ex 4 )dx 2a c e
1 3 5
- Gauss Quadrature formula generates some error
1 1
I w0 f ( x0 ) w1 f ( x1 ) f f
3 3
1 1 1 1 1 1 1 1 2 2
a b c d e a b c d e 2a c e
3 3 3 3 9 3 3 3 3 9 3 9
In general, the n-point Gauss Quadrature formula gives the exact integration up to (2n-1)th order
polynomials
4
4. Application of Gauss Quadrature Formula
Given
- Number of Gauss Quadrature Point: n
- Data for Gauss Quadrature Point
(a) Arguments : j, j 1,2, , n ( j ( 1,1) )
2 x f x0
d dx dx d
x f x0 2
xf x f x0
x f x0 x x0
1
I f
f ( x)dx
f d
x0 2 1
2 2
x x0 1 x x0 ~ ~ 1
f
2 1
g ( )d f
2
I I g ( )d
1
Integration Formula
n
~ 1
I g ( )d w j g ( j )
1
j 1
x x0 ~ x f x0 n x x0 n x x0 x x0
I f I w j g ( j ) f w j f f j f
2 2 j 1 2 j 1 2 2
Weights and function arguments x in Gauss Quadrature for the different number of quadrature points
3 w1 0.555555556 1 0.774596669
w2 0.888888889 2 0.000000000
w3 0.555555556 3 0.774596669
4 w1 0.347854845 1 0.861136312
w2 0.652145155 2 0.339981044
w3 0.652145155 3 0.339981044
w4 0.347854845 4 0.861136312
5
5 w1 0.236926885 1 0.906179846
w2 0.478628670 2 0.538469310
w3 0.568888889 3 0.000000000
w4 0.478628670 4 0.538469310
w5 0.236926885 5 0.906179846
6 w1 0.171324492 1 0.932469514
w2 0.360761573 2 0.661209386
w3 0.467913935 3 0.238619186
w4 0.467913935 4 0.238619186
w5 0.360761573 5 0.661209386
w6 0.171324492 6 0.932469514
Example 1]
Given for n=3
5
I f ( x)dx, x [0, 5]
0 Exact Integral
5
I 3x 2 2 x dx x3 x 2
0
5
0
53 52 150.0
f ( x) 3x 2 2 x
Solution
x f x0 x f x0
I 2.5 w j f 2.5 j 2.5
n
2.5, 2.5
j 1 2 2
2.5w1 f 2.5 1 2.5 w2 f 2.5 2 2.5 w3 f 2.5 3 2.5
x1 2.5 1 2.5 2.5 0.774596669 2.5 0.56350833
x2 2.5 2 2.5 2.5 0.0 2.5 2.5
x3 2.5 3 2.5 2.5 0.774596669 2.5 4.436491672
f1 f (0.56350833) 3x 2 2 x x 0.56350833
2.079641560
f2 f (2.5) 3x 2 x 2
23.75
x 2.5
f3 f (4.436491672) 3 x 2 x 2
67.920358425
x 4.436491672
6
5. Pseudo code for the Gauss Quadrature
Program main
% Input
n =3;
xmin = 0.0;
xmax = 5.0;
dx_plus = 0.5*(xmax+xmin);
dx_minus = 0.5*(xmax-xmin);
% Guass quadrature nodes and weights
call gauss_node(n,tau,w);
% Integration using Guass quadrature formula
gauss_integral = 0.0;
do j=1, n
x = dx_minus*tau(j)+dx_plus;
call f(x,y);
gauss_integral = gauss_integral + w(j)*y;
end do;
gauss_integral = dx_minus*guass_integral;
end program main
function gauss_node(n,tau,w)
if n=2, then
w1 1.000000000 , w2 1.000000000
1 0.577350269, 2 0.577350269
else if n=3, then
w1 0.555555556, w2 0.888888889, w3 0.555555556
1 0.774596669, 2 0.000000000, 3 0.774596669
else if n=4, then
w1 0.347854845, w2 0.652145155, w3 0.652145155 , w4 0.347854845
1 0.861136312, 2 0.339981044, 3 0.339981044 , 4 0.861136312
else
print*,‘node number n exceeds the maximum allowed node number= 4.’
print*, ‘Please add the node information (Gauss quadrature points and weights’
stop
end if
end function gauss_node
7
6. Advanced Topics on Gauss Quadrature
(6-1) Theorem (Gauss quadrature) Let { j } Nj 0 be the set of the zeros of the polynomial p N 1 ( )
orthogonal with respect to a weighting function () . Then there exists a unique set of quadrature weights
defined by
1 N
( k )
w j j()()d where j()
1
k 0 ( j k )
k j
and the exact weighted integration of the polynomial function , the degree of which is less than or equal to
2N+1, can be obtained with
N
p()()d p( j )wj ,
1
1
j 0
p() P2 N 1
8
Derivation of Legendre polynomials using the recurrence relation
L0 ( ) 1
L1 ( )
3 1 1
L2 ( ) L1 ( ) L0 ( ) (3 2 1)
2 2 2
5 2 5 2 1
L3 ( ) L2 ( ) L1 ( ) (3 3 ) (5 3 3 )
3 3 6 3 2
7 3 7 3 1
L4 ( ) L3 ( ) L2 ( ) (5 4 3 2 ) (3 2 1) (35 4 30 2 3)
4 4 8 8 8
9 4 9 2 1
L5 ( ) L4 ( ) L3 ( ) (35 5 30 3 3 ) (5 3 3 ) (63 5 70 3 15 )
5 5 40 5 8
11 5 11 5
L6 ( ) L5 ( ) L4 ( ) (63 6 70 4 15 2 ) (35 4 30 2 3)
6 6 48 48
1
(231 6 315 4 105 2 5)
16
( N 1) LN 1 ( ) ( 2 N 1)LN ( ) NLN 1 ( )
(6-3) Gauss Quadrature nodes { j } Nj 0 and weights {w j } Nj 0
The quadrature weights can be written as (also, weights are generally calculated using numerical methods)
( 2 N 1) 2 ( N 1)
wj , j 0,1, , N
( N 1) ( 2 N 1) (1 j ) LN 1 ( j ) LN 1 ( j )
2
2
2
j
(1 ) LN 1 ( j )
2
9
Gauss Quadrature Nodes and Weights
N 0 0 0, L1( ) 1 w0 2
N 1 0 1 / 3 , 1 1 / 3 , L2 ( ) 3 w0 w1 2 /1 1 / 33 1
1
N 2 0 3 / 5 , 1 0, 2 3 / 5 , L3 ( ) (15 2 3)
2
1
2
5
w0 w2 2 / 1 3 / 5 9 3
2 9
3 8
2
w1 2 /
2 9
15 225 105 1
N 3 (35 4 30 2 3) 0 0 ,1, 2 ,3 0.86113631, 0.33998104 , L4 ( ) (105 3 60 )
35 8
w0 w2 0.34785484
w1 w3 0 .65214515
10