JT Chen Reporter: Jia-Wei Lee Date: Mar., 11, 2010

Gaussian quadrature
Advisor: J. T. Chen
Reporter: Jia-Wei Lee
Date: Mar., 11, 2010
Page 1
計算機在工程上的應用
2010/3/11
Trapezoidal rule
1
 f ( x0 )  2 f ( x1 )  2 f ( x2 ) 
n
1
I   f ( x)dx 
1
1
1
x0 x1 x2
I 
xn
x0
where
Page 2
 2 f ( xn 1 )  f ( xn ) 
wi
xn 1
n
f ( x)dx  wi f ( xi )
i 1
xn
 x0  1

 xn  1
is weighting coefficient
計算機在工程上的應用 (JWLee)
2010/3/11
Gaussian quadrature
N
I   f ( x)dx  wi f ( xi )
1
1
i 1
f (x) is the polynomial of degree 2n-1 or less
f ( x)  Pn ( x)Qn1 ( x)  Rn1 ( x)
N
I   wi f ( xi )
1
I   f ( x )dx
i 1
1
1
1
1
1
  Pn ( x)Qn 1 ( x )dx   Rn 1 ( x )dx
1
?   Rn 1 ( x )dx ???
1
( x1 ,..., xn )
Page 3
N
N
i 1
i 1
  wi Qn 1 ( xi ) Pn ( xi )   wi Rn 1 ( xi )
N
  wi Rn 1 ( xi ) N  n
i 1
are the zeros of polynomial
計算機在工程上的應用 (JWLee)
Pn ( x)  0
2010/3/11
Legendre polynomial
Legendre’s equation:
Legendre polynomial:
1
(1  x 2 ) y  2 xy  n(n  1) y  0
1 dn 2
Pn ( x)  n
( x  1) n , 1  x  1
n
2 n ! dx
P0 ( x)  1
P1 ( x)  x
0.5
-1
-0.5
0.5
1
-0.5
-1
Page 4
1
(3 x 2  1)
2
1
P3 ( x)  (5 x3  3 x)
2
1
P4 ( x)  (35 x 4  30 x 2  3)
8
P2 ( x) 
Here are n distinct roots of
Pn ( x)
計算機在工程上的應用 (JWLee)
in the interval (1,-1)
2010/3/11
The orthogonality of
Legendre polynomial
e2
vectors
e1
1, if i  j
 ei  e j  
0, if i  j
e3
functions

b
a
w( x) A( x) B ( x)dx  0
Legendre polynomial
Page 5
A( x) and B( x)
0

1
P
(
x
)
P
(
x
)
dx

 2
1 n m
 2n  1
1
e1  e2

 e2  e3
e  e
 3
1
are orthogonal
if n  m
if n  m
計算機在工程上的應用 (JWLee)
2010/3/11
Gaussian quadrature
N
I   f ( x)dx  wi f ( xi )
1
1
i 1
f (x) is the polynomial of degree 2n-1 or less
f ( x)  Pn ( x)Qn 1 ( x)  Rn 1 ( x)
n 1
  i Pi ( x) Pn ( x)  Rn 1 ( x)
i 0
N
I   wi f ( xi )
1
I   f ( x)dx
i 1
1
n 1
   i  Pi ( x) Pn ( x)dx   Rn 1 ( x )dx
i 0
1
1
1
1
i 1
i 1
  wi Qn 1 ( xi ) Pn ( xi )   wi Rn 1 ( xi )
  wi Rn 1 ( xi )
1
( x1 ,..., xn )
N
N
  Rn 1 ( x)dx
1
N
N n
i 1
are the zeros of Legendre polynomial
Pn ( x)  0
Therefore the integral can be obtained by using n points
Page 6
計算機在工程上的應用 (JWLee)
2010/3/11
Gaussian quadrature
n
I   f ( x)dx  wi f ( xi )
1
1
i 1
n
f ( x)    i ( x) f ( xi )
i 1
1, i  j
i ( x j )  
0, i  j

 ( x  x1 )( x  x2 ) ( x  xn )
( xi  xi )

(
x

x
)(
x

x
)
(
x

x
)
( x  xi )
i
n 
 i 1 i 2
 i ( x)  

Ex: (n=3)
Page 7
Pn ( x)
1
Pn( xi ) ( x  xi )
1 ( x) 
( x  x1 )( x  x2 )( x  x3 ) ( x  x2 )( x  x3 )
1

( x1  x2 )( x1  x3 )
( x  x1 )
( x1  x2 )( x1  x3 )
 2 ( x) 
( x  x1 )( x  x2 )( x  x3 )
( x  x1 )( x  x3 )
1

( x2  x1 )( x2  x3 )
( x  x2 )
( x2  x1 )( x2  x3 )
 3 ( x) 
( x  x1 )( x  x2 )( x  x3 ) ( x  x1 )( x  x2 )
1

