Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

CE 30125 - Lecture 16

LECTURE 16
GAUSS QUADRATURE
• In general for Newton-Cotes (equispaced interpolation points/ data points/ integration
points/ nodes).
xE

 f  x  dx = h  w'o f o + w'1 f 1 +  + w'N f N  + E


xS

84

fN
f0

f2
f1 closed formula

xs = x0 x1 x2 xE = xN
h

• Note that for Newton-Cotes formulae only the weighting coefficients w i were unknown
and the x i were fixed

p. 16.1
CE 30125 - Lecture 16

• However the number of and placement of the integration points influences the accuracy
of the Newton-Cotes formulae:
• N even  N th degree interpolation function exactly integrates an N + 1 th degree poly-
nomial  This is due to the placement of one of the data points.
• N odd  N th degree interpolation function exactly integrates an N th degree polyno-
mial.

• Concept: Let’s allow the placement of the integration points to vary such that we
further increase the degree of the polynomial we can integrate exactly for a given
number of integration points.

• In fact we can integrate an 2N + 1 degree polynomial exactly with only N + 1 integra-


tion points

p. 16.2
CE 30125 - Lecture 16

• Assume that for Gauss Quadrature the form of the integration rule is
xE
x S
f  x  dx =  w o f o + w 1 f 1 +  + w N f N  + E

85

fN
f0
f3
f1
f2

xs x0 x1 x2 x3 xN xE

• In deriving (not applying) these integration formulae


• Location of the integration points, x i i = O N are unknown

• Integration formulae weights, w i i = O N are unknown

• 2  N + 1  unknowns  we will be able to exactly integrate any 2N + 1 degree polyno-


mial!

p. 16.3
CE 30125 - Lecture 16

Derivation of Gauss Quadrature by Integrating Exact Polynomials and Matching

Derive 1 point Gauss-Quadrature


• 2 unknowns w o , x o which will exactly integrate any linear function

• Let the general polynomial be


f  x  = Ax + B

where the coefficients A B can equal any value

• Also consider the integration interval to be  – 1 + 1  such that x S = – 1 and x E = + 1 (no


loss in generality since we can always transform coordinates).
+1

 f  x  dx = w o f  xo 
–1

• Substituting in the form of f  x 


+1

  Ax + B  dx = w o  Ax o + B  
–1

p. 16.4
CE 30125 - Lecture 16

+1
x2
A ----- + Bx = w o  Ax o + B  
2 –1

A  0  + B  2  = A  xo wo  + B  wo 

• In order for this to be true for any 1st degree polynomial (i.e. any A and B ).

 0 = xo wo

 2 = wo

• Therefore x o = 0 , w o = 2 for 1 point  N = 1  Gauss Quadrature.


86

f0
f(x)

-1 x0 +1

• We can integrate exactly with only 1 point for a linear function while for Newton-Cotes
we needed two points!

p. 16.5
CE 30125 - Lecture 16

Derive a 2 point Gauss Quadrature Formula


87

-1 x0 x1 +1

• The general form of the integration formula is

I = wo fo + w1 f1

• w o , x o , w 1 , x 1 are all unknowns

• 4 unknowns  we can fit a 3rd degree polynomial exactly

f  x  = Ax 3 + Bx 2 + Cx + D

• Substituting in for f  x  into the general form of the integration rule


+1

 f  x  dx = wo f  xo  + w1 f  x1 
–1



p. 16.6
CE 30125 - Lecture 16

+1
3
  Ax 3 + Bx 2 + Cx + D  dx = w o  Ax o + Bx 2o + Cx o + D  + w 1  Ax 13 + Bx 21 + Cx 1 + D 
–1

+1
Ax 4 Bx 3 Cx 2
--------- + --------- + --------- + Dx = w o  Ax o3 + Bx 2o + Cx o + D  + w 1  Ax 13 + Bx 21 + Cx 1 + D 
4 3 2 –1



2
A  w o x o3 + w 1 x 31  + B w o x 2o + w 1 x 12 – --- + C  w o x o + w 1 x 1  + D  w o + w 1 – 2  = 0
3

