Vous êtes sur la page 1sur 13

Approximate solutions of

differential equations using


Galerkins method and
weighted residuals
J. PETROLITO, Division of Physical Sciences and Engineering, La
Trobe University, Bendigo, Bendigo, VIC 3550, Australia
j.petrolito@bendigo.latrobe.edu.au
To keep the discussion simple while maintaining a general formulation, we consider the
2. GOVERNING EQUATIONS
International Journal of Mechanical Engineering Education Vol 28 No 1
1. INTRODUCTION
The modern treatment of differential equations relies heavily on approximation methods to
solve problems of practical interest in engineering. Foremost among the methods used today
is the finite element method, which is now well-established in the undergraduate curriculum.
The method is commonly introduced via either an energy approach [1] or Galerkins method
[2]. Although the two methods are equivalent for self-adjoint problems, Galerkins method
can also be used for non self-adjoint problems [3]. Hence, it is preferred by some authors as
a basis for finite element methods. As the finite element method is commonly taught at the
undergraduate level, students need a clear understanding of Galerkins method.
Key features in the development of finite element theory using Galerkins method are the
used of integration by parts and the treatment of natural boundary conditions. However,
textbook treatments tend to be somewhat vague in these areas, and this can be a source of
confusion for students. In this paper, we show that the problems can be avoided by adopting
a weighted residual approach [4], and maintaining a general formulation throughout the
analysis. Such an approach is clearer, and avoids the ambiguities associated with the usual
formulation.
The usual textbook approach to Galerkins method can be misleading, and fails to highlight
all the possible errors that arise in an approximation scheme. A general weighted residual is
presented that explicitly excludes all possible errors. Thus all the inherent approximations
are made transparent to students. The conventional form of Galerkins method is shown to
be just one particular case of this method.
Received 8th July 1997
Revised 2nd November 1998
Untitled-4 10/2/00, 3:26 pm 14
International Journal of Mechanical Engineering Education Vol 28 No 1
Approximate solutions of differential equations using Galerkins method 15
model problem of an axially loaded bar, as shown in Fig. 1. The unknown variable is the
axial displacement, u(x). The governing differential equation is
E Au p x L + < < 0 0 , (1)
where EA is the axial stiffness of the bar and p(x) is the distributed load on the bar, which is
assumed to be a continuous function for simplicity, and a prime denotes differentiation with
respect to x. There are two boundary conditions associated with the problem, namely, the
essential boundary condition.
u(0) = 0 (2)
and the natural boundary condition
E Au L P ( ) (3)
3. GALERKINS METHOD
We now derive an approximation scheme based on Galerkins method following the usual
textbook approach.
Let w(x) be a continuous function that satisfies the condition w(0) = 0. We multiply
equation (1) by w(x) and integrate over the length of the bar to give
E Au p w x
L
+ ( )

d 0
0
(4)
Integrating the first term in equation (4) by parts gives
EAu w x EAu w EAu w x
L
L
L

[ ]


d d
0
0
0
(5)
Using equation (3) and noting that we assumed w(0) = 0, equations (4) and (5) give
pw E Au w x Pw L
L
( ) +

0
0 d ( ) (6)
Equation (6) is the virtual work theorem for the bar, with w(x) being interpreted as the virtual
displacement. The equation is true for the exact solution, u
ex
, coupled with all continuous
w(x) subject to w(0) = 0. Thus, the solution of equation (6) satisfies equations (1)(3) pro-
vided it is continuous.
Fig. 1. Sign convention for axially loaded bar.
Untitled-4 10/2/00, 3:27 pm 15
*
Integration by parts in the current context.

Natural boundary conditions in the current context.


We now use equation (6), which is true for the exact solution, as the basis for an
approximation scheme. Thus, for Galerkins method, we state the problem:
Find a function

( ) u x from a set of functions U(x) with

( ) u 0 0 such that
pw E Au w x Pw L
L

( )
+

