Lecture -5
Numerical Integration
FEM Dr. Riessom 1
Axially loaded Bar
y A(x) = cross section at x
b(x) = body force
F distribution (force per unit
x
x
length)
x=0 x=L E(x) = Young’s modulus
x1 x2
For each element 1 2
Element stiffness matrix
x2
d1x d2x
kij Bi EB j Adx
x2
k B EB Adx
T
x1 x1
FEM Dr. Riessom 2
Linear Finite Element
x1
x2
B EB Adx
T 1
x 2 x1
2
1 1 x2
1 1 x1 AEdx
x1
x2
AEdx x x
2
1
1
2
1 1
1 1
Element nodal load vector
x2 x2
f b N b dx f b i N i b dx
T
x1 x1
How do we compute these integrals using a computer?
Any integral from x1 to x2 can be transformed to the
following integral on (-1, 1)
FEM Dr. Riessom 3
Numerical Integration
1
I f ( ) d
1
Use the following change of variables
1 1
x x1 x2
2 2
Goal: Obtain a good approximate value of this integral
1. Newton-Cotes Schemes (trapezoidal rule, Simpson’s rule,
etc)
2. Gauss Integration Schemes
NOTE: Integration schemes in 1D are referred to as
“quadrature rules”
FEM Dr. Riessom 4
Trapezoidal Rule
Approximate the function f(x) by a straight line g(x) that
passes through the end points and integrate the straight
line
g f1
f1
f
-1 1
1 1
g ( ) f (1) f (1)
2 2
1 1
I f ( ) d g ( ) d f (1) f (1)
1 1
FEM Dr. Riessom 5
Trapezoidal Rule Continued…
•Requires the function f(x) to be evaluated at 2 points
(-1, 1)
• Constants and linear functions are exactly integrated
• Not good for quadratic and higher order polynomials
How can I make this better?
Simpson’s rule
Approximate the function f(x) by a parabola g(x) that
passes through the end points and through f(0) and
integrate the parabola
FEM Dr. Riessom 6
Simpson’s Rule
g f1
f
f1
f(0
-1 1
( 1) (1 )
g ( ) f (1) (1 )(1 ) f (0) f (1)
2 2
1 1 1 4 1
I f ( ) d g ( ) d f (1) f (0) f (1)
1 1 3 3 3
Requires the function f(x) to be evaluated at 3 points (-1,0, 1)
Constants, linear functions and parabolas are exactly integrated
Not good for cubic and higher order polynomials
FEM Dr. Riessom 7
Simpson’s Rule Continued…
M
I f ( ) d Wi f ( i )
1
1
i 1
Weight Integration point
Trapezoidal rule:
W1 1 1 1 Accurate for polynomial of
M=2 degree at most 1 (=M-1)
W2 1 2 1
Simpson’s rule: W1 1 / 3 1 1 Accurate for polynomial of
M=3 W2 4 / 3 2 0 degree at most 2 (=M-1)
W2 1 / 3 2 1
Notice that both the integration formulas had the general form
FEM Dr. Riessom 8
Newton-Cotes
Generalization of these two integration rules
Divide the interval (-1,1) into M-1 equal intervals using M
points
Pass a polynomial of degree M-1 through these M points (the
value of this polynomial will be equal to the value of the
function at these M-1 points)
Integrate this polynomial to obtain an approximate value of the
integral With ‘M’ points we may
f1
f integrate a polynomial of
degree ‘M-1’ exactly.
f1 With ‘M’ integration points
g and ‘M’ weights, I should be
able to integrate a polynomial
-1 1 of degree 2M-1 exactly!!
FEM Dr. Riessom 9
Gaussian Quadrature
To evaluate the integral:
Where y = y(x), we might choose (sample or evaluate) y at
the midpoint y(0) = y1 and multiply by the length of the
interval, as shown below to arrive at I = 2y1, a result that is
exact if the curve happens to be a straight line.
M
I f ( ) d Wi f ( i )
1
1
i 1
Weight Integration point
FEM Dr. Riessom 10
Generalization of the formula leads to:
That is, to approximate the integral, we evaluate the
function at several sampling points n, multiply each
value yi by the appropriate weight Wi , and add the terms.
Gauss's method chooses the sampling points so that for a
given number of points, the best possible accuracy is
obtained.
Sampling points are located symmetrically with respect to
the centre of the interval.
FEM Dr. Riessom 11
In general, Gaussian quadrature using n points (Gauss points)
is exact if the integrand is a polynomial of degree 2n - 1 or
less.
In using n points, we effectively replace the given function y =
f(x) by a polynomial of degree 2n- 1.
The accuracy of the numerical integration depends on how
well the polynomial fits the given curve.
If the function f(x) is not a polynomial, Gaussian quadrature
is inexact, but it becomes more accurate as more Gauss
points are used.
Also, it is important to understand that the ratio of two
polynomials is, in general, not a polynomial; therefore,
Gaussian quadrature will not yield exact integration of the
ratio.
FEM Dr. Riessom 12
To illustrate the derivation of a two-point (n = 2) consider:
There are four unknown parameters to determine: W1, W2,
x1, and x2.
Therefore, we assume a cubic function for y as follows:
In general, with four parameters in the two-point formula,
we would expect the Gauss formula to exactly predict the
area under the curve.
FEM Dr. Riessom 13
However, we will assume, based on Gauss's method, that W1 =
W2 and that x1 = x2 as we use two symmetrically located
Gauss points at x = ±a with equal weights.
The area predicted by Gauss's formula is
If the error, e = A - AG, is to vanish for any C0 and C2, we
must have, in the error expression:
Now W = 1 and a = 0.5773 ... are the Wi’s and ai’s (xi’s) for
the two-point Gaussian quadrature as given in the table.
FEM Dr. Riessom 14
Example
Use three-point Gaussian Quadrature evaluate the integrals:
FEM Dr. Riessom 15
Gauss Integration
m Gauss Point j Gauss Weight wj Accuracy order n
1 0 2 1
2 -1/3, 1/3 1, 1 3
3 -0.6, 0, 0.6 5/9, 8/9, 5/9 5
4 -0.861136, -0.339981, 0.347855, 0.652145, 7
0.339981, 0.861136 0.652145, 0.347855
5 -0.906180, -0.538469, 0, 0.236927, 0.478629, 9
0.538469, 0.906180 0.568889, 0.478629,
0.236927
6 -0.932470, -0.661209, 0.171324, 0.360762, 11
-0.238619, 0.238619, 0.467914, 0.467914,
0.661209, 0.932470 0.360762, 0.171324
FEM Dr. Riessom 16
In two dimensions, we obtain the quadrature formula by
integrating first with respect to one coordinate and then
with respect to the other as
In three dimensions, we obtain the quadrature formula by
integrating first with respect to one coordinate and then
with respect to the other two as
FEM Dr. Riessom 17
Example: M=1 (Midpoint Qudrature)
1
I f ( ) d W1 f (1 )
1
How can we choose W1 and x1 so that we may integrate
a (2M-1=1) linear polynomial exactly?
f ( ) a0 a1
1
1
f ( ) d 2a0
But we want
1
1
f ( ) d W1 f (1 ) a0W1 a0W1
FEM Dr. Riessom 18
Hence, we obtain the identity
2a0 a0W1 a1W11
For this to hold for arbitrary a0 and a1 we need to satisfy
2 conditions
Condition 1 : W1 2
Condition 2 : W11 0
i.e.,
W1 2; 1 0
FEM Dr. Riessom 19
For M=1 1
I f ( ) d 2 f (0)
1
f
f0
g
-1 1
Midpoint quadrature rule:
• Only one evaluation of f(x) is required at the midpoint
of the interval.
• Scheme is accurate for constants and linear
polynomials (compare with Trapezoidal rule)
FEM Dr. Riessom 20
Example: M=2
1
I f ( ) d W1 f (1 ) W2 f ( 2 )
1
How can we choose W1 ,W2 x1 and x2 so that we may
integrate a polynomial of degree (2M-1=4-1=3)
exactly?
f ( ) a0 a1 a2 2 a3 3
1 2
1 f ( ) d 2a0 3 a2
But we want
1
1
f ( ) d W1 f (1 ) W2 f ( 2 )
2 2
a0 W1 W2 a1 W11 W2 2 a2 W11 W2 2 a3 W11 W2 2
3 3
FEM Dr. Riessom 21
Hence, we obtain the 4 conditions to determine the 4
unknowns (W1 ,W2 x1 and x2 )
Condition 1 : W1 W2 2
Condition 2 : W11 W2 2 0
2
Condition 3 : W11 W2 2
2 2
3
Condition 4 : W11 W2 2 0
3 3
Check that the following is the solution
W1 W2 1
1 1
1 ; 2
3 3
FEM Dr. Riessom 22
For M=2
1 1 1
I f ( ) d f ( ) f( )
1
3 3
1 1
f ( ) f( )
3 3
f
-1
* * 1
Only two evaluations of f(x) is required.
Scheme is accurate for polynomials of degree at most 3
(compare with Simpson’s rule)
FEM Dr. Riessom 23
Stiffness Matrix by Gaussian
Quadrature
For the two-dimensional element, we have shown in previous
chapters that
Where, in general, the integrand is a function of x and y and
nodal coordinate values.
For a quadrilateral element can be evaluated in terms of a local
set of coordinates s-t, with limits from -1 to 1within the
element.
Each coefficient of the integrand [B]T [D] [B] |[J]|
evaluated by numerical integration in the same manner
as f(s, t) was integrated.
FEM Dr. Riessom 24
In FEM we always use Gauss
quadrature 2
1
Linear Element
Stiffness matrix 1 1
1
1
T 1 1 1 1
k B EB Ad
4 1 1 1
AEd 1
1 1 1
1 AEd 4 1 1
Nodal load vector
1
1
f b N b d
T f b i N i b d
1
1
Usually a 2-point Gauss integration is used. Note that if
A, E and b are complex functions of x, they will not be
accurately integrated
FEM Dr. Riessom 25
Quadratic Element
1 2 3
Nodal shape functions
1 0 1
N1 ( ) 1
2
N 2 ( ) 1 2
You should be able to derive these!
N 3 ( ) 1
2
Stiffness matrix
1 1
k B EB Ad AE B B d
T T
1 1
Assuming E and A are constants
d N dN1 dN 2 dN3 1
2 1
1
B 2 1 2
d d d d 2 2
FEM Dr. Riessom 26
Quadratic Element Continued…
1 1
k B EB Ad AE B B d
T T
1 1
1
1/ 2 2 2 1/ 2
2 1/ 4
AE 2 1/ 2 4 2
2 1/ 2 d
1
1/ 4
2
2 1/ 2 1/ 2
2
Need to exactly integrate quadratic terms. Hence we
need a 2-point Gauss quadrature scheme.. Why?
FEM Dr. Riessom 27
Example
f
f 1/ 3
f 1/ 3
-1 1 / 3 1/ 3 1
A 2-point Gauss quadrature rule
1 1 1
1
f ( ) d f (
3
) f (
3
)
is exact for a polynomial of degree 3 or less
FEM Dr. Riessom 28
1 1
2D
t
Square Domain 1 1
1 1 ,
, 3 3
3 3
1
1 1
s I f (s, t ) dsdt
1 1
1
1 1 1 1
, ,
3 3 3 3
1 1
I f ( s, t ) dsdt
1 1
M
W j f ( s, t j ) ds Using 1D Gauss rule to integrate along ‘t’
1
1
j 1
M M
WiW j f ( si , t j ) Using 1D Gauss rule to integrate along ‘s’
i 1 j 1
M M
Wij f ( si , t j ) Where Wij =Wi Wj
i 1 j 1
FEM Dr. Riessom 29
The Rule
M M
f ( s, t ) dsdt Wij f ( si , t j )
1 1
I
1 1
i 1 j 1
Uses M2 integration points on a non-uniform grid
inside the parent element and is exact for a polynomial
of degree (2M-1) i.e.,
exact M M
Wij si t j
1 1
s t dsdt for 2M 1
1 1
i 1 j 1
A M2 –point rule is exact for a complete polynomial of
degree (2M-1)
FEM Dr. Riessom 30
CASE II: M=2 (2x2 GQ rule)
t 1 1
1 1 1 1 ,
, 3 3
3 3
1
s
1
1 1 1 1
, ,
3 3 3 3
2 2
I Wij f ( si , t j )
i 1 j 1
1 1 1 1 1 1 1 1
f( , ) f ( , ) f ( , ) f( , )
3 3 3 3 3 3 3 3
is exact for a product of two cubic polynomials
FEM Dr. Riessom 31
CASE III: M=3 (3x3 GQ rule)
t
1 1
64
3 6 2 W1 ,
1 3
81
7 1 9 5 25
3
s W2 W3 W4 W5
81
1 4 8 5 5
40
W6 W7 W8 W9
3 3 81
5 5
3 3
f ( s, t ) dsdt Wij f ( si , t j )
1 1
I
1 1
i 1 j 1
is exact for a product of two 1D polynomials of degree 5
FEM Dr. Riessom 32
Examples
If f(s,t)=1
1 1
I f ( s, t ) dsdt 4
1 1
A 1-point GQ scheme is sufficient
If f(s,t)=s
1 1
I f ( s, t ) dsdt 0
1 1
A 1-point GQ scheme is sufficient
If f(s,t)=s2t2
1 1 4
I f ( s, t ) dsdt
1 1 9
A 3x3 GQ scheme is sufficient
FEM Dr. Riessom 33
2D Gauss quadrature for
Triangular Domains
Remember that the parent element is a right angled
triangle with unit sides
t The type of integral encountered
1 1t
I f ( s, t ) dsdt
1 t 0 s 0
t 1 1t
s=1-t t s
I f ( s, t ) dsdt
t 0 s 0
M
WIP f IP
1
IP 1
FEM Dr. Riessom 34