• In order for this to be true for any third degree polynomial (i.e. all arbitrary coefficients,
A , B , C , D ), we must have:

w o x o3 + w 1 x 31 = 0

2
w o x o2 + w 1 x 21 – --- = 0
3

wo xo + w1 x1 = 0

wo + w1 – 2 = 0

p. 16.7
CE 30125 - Lecture 16

• 4 nonlinear equations  4 unknowns

w o = 1 and w 1 = 1

1 1
x o = – --- and x 1 = + ---
3 3

• All polynomials of degree 3 or less will be exactly integrated with a Gauss-Legendre 2


point formula.

p. 16.8
CE 30125 - Lecture 16

Gauss Legendre Formulae

+1 N

I =  f  x  dx =  wi fi + E
–1 i=0

xi , Exact for
N N+1 wi polynomials of
i = 0 N degree
0 1 0 2 1
1 2 1 1 1, 1 3
– --- , + ---
3 3
2 3 -0.774597, 0, 0.5555, 0.8889, 5
+0.774597 0.5555
N N+1 2N + 1

p. 16.9
CE 30125 - Lecture 16

xi , Exact for
N N+1 wi polynomials of
i = 0 N degree
3 4 -0.86113631 0.34785485 7
-0.33998104 0.65214515
0.33998104 0.65214515
0.86113631 0.34785485
4 5 -0.90617985 0.23692689 9
-0.53846931 0.47862867
0.00000000 0.56888889
0.53846931 0.47862867
0.90617985 0.23692689
5 6 -0.93246951 0.17132449 11
-0.66120939 0.36076157
-0.23861919 0.46791393
0.23861919 0.46791393
0.66120939 0.36076157
0.93246951 0.17132449

p. 16.10
CE 30125 - Lecture 16

• Notes
• N + 1 = the number of integration points

• Integration points are symmetrical on  – 1 +1 

• Formulae can be applied on any interval using a coordinatetransformation

• N + 1 integration points  will integrate polynomials of up to degree 2N + 1 exactly.

• Recall that Newton Cotes  N + 1 integration points only integrates an


N th /N + 1 th degree polynomial exactly depending on N being odd or even.

• For Gauss-Legendre integration, we allowed both weights and integration point


locations to vary to match an integral exactly  more d.o.f.  allows you to
match a higher degree polynomial!

• An alternative way of looking at Gauss-Legendre integration formulae is that we


use Hermite interpolation instead of Lagrange interpolation! (How can this be
since Hermite interpolation involves derivatives  let’s examine this!)

p. 16.11
CE 30125 - Lecture 16

Derivation of Gauss Quadrature by Integrating Hermite Interpolating Functions

Hermite interpolation formulae

• Hermite interpolation which matches the function and the first derivative at N + 1 inter-
polation points is expressed as:
N N
1
gx =  i  x fi +   i  x fi
i=0 i=0
88

(1) (1) (1) (1) (1) (1) (1)


f0 f0 f1 f1 f2 f2 f3 f3 f4 f4 f5 f5 fN fN

0 1 2 3 4 5 N
x0 x1 x2 x3 x4 x5 xN

• It can be shown that in general for non-equispaced points

 i  x  = t i  x l iN  x l iN  x  i = 0 N

 i  x  = s i  x l iN  x l iN  x  i = 0 N

p. 16.12
CE 30125 - Lecture 16

where

pN  x    x – xo   x – x1    x – xN 

p x
N
l iN  x   --------------------------------------
- i = 0 N
1
 x – x i p  x i 
N

1
t i  x   1 –  x – x i  2 l iN  x i 

si  x    x – xi 

p. 16.13
CE 30125 - Lecture 16

Example of defining a cubic Hermite interpolating function

• Derive Hermite interpolating functions for 2 interpolation points located at – 1 and + 1


for the interval  – 1 + 1  .
89

(1)
f0 f0 (1)
f1 f1
x
x0 = 1 x1 = +1

N + 1 = 2 points  N = 1

• Establish p N  x 

p  x  =  x – xo   x – x1  
1

p 1  x  =  x – x o  +  x – x 1 
1