( )
0
0 d (7)
for all w(x) from U(x) with w(0) = 0.
Equation (7) is the weak form of the problem [5], and is a more general version of the
original statement of the problem in equations (1)(3). In particular, equation (7) still makes
sense even if

( ) u x does not possess a second derivative. However, if the set U(x) includes
the exact solution, and the solution of equation (7) possesses a second derivative, then the
solution of equation (7) is also the solution of equations (1)(3). For an approximate
solution, U(x) is restricted to a finite set of suitable functions, typically polynomials, and
equation (7) is satisfied for these functions only.
The above derivation critically relies on integration by parts, and yet there is disagree-
ment in the literature on its use or value. For example, Strang and Fix [6, p. 10] state that
indeed the whole theory of differential operators rests on this rule. In contrast, having
written an equation analogous to equation (4) above, Ames [7, p. 29] states that it is useful,
but not mandatory, to apply Greens theorem
*
to incorporate second and third boundary
conditions

although he does not elaborate further on this point. Finally, Mohr [8, p. 414]
states that the Galerkin method will yield better results if integration by parts is used to
reduce the order of the governing differential equation.
The usual justification for the integration by parts is that
(a) it allows approximation functions with lower continuity requirements and this is
crucial for finite elements, and
(b) it allows the natural boundary conditions to be incorporated into the formulation.
While this is true from a theoretical point of view, and the final result (equation (7)) is
correct, from a teaching point of view the preceding formulation is likely to be confusing or
misleading.
Firstly, although equation (7) was derived from equation (4), the two equations are not
generally equivalent for u u

. This can be clearly seen by taking the approximation

( ) , u x Cx with C an unknown constant, and w(x) = x . Such an approximation can be used


in equation (7), but not in equation (4) where it leads to the nonsensical statement.
px x
L
d

0
0
(8)
Secondly, the derivation seems to imply that the natural boundary condition will be
satisfied exactly by the approximate solution since it was incorporated in the derivation via
equation (5). Again, this is not generally the case. For example, using the above approxima-
tion in equation (7) leads to E Au L pL

( ) 2 0 for the case of constant p and P = 0.


The conceptual difficulty with the above derivation is that it only focuses on the error
arising from the differential equation not being satisfied. In general, up to three errors can
arise from an approximation, depending on which of equations (1)(3) are not satisfied. The
16 J. Petrolito
International Journal of Mechanical Engineering Education Vol 28 No 1
Untitled-4 10/2/00, 3:27 pm 16
International Journal of Mechanical Engineering Education Vol 28 No 1
Approximate solutions of differential equations using Galerkins method 17
errors associated with the boundary conditions are blurred in the above derivation. Thus, it is
clearer and more consistent to work with a general formulation that includes all possible
errors arising from the approximation. This leads to the notion of a weighted residual
formulation.
4. WEIGHTED RESIDUAL FORMULATION
In this approach, we include all possible errors arising from the approximation. Thus, for an
approximation

( ), u x we define three residuals, namely