( x3  x1 )( x3  x2 )
( x  x3 )
( x3  x1 )( x3  x2 )
計算機在工程上的應用 (JWLee)
2010/3/11
Gaussian quadrature
n
I   f ( x)dx  wi f ( xi )
1
1
i 1
n
Let:f ( x)   f ( x ) L ( x)
i
i 1
Li ( x) 
where
Pn ( x)
1
Pn( xi ) ( x  xi )
i
(Lagrange polynomial)
f ( x)
n
 I   f ( x)dx  wi f ( xi )
1
1

1
1
n
 f ( x ) L( x )
i 0
n
i 1
Pn ( x)
1
i
i
 f ( x ) P( x ) ( x  x ) dx
i 1
i
n
i
i
1 P ( x)
 1

n

dx
 f ( xi )

1 ( x  x )

P
(
x
)
i
 n i

1 P ( x)
1
n
 wi 
dx


1
Pn( xi ) ( x  xi )
Page 8
x0
計算機在工程上的應用 (JWLee)
xi
xn
2010/3/11
Weighting coefficients w
and associated points x
i
i
Number of points
n
Weighting coefficients Associated points
xi
wi
8
9
5
9
3
4
n
w
i 1
Page 9
i
2
0.774596669
0.6521451549
0.3399810436
0.3478548451
0.8611363116
0.5688888888
5
0
0
0.4786286705
0.5384693101
0.2369268851
0.9061798459
Because the integral interval is from -1 to 1.
計算機在工程上的應用 (JWLee)
2010/3/11
The general integral interval (a,b)
b
I   f ( x)dx
a
b  s
1
 r  1
s
1
1
  
 a 

 
 b 
a

s
r
1

1
  
  

 1
 r
t 
 x  rt  s
xs

r
dx  rdt
b
1
1
a
1
1
b
n
n
a
i 1
i 1
 I   f ( x)dx  r  f (rt  s)dt  r  F (t )dt
I   f ( x)dx  r  wi f (rti  s )  r  wi F (ti )
Page 10
計算機在工程上的應用 (JWLee)
2010/3/11
Numerical examples
Ex: 1
f1 ( x)  x7  100x6  x4  x2  1
f1 ( x)
is a polynomial degree of 7
2n  1  7
I1  1 ( x 7  100 x 6  x 4  x 2  1)dx
1
n  4
1
Exact
 1 8 100 7 1 5 1 3

I

solution: 1  8 x  7 x  5 x  3 x  x   31.6381
1
Number of points
 w f (x )
5
31.6381
4
31.6381
3
27.0667
2
10.2963
n
Page 11
n
i 1
i 1
i
計算機在工程上的應用 (JWLee)
2010/3/11
Numerical examples
Ex: 2
f 2 ( x)  x2e3 x
I 2  1 x 2e3 x dx
1
1
Exact
1
solution: I 2   e3 x  9 x 2  6 x  2   3.6882
 27
 1
Number of points
n
Page 12
n
 w f (x )
i 1
i
i
5
3.6881
4
3.6876
3
3.6716
2
3.4374
計算機在工程上的應用 (JWLee)
2010/3/11
Numerical examples
Ex: 3
f3 ( x)  x2 sin( x)
2
1 1 1 5
1 5
I 3  2 x sin( x)dx  1  t   sin  t   dt
2 2 2
2 2
3
Exact
2
3
solution:I3  2 x sin( x)  ( x 2  2)cos( x)   3.3072
2
Number of points
Page 13
n
n 1
 w f (x )
5
3.3072
4
3.3072
3
3.6716
2
3.3043
i 1
i
i
計算機在工程上的應用 (JWLee)
2010/3/11
Fortran program
Page 14
計算機在工程上的應用 (JWLee)
2010/3/11
Fortran program
Page 15
計算機在工程上的應用 (JWLee)
2010/3/11
The end
Thanks for your kind attentions
Page 16
計算機在工程上的應用 (JWLee)
2010/3/11
Gaussian quadrature
N
I   f ( x)dx  wi f ( xi )
1
1
i 1
f (x) is the polynomial of degree 2n-1 or less
f ( x)  Pn ( x)Qn 1 ( x)  Rn 1 ( x)
n 1
  i Pi ( x) Pn ( x)  Rn 1 ( x)
i 0
N
I   wi f ( xi )
1
I   f ( x)dx
i 1
1
n 1
   i  Pi ( x) Pn ( x)dx   Rn 1 ( x )dx
i 0
1
1
1
1
i 1
i 1
  wi Qn 1 ( xi ) Pn ( xi )   wi Rn 1 ( xi )
  wi Rn 1 ( xi )
1
( x1 ,..., xn )
N
N
  Rn 1 ( x)dx
1
N
N n
i 1
are the zeros of Legendre polynomial
Pn ( x)  0
Therefore the integral can be obtained by using n points
Page 17
計算機在工程上的應用 (JWLee)
2010/3/11