p. 16.14
CE 30125 - Lecture 16

• Establish l iN  x 

p1 x 
l i1  x  = ----------------------------------------
1
-
 x – xi   p1  xi  

 x – xo   x – x1 
l i1  x  = ---------------------------------------------------------------------
 x – xi    xi – xo  +  xi – x1  

• Let i = 0
 x – xo   x – x1 
l o1  x  = ------------------------------------------------------ 
 x – xo   0 +  xo – x1  

x – x1
l o1  x  = ----------------
xo – x1

• Substitute in x o = – 1 and x 1 = + 1

1
l o1  x  = ---  1 – x 
2

p. 16.15
CE 30125 - Lecture 16

• Let i = 1

 x – xo   x – x1 
l 11  x  = ------------------------------------------------------
 x – x1    x1 – xo  + 0 

• Substitute in values for x o , x 1

1
l 11  x  = ---  1 + x 
2

• Taking derivatives

1 1
lo1  x  = – ---
2

1 1
l  x  = + ----
11 2

p. 16.16
CE 30125 - Lecture 16

• Establish t i  x 

1
t o  x  = 1 –  x – x o 2lo1  x o  

1
to  x  = 1 – x + 1   2   – --- 
 2

to  x  = 2 + x

1
t 1  x  = 1 –  x – x 1  2 l11  x 1  

1
t 1  x  = 1 –  x – 1   2  --- 
 2

t1  x  = 2 – x

• Establish s i  x 

so  x  = x + 1

s1  x  = x – 1

p. 16.17
CE 30125 - Lecture 16

• Establish  i  x 

 o  x  = t o  x l o1  x l o1  x  

1 1
 o  x  =  2 + x  ---  1 – x  ---  1 – x  
2 2

1
 o  x  = ---  2 – 3x + x 3 
4

 1  x  = t 1  x l 11  x l 11  x  

1 1
 1  x  =  2 – x  ---  1 + x  ---  1 + x  
2 2

1
 1  x  = ---  2 + 3x – x 3 
4

p. 16.18
CE 30125 - Lecture 16

• Establish  i  x 

 o  x  = s o  x l o1  x l o1  x  

1 1
 o  x  =  x + 1  ---  1 – x  ---  1 – x  
2 2

1
 o  x  = ---  1 – x – x 2 + x 3 
4

 1  x  = s 1  x l 11  x l 11  x  

1 1
 1  x  =  x – 1  ---  1 + x  ---  1 + x  
2 2

1
 1  x  = ---  – 1 – x + x 2 + x 3 
4

• In general

g  x  =  o  x  f o +  1  x  f 1 +  o  x  fo 1  +  1  x  f  1 
1

p. 16.19
CE 30125 - Lecture 16

90
(1)
i(x) i (x)
1(x)
0(x) (1)
1 (x)

x x
   
(1)
0 (x)
(1)
i(x) i (x)

0(x) (1)
0 1
(1)

x x
   
1(x)

• These functions satisfy the constraints


1 
 i  x j  =  ij i  x j  = 0
1
i xj  = 0 i  x j  =  ij

p. 16.20
CE 30125 - Lecture 16

Gauss-Legendre Quadrature by integrating Hermite interpolating polynomials

+1 N

I =  f  x  dx =  wi fi + E
–1 i=0

• Notes
• Use  – 1 +1  without loss of generality we can always transform the interval.
• Approximation for I is exact for 2N + 1 degree polynomials

• We can derive all Gauss-Legendre quadrature formulae by approximating f  x  with an


2N + 1 th degree Hermite interpolating function using N specially selected integration/
interpolation points.
+1

I =  g  x  dx + E
–1

where
N N
1
gx =   i  x f i +   i  x f i
i=0 i=0

p. 16.21
CE 30125 - Lecture 16

• Thus
+1 N N
1
I=   i  x fi +  i  x fi dx + E
–1 i = 0 i=0


N N
1
I =  Ai fi +  Bi fi +E
i=0 i=0

where
+1 +1

Ai    i  x  dx and B i   i  x  dx
–1 –1

• Furthermore we can show that

