You are on page 1of 6

Elementos Finitos en Ingenieria Civil

ORIGIN 1

Overview
A wide variety of techniques may be used to numerically evaluate integrals (e.g., Trapezoidal integration,
Simpson's Rule, etc.). All of these methods require that the function under consideration be evaluated at
various sampling locations. Gauss quadrature is an integration technique that utilizes optimally chosen
sampling locations to minimize the number of function evaluations that need to be performed. This results
in a method that is both numerically efficient and highly accurate.
In this basic form, Gauss quadrature permits a function f ( ) to be integrated from -1 to +1 using a
summation of weighted function evaluations. When a function is constructed such that only coordinates
in the range = [-1,+1] are of interest, the function is said to be written in terms of a "natural"
coordinate, . In such cases, integration is performed as follows.

f ( ) dx =
1

( wp f ( p ) )

p =1

p are function sampling locations (Gauss points), wp are weighting factors, and n is the number of Gauss
integration points. If integration of a general function f ( x) is required, where x may vary over an
arbitrary range of values from xi (initial) to xf (final), then a modified version of Gauss quadrature may
be used, as shown below. In the expression below, each Gauss point is mapped to a corresponding
coordinate x( ) so that the function f ( x) = f ( x( ) ) may be evaluated (sampled) at the mapped Gauss
dx
points. Additionally, a scaling factor J =
is required in order to correct for the differences in range
d
of the independent variables x and . The variable x ranges from xi to xf whereas the variable ranges
from -1 to +1, or a total distance of 2.

f
f ( x ) dx = J
x
i

( w p f ( x( p ) ) ) =

p =1

( xf xi)
2

p =1

xf + xi xf xi
wp f
+

2 2 p

1 of 6

Ilustrative example: natural coordinate

Consider a function f ( )
3

f ( ) := 81 + 90 + 39 + 65
Plot the function from -1 to +1

i := 1

f := 1

n := 201

inc := ( f i ) ( n 1)

i := 1 .. n

:= i + inc ( i 1)
i

300

200

f ( i)
100

1.2

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

Assume that we wish to integrate the function f ( ) in the natural coordinate system from -1 to +1
1

3
2
I = 81 + 90 + 39 + 65 d
1
That is, we wish to find the area under the curve shown below
300

200

f ( i)
100

1.2

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

Use Mathcad's built-in symbolic integration capabilities to exactly compute the value of the integral
1

3
2
I := 81 + 90 + 39 + 65 d
1
I 190
2 of 6

w1 := 2

1 := 0

f1 := f ( 1 )

I := w1 f1

f1 = 65

I = 130

not exact: insufficient Gauss

points used to compute integral

300

f ( i)

200

f1
100

1.2

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

i , 1

number of gauss points n := 2

maximum degree for exact integration 2n 1 = 3

w1 := 1

w2 := 1

1 :=

2 :=

1 = 0.577

2 = 0.577

f1 := f ( 1 )

f1 = 56.895

Weight the sampled function values and sum

f2 := f ( 2 )

f2 = 133.105

I := w1 f1 + w2 f2

I = 190

300

f ( i) 200
f1
f2

100

1.2

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

i , 1 , 2

3 of 6

number of gauss points n := 3

maximum degree for exact integration 2n 1 = 5

w1 :=

w2 :=

Evaluate the
f1 := f ( 1 )
f2 := f ( 2 )
f3 := f ( 3 )

8
9

w3 :=

1 :=

2 := 0

3 :=

f1 = 51.145
f2 = 65
f3 = 186.855

3
5

Weight the sampled function values and sum

I := w1 f1 + w2 f2 + w3 f3

I = 190

300

f ( i)
200

f1
f2
f3

100

1.2

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

i , 1 , 2 , 3

number of gauss points n := 4

maximum degree for exact integration 2n 1 = 7

w1 :=

1 :=

49

6 ( 18 +

w2 :=

30)

15 + 2 30

2 :=

49

6 ( 18

30)

15 2 30

35

Evaluate the
f1 := f ( 1 )
f2 := f ( 2 )
f3 := f ( 3 )
f4 := f ( 4 )

w3 :=

49

6 ( 18

w4 :=

30)

15 2 30

3 :=

35

4 :=

35

f1 = 46.431
f2 = 58.96
f3 = 91.845
f4 = 217.049

49

6 ( 18 +

30)

15 + 2 30
35

Weight the sampled function values and sum

I := w1 f1 + w2 f2 + w3 f3 + w4 f4

I = 190

300

f ( i)
f1

200

f2
f3

100

f4

1.2

0.8

0.6

0.4

0.2

0.2

0.4

0.6

0.8

1.2

i , 1 , 2 , 3 , 4
4 of 6

Ilustrative example: general coordinate

Consider integration of a more general function written in terms of an arbitrary coordinate x
3

f ( x) := 3 x + x + 2 x + 59
Range of interest (initial and final values)
xi := 2

xf := 4

n := 201

inc := ( xf xi) ( n 1)

i := 1 .. n

x := xi + inc ( i 1)
i

300

200

f ( xi)
100

2.2 1.8 1.4

0.6 0.2

0.2

0.6

1.4

1.8

2.2

2.6

3.4

3.8

4.2

xi

Use Mathcad's built-in symbolic integration capabilities to exactly compute the value of the integral

I :=

xf
3

3 x + x + 2 x + 59 dx

I 570

xi

number of gauss points n := 2

maximum degree for exact integration 2n 1 = 3

w1 := 1

w2 := 1

1 :=

2 :=

1
3

Form a function that maps from coordinates onto x coordinates

xf + xi xf xi
tox ( ) :=
+

xf + xi = 1
2

xf xi
f i

midpoint of x-range

= 0 midpoint of -range

4 2

6
= 2 = 3

1 1

Check the mapping

check := 1

tox ( check ) = 2

check := 1

tox ( check ) = 4

1 = 0.577

x1 := tox ( 1 )

x1 = 0.732

2 = 0.577

x2 := tox ( 2 )

x2 = 2.732
5 of 6

Evaluate (sample) the function f ( x) at the mapped integration locations

3

f1 := f ( x1)

f1 = 56.895

ff ( ) := 81 + 90 + 39 + 65

f2 := f ( x2)

f2 = 133.105

ff1 := ff ( 1 ) = 56.895
ff2 := ff ( 2 ) = 133.105

300

f(i)

200

100

1.2

0.9

0.6

0.3

0.3

0.6

0.9

1.2

3.7

4.6

i,1,2

1 = 0.577

2 = 0.577

onto the x domain [ xi, xf]

300

f(xi)

200

100

2.6

1.7

0.8

0.1

1.9

2.8

xi,x1,x2

x1 = 0.732

x2 = 2.732

Calculate the scaling factor produced by changing the integration variable from to x (Jacobian)
J :=

xf xi
f i

J =3

where

dx = J d

Weight the sampled function values and sum

I := J ( w1 f1 + w2 f2 )

I = 570

6 of 6