R u E Au p x L
R u P E Au L
R u u
D
P
U
(

,
(

( )
(

( )
+ < <

0
0
(9)
For the exact solution we have
R u R u R u
D ex P ex U ex
( ) ( ) ( ) 0 (10)
but for the approximation we have, in general,
R u R u R u
D P U
(

) , (

) , (

) 0 0 0 (11)
Note that R
D
is defined over an interval whereas R
P
and R
U
are point functions.
The goal of any approximation scheme is to force the residuals in equation (9) to zero in
some sense. There is considerable latitude in choosing the criterion to be used, for example
collocation and least squares methods are also used [9]. One possible formulation is to
satisfy
R u w x
R u w
R u w
L
D D
P P
U U
d (

)
(

)
(

)
0
0
0
0

(12)
for some specified weights w
D
(x), w
P
and w
U
. Note that w
P
and w
U
are not strictly required
in equation (12), but they are required in the following development for dimensional
consistency.
While this type of formulation is quite general, it is likely to be too demanding. For
example, using a one-parameter approximation

( ) u Cf x we have one unknown, C, and


possibly three conditions to satisfy arising from equation (12). Thus, we may end up with an
inconsistent set of equations. However, if the function f (x) identically satisfies the boundary
conditions (i.e. R
P
= R
U
= 0), we should be able to obtain a solution. This approach is just the
classical Galerkin method if w
D
= f [10].
Recognizing the above difficulties, we can relax our demands and instead try to set the
sum of the weighted residuals to zero, i.e.,
R u w x R u w R u w
L
D D P P U U
d (

) (

) (

) + +

0
0 (13)
Untitled-4 10/2/00, 3:27 pm 17
In this approach it is clear that, in general, we no longer will force each residual to be zero
identically. Equation (13) is a general formulation that includes all possible errors arising
from the approximation. However, it is common practice to satisfy the essential boundary
condition, i.e. to enforce R u
U
(

) , 0 and we consider this case here. Using this assumption,


we are led to the criterion
EAu p w x P EAu L w
L

( ) +
( )
+
( )

0
0
D P
d (15)
To discuss the accuracy of the approximate solution, we will introduce two errors
measures. The displacement error is defined as
u
px L x
EA
ex

( ) 2
2
(19)
The magnitude of w
P
determines the relative importance associated with the errors in the
differential equation and the natural boundary condition (see equation (15)). Hence, there is
no unique best value of w
P
. We can study the influence of w
P
by considering the resulting
error in the approximation. For the problem under consideration, the exact solution is
However, from the physical situation we expect a positive displacement of the bar under this
loading, and hence C should be positive. Hence, we conclude from equation (17) that
w
P
> 0 (18)
C
pL
EAw

2
2
P
(17)
We can simplify equation (16) by choosing w
P
= w
D
(L). Making this choice gives
equation (7), and the above derivation reduces to the standard formulation. However, the
derivation avoids the conceptual difficulties associated with the usual derivation. It is clear
from the above derivation that the natural boundary condition will not generally be exactly
satisfied, and that integration by parts has been used as a simplifying tool. It also clarifies the
issue of signs in the various terms in equation (15). This contrasts with derivations that start
with a combined weighted residual equation such as equation (15) with w
P
= w
P
(L), but
without any justification for the signs of the terms in the equation, e.g. [11, p. 84]. Finally, it
shows that Galerkins method arises from one possible choice for w
P
, and hence other
choices for w
P
could be explored.
Further motivation for the choice w
P
= w
D
(L) can be provided as follows. We consider
the case p = constant and P = 0, together with a linear approximation

( ) , u x Cx and corre-
sponding weight function w(x) = x. In this case, equation (16) gives
pw EAu w x EAu L w L P EAu L w
L
D D D P
d
( )
+ +
( )


( ) ( )

( )
0
0 (16)
Integrating the first term in equation (15) by parts gives
R u w x R u w
L
D D P P
d (

) (

) +

0
0 (14)
or
18 J. Petrolito
International Journal of Mechanical Engineering Education Vol 28 No 1
Untitled-4 10/2/00, 3:27 pm 18
E u u x
L
u ex
d

)
0
2
(20)
Noting that the strain energy in the bar, U, is given by
U
EA
u x
L

2
2
0
( ) d (21)
the strain energy error is defined as
E u u x
L
s ex
d

)
2
0
(22)
The variations of E
u
and E
s
with w
P
are shown in Fig. 2. We can see from the figure that
there is an optimum value of w
P
depending on which error we choose to minimize. Choosing
the value of w
P
according to Galerkins method is equivalent to minimizing the strain energy
error, as is well-known [9]. A different optimum value of w
P
arises if we choose to minimize
the displacement error. For the present example, the optimum values are
Fig. 2. Energy and displacement errors for continuous example.
w L E
L
E
P s
P u
for minimum (Galerkin' s method)
w for minimum


4
5
(23)
International Journal of Mechanical Engineering Education Vol 28 No 1
Approximate solutions of differential equations using Galerkins method 19
Untitled-4 10/2/00, 3:27 pm 19
The resulting approximate displacements associated with these optimum values are shown
in Fig. 3, together with the exact solution. While Galerkins method produces exact nodal
displacements for this example, it results in a large relative error in the displacement at other
points. In contrast, minimizing E
u
produces smaller errors in displacement on average
throughout the whole bar. Of course, in a practical problem the exact solution is unknown,
and we would not be able to determine the optimum value of w
P
associated with E
u
.
However, the calculations confirm that, in principle, other choice for w
P
are possible.
We can extend the above ideas to a multi-parameter approximation. In this case, we
assume that the approximate displacement is taken as

( ) u x C
j j
j
N

1
(24)
where N is the number of unknown parameters, and each
j
x ( ) is an independent basis
function. Since we have N unknowns, equation (14) is replaced by
Integrating by parts gives
Fig. 3. Solutions for continuous example.
R u w x R u w j N
j
L
j D D P P
d (

) (

) , , , ,
0
0 1 2

+ (25)
20 J. Petrolito
International Journal of Mechanical Engineering Education Vol 28 No 1
Untitled-4 10/2/00, 3:27 pm 20
pw EAu w x EAu L w L P EAu L w
j j
L
j j D D D P
d
( )
+ +
( )


( ) ( )

( ) ,
0
0
j N 1 2 , , , (26)
Equation (26) reduces to Galerkins method if we use w
Pj
= w
Dj
(L), giving
pw EAu w x Pw L j N
j j
L
j D D D
d
( )
+

( ) , , , ,
0
0 1 2 (27)
where N is the total number of mesh variables.
5. APPLICATION TO FINITE ELEMENTS
We now extend the above discussion to finite elements. For this purpose, we consider a two-
element discretization as shown in Fig. 4. This discretization is sufficient to illustrate the
features of the finite element formulation.
Fig. 4. Two-element discretization for bar.
We assume that the approximate displacement is piecewise-continuous at x = a, and
identically satisfies the essential boundary condition

( ) . u 0 0 The derivative,

( ), u x is
generally discontinuous at x = a, and the natural boundary condition at x = L is not identi-
cally satisfied by the approximation. Finally, the second derivative of

( ) u x is undefined in
the classical sense at x = a.
For the stated assumptions, the residuals are
R u EAu p x a
R u EAu p a x L
R u EA u a u a
R u P EAu L
D1
D2
I
P
(

,
(

,
(

( )

( )
(

( )
+ < <
+ < <

( )

+
0
(28)
where

( )
+
u a is the derivative of

u at a point just to the right of x = a and

( )

u a is the
derivative of
u at a point just to the left of x = a.
As for the continuous case, we generally cannot force each residual to zero identically.
Hence, we introduce piecewise-continuous weight functions, w
Dj
(x), such that
w
Dj
(a
+
) = w
Dj
(a

), and point weights, w


Ij
and w
Pj
, associated with the points x = a and x = L,
and attempt to force the residuals to zero in some average sense. Hence, the weighted
residual scheme is taken as
R u w x R u w x R u w R u w
j N
j
a
j
a
L
j j D D D D I I P P
d d
1
0
2
0
1 2
(

) (

) (

) (

) ,
, , ,
+ + +

+
(29)
International Journal of Mechanical Engineering Education Vol 28 No 1
Approximate solutions of differential equations using Galerkins method 21
Untitled-4 10/2/00, 3:27 pm 21
Since the approximate displacement and weight functions are continuous within each
element, integration by parts gives
EAu w x EAu w x EAu a w a
EAu w x EAu w x EAu L w L EAu a w a
j
a
j
a
j
j
a
L
j
a
L
j j

( ) ( )

( ) ( )

( ( )
)
+
+

+ +

+
D D D
D D D D
d d
d d
0 0
(30)
Combining equations (28)(30) and noting that the products

u w
j D
and pw
Dj
are well-
defined over the entire interval (0, L) gives
pw EAu w x EAu a w a EAu L w L
EAu a w a EA u a u a w
P EAu L w j N
j j
L
j j
j j
j
D D D D
D I
P
d
( )
+ +
+
( )
+
( )


+ +

( ) ( )

( ) ( )

( ) ( )

( )

( )

( ) , , , ,
0
0 1 2
(31)
As before, we can simplify equation (31) by choosing w
Ij
= w
Dj
(a) and w
Pj
= w
Dj
(L), giving
pw EAu w x Pw L j N
j j
L
j D D D
d
( )
+

( ) , , , ,
0
0 1 2 (32)
which is the same equation as for the continuous case (equation (27)).
We can again study the influence of w
Ij
and w
Pj
on the solution for the example problem.
For simplicity, we approximate the displacement by a piecewise-linear function, and use
elements of equal lengths (see Fig. 5(a)). Hence,

( ) ( ) ( ) u x x C x C +
1 1 2 2
(33)
where the basis functions
1
( ) x and
2
( ) x are shown in Fig. 5(b). Applying equation (31)
and w
Dj
(x) taken as each basis function in turn gives
2
2
2 4
2
1
1
2
1
2
EA
L
w w w w
w w w w
C
C
pL I P1 P1 I1
I2 P P2 I2

1
]
1
1

'



'

(34)
or
KC = R (35)
It is clear from equation (34) that not all choices for the point weights will work. For
example, the choice w
I1
= w
I2
, w
P1
= w
P2
leads to an inconsistent set of equations. For a
unique solution, we require K to have a nonzero determinant, that is
det( ) K w w w w
I1 P2 P1 I2
0 (36)
We also see that K is not symmetrical for arbitrary values of the weights, which is a
computational disadvantage for large problems. For a symmetrical K, we require
2w
I2
w
I1
w
P1
w
P2
= 0 (37)
Solving equation (34) gives
22 J. Petrolito
International Journal of Mechanical Engineering Education Vol 28 No 1
Untitled-4 10/2/00, 3:27 pm 22
Fig. 5. Piecewise linear approximation and associated basis functions.
(39)
C
pL w w w w
EA w w w w
C
pL w w w w
EA w w w w
1
2
2
2
2 4 2
8
2 2
8

+
( )

( )

+
( )

( )
I1 I2 P1 P2
I1 P2 I2 P1
I1 I2 P1 P2
I1 P2 I2 P1
(38)
We can again attempt to find the optimum values of the weights based on minimizing either
E
s
or E
u
. In this case, the optimum values of the weights are
w
w
w w w w E
w
w
w
w
w w E
I1
P1
P2 I2 I2 P1 s
I1
P1
P2
I2
I2 P1 u
and arbitrary, for minimum
and arbitrary, for minimum
+

1
2
1 2
7
8
13
32
14
13
32
13
, ,
, ,
International Journal of Mechanical Engineering Education Vol 28 No 1
Approximate solutions of differential equations using Galerkins method 23
Untitled-4 10/2/00, 3:27 pm 23
C
pL
EA
C
pL
EA
E
C
pL
EA
C
pL
EA
E
1
2
2
2
1
2
2
2
3
8 2
45
112
29
56


,
,
for minimum
for minimum
s
u
(40)
The resulting optimum displacements are shown in Fig. 6, and show a similar trend to the
results for the continuous case.
Fig. 6. Solutions for finite element example.
24 J. Petrolito
There is no unique solution for the weights in both cases. Galerkins method uses the
solution for minimum E
s
together with w
I2
= w
P1
= 0. This choice also results in a symmetri-
cal K matrix.
In contrast to the weights, the resulting optimum values of the displacement parameters
are unique, and are given by
International Journal of Mechanical Engineering Education Vol 28 No 1
R u w x R u w j N
L
j j D D P P
d
0
0 1 2

+ (

) (

) , , , , (41)
In the above formulation, the inter-element residual, R
I
, was explicitly included, and
differential equation residuals, R
D1
and R
D2
, were defined for each element. An alternative
approach is to define the differential equation residual over the entire region, and take the
weighted residual scheme as
Untitled-4 10/2/00, 3:27 pm 24
However, since

u is undefined at x = a, some care is required in evaluating the integral in


equation (42). Interpreting
u as a generalized function [5], and noting the discontinuity in

u at x = a, we have
R u w x R u w x R u w x R w a
L
j j
a
a
L
j j D D D D D D I D
d d d
0 0

+ +

+
(

) (

) (

) ( ) (43)
Combining equations (41) and (43) gives
R u w x R u w x R w a R u w
j N
j
a
a
L
j j j D D D D I D P P
d d (

) (

) ( ) (

) ,
, , ,
0
0
1 2

+
+ + +

(44)
Comparing equations (29) and (44), we see that in this approach w
Ij
does not explicitly
appear as it is automatically set equal to w
Dj
(a). This approach is therefore slightly less
general than the previous one.
The treatment of the inter-element residual, R
I
, varies considerably in textbooks. Most
books ignore R
I
by simply starting with equation (7), and disregard the fact that the integra-
tion by parts in equation (5) is not valid for the discontinuous case. Some authors include R
I
,
but then either claim or assume it is zero on the basis of the exact solution having a
continuous first derivative at the inter-element boundaries. Neither treatment is logically
consistent. Again, the problems stem from basing the derivation on only the differential
equation error, rather than all possible errors.
REFERENCES
[1] Livesley, R. K., Finite Elements: An Introduction for Engineers, Cambridge University Press,
Cambridge, 1983.
[2] Becker, E. B., Carey, G. F., and Oden, J. T., Finite Elements: An Introduction, Prentice Hall,
Englewood Cliffs, NJ, 1981.
[3] Mikhlin, S. G., Variational Methods in Mathematical Physics, Pergamon Press, New York, 1963.
[4] Finlayson, B. A., The Method of Weighted Residuals and Variational Principles, Academic Press,
New York, 1972.
[5] Stakgold, I., Greens Functions and Boundary Value Problems, WileyInterscience, New York,
1979.
6. CONCLUSIONS
The paper has discussed some of the issues that arise in the derivation of approximate
methods for the solution of differential equations. The usual textbook approach to Galerkins
method can be misleading, and fails to highlight all the possible errors that arise in an
approximation scheme. A general weighted residual method has been presented that explic-
itly includes all possible errors. In this way, all the inherent approximations are made trans-
parent to students. The conventional form of Galerkins method was shown to be just one
particular case of this method. An example was studied to demonstrate the effect of the point
weights on the approximation.
International Journal of Mechanical Engineering Education Vol 28 No 1
Approximate solutions of differential equations using Galerkins method 25
where in this case
R u EAu p x L
D
(

, + < < 0 (42)


Untitled-4 10/2/00, 3:27 pm 25
[6] Strang, G., and Fix, G. J., An Analysis of the Finite Element Method, Prentice Hall, Englewood
Cliffs, NJ, 1973.
[7] Ames, W. F, Numerical Methods for Partial Differential Equations, 3rd edn, Academic Press,
New York, 1992.
[8] Mohr, G. A., Finite Elements for Solids, Fluids and Optimization, Oxford University Press, Oxford,
1992.
[9] Cook, R. D., Malkus, D. S., and Plesha, M. E., Concepts and Applications of Finite Element
Analysis, 3rd edn, John Wiley, New York, 1989.
[10] Crandall, S. H., Engineering Analysis, McGraw-Hill, New York, 1956.
[11] Davies, A. J., The Finite Element Method: A First Approach, Oxford University Press, Oxford,
1980.
26 J. Petrolito
International Journal of Mechanical Engineering Education Vol 28 No 1
Untitled-4 10/2/00, 3:27 pm 26

Vous aimerez peut-être aussi