+1 2
p N + 1  x   2N + 2 
E =  ----------------------- f
 2N + 2 !
 x o  + H.O.T. dx
–1

p. 16.22
CE 30125 - Lecture 16

• Note that we are assuming Taylor series expansions about x o and using higher order
terms in the expansion.
• Therefore E = 0 for any polynomial of degree 2N + 1 or less!

• The problem that we encounter is that the integration formula as it now stands in
general requires us to know both functional and first derivative values at the nodes!

• Let us select x o x 1 x 2 x N such that

Bi = 0 i = 0 N 

+1

  i  x  dx = 0 i = 0 N 
–1

+1

 si  x liN  x liN  x  dx = 0 i = 0 N 
–1

+1
pN  x 
  x – x i  -----------------------------------
1
 x – x i p N  x i 
- l iN  x  dx = 0 i = 0 N 
–1

p. 16.23
CE 30125 - Lecture 16

+1
1
-----------------
1
pN  xi 
-  pN  x liN  x  dx = 0 i = 0 N
–1

p N  x   polynomial of degree N + 1

l iN  x   polynomial of degree N

• Therefore we require p N  x  to be orthogonal on  – 1 +1  to all polynomials of degree N


or less  any multiple of Legendre-Polynomials will satisfy this.
• Let
2 N + 1   N + 1 !  2
p N  x  = ----------------------------------------- P N + 1  x 
 2  N + 1  !

where
p N  x  =  x – x o   x – x 1   x – x 2   x – x N 

P N + 1 = the Legendre polynomial of degree N + 1

2 N + 1   N + 1 !  2
----------------------------------------- is required to normalize the leading coefficient of P N + 1  x 
 2  N + 1  !

p. 16.24
CE 30125 - Lecture 16

• What have we done by defining p N  x  in this way  we have selected the integration/
interpolation/data points x o x 1 x N to be the roots of P N + 1  x  .

• In general

1 dn x2 – 1 n
P n  x  = ---------- --------------------------
-
2 n n! dx n

Po  x  = 1

P1  x  = x

1
P 2  x  = ---  3x 2 – 1 
2

1
P 3  x  = ---  5x 3 – 3x 
2
.
.
.

p. 16.25
CE 30125 - Lecture 16

• So far we have established


• Selecting p N  x  to be proportional to the Legendre Polynomial of degree N + 1 
this satisfies the orthogonality condition which will lead to:
+1

  i  x  dx = 0
–1

As a result fi 1  terms will not appear in the Gauss-Legendre integration formula.

• If we select p N  x  to be the Legendre Polynomial of degree N + 1  the roots of


that polynomial will represent the interpolating/integration/data points since
p N  x  =  x – x o   x – x 1   x – x N  has been set equal to CP N + 1  x 

• Now we must find the weights of the integration formula. Note that A i will represent the
weights!
+1

Ai    i  x  dx 
–1

p. 16.26
CE 30125 - Lecture 16

+1

Ai =  ti  x  liN  x  liN  x  dx
–1

where

1
t i  x  = 1 –  x – x i  2 l iN  x i 

pN  x 
l iN  x  = -----------------------------------
1
-
 x – xi  pN  xi 

p N  x  =  x – x o   x – x N 

and where x o  x N are the roots of the Legendre polynomial of degree N + 1 or

2 N + 1   N + 1 !  2
p N  x  = ----------------------------------------- P N + 1  x 
 2  N + 1  !

p. 16.27
CE 30125 - Lecture 16

Two point Gauss-Legendre integration

Develop a 2 point Gauss-Legendre integration formula for  – 1 +1  . Let


1 1
1 
gx =   i  x f i +   i  x f i
j=0 j=0

1 1
g  x  =  o  x f o +  1  x f 1 +  o  x f o +  1  x f 1

• Thus
+1

I =  g  x  dx + E 
–1

+1 +1 +1 +1
1  1
I =   o  x f o dx +   1  x f 1 dx +   o  x f o dx +   1  x f 1 dx 
–1 –1 –1 –1

+1 +1 +1 +1
1 1
I = f o   o  x  dx + f 1   1  x  dx + f o   o  x  dx + f 1   1  x  dx
–1 –1 –1 –1

p. 16.28
CE 30125 - Lecture 16

Step 1 - Establish interpolating points

• Interpolation points will be the roots of the Legendre Polynomial of order 2.

1
P 2  x  = ---  3x 2 – 1  
2

1
---  3x 2 – 1  = 0 
2

3x 2 = 1 

1
x 2 = --- 
3

1
x 0 1 =  --- 
3

x 0 1 =  0.57735

p. 16.29
CE 30125 - Lecture 16

• Checking these roots


1 d2 x2 – 1 2
P 2  x  = ---------- --------------------------
- 
2 2 2! dx 2

1 d2
P 2  x  = --- -------2-  x 4 – 2x 2 + 1  
8 dx

1
P 2  x  = ---  12x 2 – 4  
8

1
P 2  x  = ---  3x 2 – 1 
2

2 2  2!  2
p 1  x  = ------------------ P 2  x  
 2  2  !

44 1
p 1  x  = ------------------  ---  3x 2 – 1  
432 2

1
p 1  x  = x 2 – ---
3

p. 16.30
CE 30125 - Lecture 16

• From formula which defines p 1  x  using the integration points

1 1 1
p 1  x  =  x + ---  x – --- = x 2 – ---
 3  3 3

Step 2 - Establish the coefficients of the derivative terms in the integration formula

• Let’s demonstrate that with the roots x o 1 =  0.57735 we will satisfy

+1 +1

  o  x  dx = 0 and   1  x  dx = 0
–1 –1

1 
• First develop o x  and 1 x  by developing p 1  x , p 1  x , l o1  x , l 11  x ,
s o  x  and s 1  x 

p1  x  =  x – xo   x – x1 

1
p1  x  =  x – xo  +  x – x1 

p. 16.31
CE 30125 - Lecture 16

p1  x 
l j1  x  = --------------------------------------
- j = 0 1 
 x – x j p1 1  x j 

 x – xo   x – x1 
l j1  x  = ---------------------------------------------------------------------
 x – xj    xj – xo  +  xj – x1  

 x – xo   x – x1 
l o1  x  = -------------------------------------------------------------- 
 x – xo   xo – xo + xo – x1 

x – x1
l o1  x  = ----------------
xo – x1

 x – xo   x – x1 
l 11  x  = ------------------------------------------------------------------------ 
 x – x1    x1 – xo  +  x1 – x1  

x – xo
l 11  x  = ----------------
x1 – xo

p. 16.32
CE 30125 - Lecture 16

so  x  = x – xo

s1  x  = x – x1

• Now we can establish  o  x 

 o  x  = s o  x  l o1  x  l o1  x  

x – x1 x – x1
 o  x  =  x – x o   ----------------  ----------------
 x o – x 1  x o – x 1

1 1
• Noting that x o = – --- , x 1 = ---
3 3

 x – 1---  x – 1---
1  3  3
 o  x  =  x + --- ------------------------------------------
- 
 3 1 1 2
 – --- – ---
 3 3

3 1 1 1 3/2
 o  x  = --- x 3 – --- x 2 – --- x +  ---
4 3 3  3

p. 16.33
CE 30125 - Lecture 16

• Similarly for  1  x 

 1  x  = s 1  x  l 11  x  l 11  x  

 x – xo   x – xo 
 1  x  =  x – x 1  ---------------------  ---------------------
 x1 – xo   x1 – xo 

1 1
• Substituting x o = – --- , x 1 = ---
3 3

 x – 1---  x + 1---  x + 1---


 3  3  3
 1  x  = -----------------------------------------------------------------
2
- 
 1--- + 1---
 3 3

3 1 1 1 3/2
 1  x  = --- x 3 + --- x 2 – --- x –  ---
4 3 3  3

p. 16.34
CE 30125 - Lecture 16

+1
• Now we can develop –1 o  x  dx

+1 +1 3 1 2 1 1 3 / 2

– 1  o  x  d x = –1 --4- x3 – --- x – --- x + ---
3 3  3
dx 

+1 3 x 4  1 3 / 2 3 1 2  1 3 / 2 +1
– 1 o
  x  d x = --- ----- – ---
4 4  3
x – --- x + ---
6  3
x
–1

+1 3  1  1 3 / 2 1  1 3 / 2  1  1 3 / 2 1  1 3 / 2
– 1 o
  x  d x = --- --- – ---
4  4  3
– --- + --- – --- + ---
6  3   4  3
– --- – ---
6  3 

+1
–1 o  x  dx = 0

p. 16.35
CE 30125 - Lecture 16

+1
• Develop –1 1  x  dx

+1 +1 3 1 2 1 1 3 / 2

– 1  1  x  d x = –1 --4- x3 + --- x – --- x – ---
3 3  3
dx 

+1 3 x 4  1 3 / 2 3 1 2  1 3 / 2 +1
– 1 1
  x  d x = --- ----- + ---
4 4  3
x – --- x – ---
6  3
x
–1

+1 3  1  1 3 / 2 1  1 3 / 2  1  1 3 / 2 1  1 3 / 2
– 1 1
  x  d x = --- --- + ---
4  4  3
– --- – --- – --- – ---
6  3   4  3
– --- + ---
6  3 

+1
–1 1  x  dx = 0

p. 16.36
CE 30125 - Lecture 16

• Now our integration formula reduces to:


+1 +1
I = f o   o  x  dx + f 1   1  x  dx 
–1 –1

I = Ao fo + A1 f1

where
+1 +1
A o    o  x  dx and A 1    1  x  dx
–1 –1

Step 3 - Develop A o , A1

• Establish  o  x 

 o  x  = t o  x  l o1  x  l o1  x  

1
 o  x  =  1 –  x – x o 2l o1 x o  l o1  x l o1  x  

p. 16.37
CE 30125 - Lecture 16

 2  x – x1 x – x1
 o  x  =  1 –  x – x o  ----------------  ----------------  ---------------- 
 x o – x 1  x o – x 1  x o – x 1

   x – 1---  x – 1---
 1 2   3  3
 o  x  =  1 –  x + --- -------------------------  -------------------------------------------------------------- 
 3 1 1
 – --- – ---   – --- – ---  – --- – ---
1 1 1 1
 3 3  3 3  3 3

  
3 1  2  1 1
 o  x  = ---  1 –  x + ---  --------------  x 2 – 2 --- x + --- 
4  3  1  3 3
  – 2 --3- 

3 3 2  1 1
 o  x  = ----------  ------- + x  x 2 – 2 --- x + --- 
4  3  3 3

3  1 3/2 
 o  x  = --- 3  x 3 – x + 2  --- 
4   3

p. 16.38
CE 30125 - Lecture 16

+1
• Develop –1 o  x  dx

+1 +1 3  3 1 3/2
– 1  o  x  dx = –1 --- 3 x – x + 2  ---  dx 
4   3 

+1 3 x4 x2 3/2 +1
 1--- x
– 1 o
  x  d x = --
4
- 3 ----
-
4 2
– ----
- + 2
 3 –1

+1 3 3/2 3/2
 1--- – 1--- + 2  1---  –  1--- – 1--- – 2  1--- 
– 1 o
  x  d x = --
4
- 3
4 2  3   4 2  3 

+1 3  1 1
– 1 o
  x  d x = --- 3 4 --- ---
4  3 3

+1
– 1  o  x  d x = 1 

Ao = 1

p. 16.39
CE 30125 - Lecture 16

+1
• Similarly we can show that A 1 = – 1  1  x  d x = 1

• Thus we have established the two point Gauss Quadrature rule


+1
I = – 1 f  x  d x = wo fo + w1 f1

1 1
where x o = – --- and x 1 = + --- are the integration points and w o = w 1 = 1
3 3

• We note that this integration rule was established by defining a Hermite cubic interpo-
lating function and defining the integration points x o , x 1 such that

+1 +1
– 1  o  x  d x = 0 and – 1  1  x  d x = 0

• Therefore the functional derivative values drop out of the Gauss Legendre integra-
tion formula!

p. 16.40

You might also like