Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Numerical Methods for Engineers

Numerical Methods for Engineers

Numerical Methods for Engineers

PART SEVEN

699

PT7.1 MOTIVATION

In the  rst chapter of this book, we derived the following equation based on Newton’s

second law to compute the velocity y of a falling parachutist as a function of time t

[recall Eq. (1.9)]:

dy

dt 5 g 2

c

m y (PT7.1)

where g is the gravitational constant, m is the mass, and c is a drag coef cient. Such

equations, which are composed of an unknown function and its derivatives, are called

differential equations. Equation (PT7.1) is sometimes referred to as a rate equation

because it expresses the rate of change of a variable as a function of variables and pa-

rameters. Such equations play a fundamental role in engineering because many physical

phenomena are best formulated mathematically in terms of their rate of change.

In Eq. (PT7.1), the quantity being differentiated, y, is called the dependent variable.

The quantity with respect to which y is differentiated, t, is called the independent vari-

able. When the function involves one independent variable, the equation is called an

ordinary differential equation (or ODE). This is in contrast to a partial differential equa-

tion (or PDE) that involves two or more independent variables.

Differential equations are also classi ed as to their order. For example, Eq. (PT7.1)

is called a ! rst-order equation because the highest derivative is a  rst derivative. A

second-order equation would include a second derivative. For example, the equation

describing the position x of a mass-spring system with damping is the second-order

equation,

m d 2x

dt 2 1 c

dx

dt 1 kx 5 0 (PT7.2)

where c is a damping coef cient and k is a spring constant. Similarly, an nth-order equa-

tion would include an nth derivative.

Higher-order equations can be reduced to a system of  rst-order equations. For Eq.

(PT7.2), this is done by de ning a new variable y, where

y 5 dx

dt (PT7.3)

which itself can be differentiated to yield

dy

dt 5

d 2x

dt2 (PT7.4)

ORDINARY DIFFERENTIAL EQUATIONS

700 ORDINARY DIFFERENTIAL EQUATIONS

Equations (PT7.3) and (PT7.4) can then be substituted into Eq. (PT7.2) to give

m dy

dt 1 cy 1 kx 5 0 (PT7.5)

or

dy

dt 5 2

cy 1 kx

m (PT7.6)

Thus, Eqs. (PT7.3) and (PT7.6) are a pair of  rst-order equations that are equivalent to

the original second-order equation. Because other nth-order differential equations can be

similarly reduced, this part of our book focuses on the solution of  rst-order equations.

Some of the engineering applications in Chap. 28 deal with the solution of second-order

ODEs by reduction to a pair of  rst-order equations.

PT7.1.1 Noncomputer Methods for Solving ODEs

Without computers, ODEs are usually solved with analytical integration techniques. For

example, Eq. (PT7.1) could be multiplied by dt and integrated to yield

y 5 # ag 2 cm yb dt (PT7.7) The right-hand side of this equation is called an inde! nite integral because the limits of

integration are unspeci ed. This is in contrast to the de nite integrals discussed previously

in Part Six [compare Eq. (PT7.7) with Eq. (PT6.6)].

An analytical solution for Eq. (PT7.7) is obtained if the inde nite integral can be

evaluated exactly in equation form. For example, recall that for the falling parachutist

problem, Eq. (PT7.7) was solved analytically by Eq. (1.10) (assuming y 5 0 at t 5 0):

y(t) 5 gm

c (1 2 e2(cym)t) (1.10)

The mechanics of deriving such analytical solutions will be discussed in Sec. PT7.2. For

the time being, the important fact is that exact solutions for many ODEs of practical

importance are not available. As is true for most situations discussed in other parts of

this book, numerical methods offer the only viable alternative for these cases. Because

these numerical methods usually require computers, engineers in the precomputer era

were somewhat limited in the scope of their investigations.

One very important method that engineers and applied mathematicians developed to

overcome this dilemma was linearization. A linear ordinary differential equation is one

that  ts the general form

an(x)y (n)

1 p 1 a1(x)y¿ 1 a0(x)y 5 f(x) (PT7.8)

where y(n) is the nth derivative of y with respect to x and the a’s and f ’s are speci ed

functions of x. This equation is called linear because there are no products or nonlinear

functions of the dependent variable y and its derivatives. The practical importance of

linear ODEs is that they can be solved analytically. In contrast, most nonlinear equations

PT7.1 MOTIVATION 701

cannot be solved exactly. Thus, in the precomputer era, one tactic for solving nonlinear

equations was to linearize them.

A simple example is the application of ODEs to predict the motion of a swinging

pendulum (Fig. PT7.1). In a manner similar to the derivation of the falling parachutist

problem, Newton’s second law can be used to develop the following differential equation

(see Sec. 28.4 for the complete derivation):

d 2u

dt 2 1

g

l sin u 5 0 (PT7.9)

where u is the angle of displacement of the pendulum, g is the gravitational constant,

and l is the pendulum length. This equation is nonlinear because of the term sin u. One

way to obtain an analytical solution is to realize that for small displacements of the

pendulum from equilibrium (that is, for small values of u),

sin u > u (PT7.10)

Thus, if it is assumed that we are interested only in cases where u is small, Eq. (PT7.10)

can be substituted into Eq. (PT7.9) to give

d 2u

dt 2 1

g

l u 5 0 (PT7.11)

We have, therefore, transformed Eq. (PT7.9) into a linear form that is easy to solve

analytically.

Although linearization remains a very valuable tool for engineering problem solving,

there are cases where it cannot be invoked. For example, suppose that we were interested

in studying the behavior of the pendulum for large displacements from equilibrium. In

such instances, numerical methods offer a viable option for obtaining solutions. Today,

the widespread availability of computers places this option within reach of all practicing

engineers.

PT7.1.2 ODEs and Engineering Practice

The fundamental laws of physics, mechanics, electricity, and thermodynamics are usually

based on empirical observations that explain variations in physical properties and states

of systems. Rather than describing the state of physical systems directly, the laws are

usually couched in terms of spatial and temporal changes.

Several examples are listed in Table PT7.1. These laws de ne mechanisms of change.

When combined with continuity laws for energy, mass, or momentum, differential equa-

tions result. Subsequent integration of these differential equations results in mathematical

functions that describe the spatial and temporal state of a system in terms of energy,

mass, or velocity variations.

The falling parachutist problem introduced in Chap. 1 is an example of the derivation

of an ordinary differential equation from a fundamental law. Recall that Newton’s second

law was used to develop an ODE describing the rate of change of velocity of a falling

parachutist. By integrating this relationship, we obtained an equation to predict fall veloc-

ity as a function of time (Fig. PT7.2). This equation could be utilized in a number of

different ways, including design purposes.

FIGURE PT7.1 The swinging pedulum.

u

l

702 ORDINARY DIFFERENTIAL EQUATIONS

In fact, such mathematical relationships are the basis of the solution for a great

number of engineering problems. However, as described in the previous section, many

of the differential equations of practical signi cance cannot be solved using the analyti-

cal methods of calculus. Thus, the methods discussed in the following chapters are

extremely important in all  elds of engineering.

TABLE PT7.1 Examples of fundamental laws that are written in terms of the rate of change of variables (t 5 time and x 5 position).

Law Mathematical Expression Variables and Parameters

Newton’s second law Velocity (v), force (F), and of motion mass (m)

Fourier’s heat law Heat fl ux (q), thermal conductivity (k9) and temperature (T)

Fick’s law of diffusion Mass fl ux ( J), diffusion coeffi cient (D), and concentration (c)

Faraday’s law Voltage drop (DV L), inductance (L), (voltage drop across and current (i) an inductor)

dv

dt 5

F

m

q 5 2k¿ dT

dx

J 5 2D dc

dx

¢VL 5 L di

dt

F = ma

Analytical Numerical

v = (1 – e– (c/m)t) gm

c vi + 1 = vi + (g – vi) t

c

m

= g – vdv

dt

c

m

Physical law

Solution

ODE

FIGURE PT7.2 The sequence of events in the application of ODEs for engineering problem solving. The exam- ple shown is the velocity of a falling parachutist.

PT7.2 MATHEMATICAL BACKGROUND 703

PT7.2 MATHEMATICAL BACKGROUND

A solution of an ordinary differential equation is a speci c function of the independent

variable and parameters that satis es the original differential equation. To illustrate this

concept, let us start with a given function

y 5 20.5×4 1 4×3 2 10×2 1 8.5x 1 1 (PT7.12)

which is a fourth-order polynomial (Fig. PT7.3a). Now, if we differentiate Eq. (PT7.12),

we obtain an ODE:

dy

dx 5 22×3 1 12×2 2 20x 1 8.5 (PT7.13)

This equation also describes the behavior of the polynomial, but in a manner different

from Eq. (PT7.12). Rather than explicitly representing the values of y for each value of

x, Eq. (PT7.13) gives the rate of change of y with respect to x (that is, the slope) at every

value of x. Figure PT7.3 shows both the function and the derivative plotted versus x. Notice

FIGURE PT7.3 Plots of (a) y versus x and (b) dy/dx versus x for the function y 5 20.5×4 1 4×3 2 10×2 1 8.5x 1 1.

y

4

(a)

x3

dy/dx

8

(b)

x

– 8

3

704 ORDINARY DIFFERENTIAL EQUATIONS

how the zero values of the derivatives correspond to the point at which the original func-

tion is ! at—that is, has a zero slope. Also, the maximum absolute values of the derivatives

are at the ends of the interval where the slopes of the function are greatest.

Although, as just demonstrated, we can determine a differential equation given the

original function, the object here is to determine the original function given the differ-

ential equation. The original function then represents the solution. For the present case,

we can determine this solution analytically by integrating Eq. (PT7.13):

y 5 # (22×3 1 12×2 2 20x 1 8.5) dx Applying the integration rule (recall Table PT6.2)

#un du 5 u n11

n 1 1 1 C n ? 21

to each term of the equation gives the solution

y 5 20.5×4 1 4×3 2 10×2 1 8.5x 1 C (PT7.14)

which is identical to the original function with one notable exception. In the course of

differentiating and then integrating, we lost the constant value of 1 in the original equa-

tion and gained the value C. This C is called a constant of integration. The fact that such

an arbitrary constant appears indicates that the solution is not unique. In fact, it is but

one of an in nite number of possible functions (corresponding to an in nite number of

possible values of C) that satisfy the differential equation. For example, Fig. PT7.4 shows

six possible functions that satisfy Eq. (PT7.14).

FIGURE PT7.4 Six possible solutions for the integral of 22×3 1 12×2 2 20x 1 8.5. Each conforms to a different value of the constant of integration C.

y

x C = 0

C = – 1

C = – 2

C = 3

C = 2

C = 1

PT7.3 ORIENTATION 705

Therefore, to specify the solution completely, a differential equation is usually ac-

companied by auxiliary conditions. For  rst-order ODEs, a type of auxiliary condition

called an initial value is required to determine the constant and obtain a unique solution.

For example, Eq. (PT7.13) could be accompanied by the initial condition that at x 5 0,

y 5 1. These values could be substituted into Eq. (PT7.14):

1 5 20.5(0)4 1 4(0)3 2 10(0)2 1 8.5(0) 1 C (PT7.15)

to determine C 5 1. Therefore, the unique solution that satis es both the differential

equation and the speci ed initial condition is obtained by substituting C 5 1 into Eq.

(PT7.14) to yield

y 5 20.5×4 1 4×3 2 10×2 1 8.5x 1 1 (PT7.16)

Thus, we have “pinned down’’ Eq. (PT7.14) by forcing it to pass through the initial

condition, and in so doing, we have developed a unique solution to the ODE and have

come full circle to the original function [Eq. (PT7.12)].

Initial conditions usually have very tangible interpretations for differential equations

derived from physical problem settings. For example, in the falling parachutist problem,

the initial condition was re! ective of the physical fact that at time zero the vertical veloc-

ity was zero. If the parachutist had already been in vertical motion at time zero, the

solution would have been modi ed to account for this initial velocity.

When dealing with an nth-order differential equation, n conditions are required to

obtain a unique solution. If all conditions are speci ed at the same value of the indepen-

dent variable (for example, at x or t 5 0), then the problem is called an initial-value

problem. This is in contrast to boundary-value problems where speci cation of conditions

occurs at different values of the independent variable. Chapters 25 and 26 will focus on

initial-value problems. Boundary-value problems are covered in Chap. 27 along with

eigenvalues.

PT7.3 ORIENTATION

Before proceeding to numerical methods for solving ordinary differential equations, some

orientation might be helpful. The following material is intended to provide you with an

overview of the material discussed in Part Seven. In addition, we have formulated objec-

tives to focus your studies of the subject area.

PT7.3.1 Scope and Preview

Figure PT7.5 provides an overview of Part Seven. Two broad categories of numerical

methods for initial-value problems will be discussed in this part of this book. One-step

methods, which are covered in Chap. 25, permit the calculation of yi11, given the dif-

ferential equation and yi. Multistep methods, which are covered in Chap. 26, require

additional values of y other than at i.

With all but a minor exception, the one-step methods in Chap. 25 belong to what

are called Runge-Kutta techniques. Although the chapter might have been organized

around this theoretical notion, we have opted for a more graphical, intuitive approach to

introduce the methods. Thus, we begin the chapter with Euler’s method, which has a

very straightforward graphical interpretation. Then, we use visually oriented arguments

706 ORDINARY DIFFERENTIAL EQUATIONS

FIGURE PT7.5 Schematic representation of the organization of Part Seven: Ordinary Differential Equations.

CHAPTER 25

Runge-Kutta

Methods

PART 7

Ordinary

Differential

Equations

CHAPTER 26

Stiffness/

Multistep

Methods

CHAPTER 27

Boundary Value

and Eigenvalue

Problems

CHAPTER 28

Case Studies

EPILOGUE

26.2 Multistep methods

26.1 Stiffness

PT 7.2 Mathematical background

PT 7.6 Advanced methods

PT 7.5 Important formulas

28.4 Mechanical engineering

28.3 Electrical

engineering

28.2 Civil

engineering

28.1 Chemical

engineering

27.1 Boundary-

value problems

27.3 Software packages

27.2 Eigenvalues

PT 7.4 Trade-offs

PT 7.3 Orientation

PT 7.1 Motivation

25.2 Heun and midpoint methods

25.1 Euler’s method

25.3 Runge-Kutta

25.4 Systems of

ODEs

25.5 Adaptive RK

methods

PT7.3 ORIENTATION 707

to develop two improved versions of Euler’s method—the Heun and the midpoint tech-

niques. After this introduction, we formally develop the concept of Runge-Kutta (or RK)

approaches and demonstrate how the foregoing techniques are actually  rst- and second-

order RK methods. This is followed by a discussion of the higher-order RK formulations

that are frequently used for engineering problem solving. In addition, we cover the ap-

plication of one-step methods to systems of ODEs. Finally, the chapter ends with a

discussion of adaptive RK methods that automatically adjust the step size in response to

the truncation error of the computation.

Chapter 26 starts with a description of stiff ODEs. These are both individual and

systems of ODEs that have both fast and slow components to their solution. We intro-

duce the idea of an implicit solution technique as one commonly used remedy for this

problem.

Next, we discuss multistep methods. These algorithms retain information of previous

steps to more effectively capture the trajectory of the solution. They also yield the trunca-

tion error estimates that can be used to implement step-size control. In this section, we

initially take a visual, intuitive approach by using a simple method—the non-self-starting

Heun—to introduce all the essential features of the multistep approaches.

In Chap. 27 we turn to boundary-value and eigenvalue problems. For the former,

we introduce both shooting and ! nite-difference methods. For the latter, we discuss sev-

eral approaches, including the polynomial and the power methods. Finally, the chapter

concludes with a description of the application of several software packages and librar-

ies for solution of ODEs and eigenvalues.

Chapter 28 is devoted to applications from all the  elds of engineering. Finally, a

short review section is included at the end of Part Seven. This epilogue summarizes and

compares the important formulas and concepts related to ODEs. The comparison includes

a discussion of trade-offs that are relevant to their implementation in engineering prac-

tice. The epilogue also summarizes important formulas and includes references for

advanced topics.

PT7.3.2 Goals and Objectives

Study Objectives. After completing Part Seven, you should have greatly enhanced your capability to confront and solve ordinary differential equations and eigenvalue prob-

lems. General study goals should include mastering the techniques, having the capability

to assess the reliability of the answers, and being able to choose the “best’’ method (or

methods) for any particular problem. In addition to these general objectives, the speci c

study objectives in Table PT7.2 should be mastered.

Computer Objectives. Algorithms are provided for many of the methods in Part Seven. This information will allow you to expand your software library. For example,

you may  nd it useful from a professional viewpoint to have software that employs the

fourth-order Runge-Kutta method for more than  ve equations and to solve ODEs with

an adaptive step-size approach.

In addition, one of your most important goals should be to master several of the

general-purpose software packages that are widely available. In particular, you should

become adept at using these tools to implement numerical methods for engineering

problem solving.

708 ORDINARY DIFFERENTIAL EQUATIONS

TABLE PT7.2 Specifi c study objectives for Part Seven.

1. Understand the visual representations of Euler’s, Heun’s, and the midpoint methods 2. Know the relationship of Euler’s method to the Taylor series expansion and the insight it provides

regarding the error of the method 3. Understand the difference between local and global truncation errors and how they relate to the

choice of a numerical method for a particular problem 4. Know the order and the step-size dependency of the global truncation errors for all the methods

described in Part Seven; understand how these errors bear on the accuracy of the techniques 5. Understand the basis of predictor-corrector methods; in particular, realize that the effi ciency of the

corrector is highly dependent on the accuracy of the predictor 6. Know the general form of the Runge-Kutta methods; understand the derivation of the second-order

RK method and how it relates to the Taylor series expansion; realize that there are an infi nite number of possible versions for second- and higher-order RK methods

7. Know how to apply any of the RK methods to systems of equations; be able to reduce an nth-order ODE to a system of n fi rst-order ODEs

8. Recognize the type of problem context where step size adjustment is important 9. Understand how adaptive step size control is integrated into a fourth-order RK method 10. Recognize how the combination of slow and fast components makes an equation or a system of

equations stiff 11. Understand the distinction between explicit and implicit solution schemes for ODEs; in particular,

recognize how the latter (1) ameliorates the stiffness problem and (2) complicates the solution mechanics

12. Understand the difference between initial-value and boundary-value problems 13. Know the difference between multistep and one-step methods; realize that all multistep methods are

predictor-correctors but that not all predictor-correctors are multistep methods 14. Understand the connection between integration formulas and predictor-corrector methods 15. Recognize the fundamental difference between Newton-Cotes and Adams integration formulas 16. Know the rationale behind the polynomial and the power methods for determining eigenvalues; in

particular, recognize their strengths and limitations 17. Understand how Hoteller’s defl ation allows the power method to be used to compute intermediate

eigenvalues 18. Know how to use software packages and/or libraries to integrate ODEs and evaluate eigenvalues

25

709

C H A P T E R 25

Runge-Kutta Methods

This chapter is devoted to solving ordinary differential equations of the form

dy

dx 5 f(x, y)

In Chap. 1, we used a numerical method to solve such an equation for the velocity of

the falling parachutist. Recall that the method was of the general form

New value 5 old value 1 slope 3 step size

or, in mathematical terms,

yi11 5 yi 1 fh (25.1)

According to this equation, the slope estimate of f is used to extrapolate from an old value

yi to a new value yi 1 1 over a distance h (Fig. 25.1). This formula can be applied step by

step to compute out into the future and, hence, trace out the trajectory of the solution.

FIGURE 25.1 Graphical depiction of a one- step method.

y

x

Step size = h

Slope =

xi xi + 1

yi + 1 = yi + h

710 RUNGE-KUTTA METHODS

All one-step methods can be expressed in this general form, with the only difference

being the manner in which the slope is estimated. As in the falling parachutist problem,

the simplest approach is to use the differential equation to estimate the slope in the form

of the ! rst derivative at xi. In other words, the slope at the beginning of the interval is

taken as an approximation of the average slope over the whole interval. This approach,

called Euler’s method, is discussed in the ! rst part of this chapter. This is followed by

other one-step methods that employ alternative slope estimates that result in more ac-

curate predictions. All these techniques are generally called Runge-Kutta methods.

25.1 EULER’S METHOD

The ! rst derivative provides a direct estimate of the slope at xi (Fig. 25.2):

f 5 f(xi, yi)

where f(xi, yi) is the differential equation evaluated at xi and yi. This estimate can be

substituted into Eq. (25.1):

yi11 5 yi 1 f(xi, yi)h (25.2)

This formula is referred to as Euler’s (or the Euler-Cauchy or the point-slope)

method. A new value of y is predicted using the slope (equal to the ! rst derivative at the

original value of x) to extrapolate linearly over the step size h (Fig. 25.2).

EXAMPLE 25.1 Euler’s Method

Problem Statement. Use Euler’s method to numerically integrate Eq. (PT7.13):

dy

dx 5 22×3 1 12×2 2 20x 1 8.5

y

xxi + 1

error

Predicted

True

xi

h

FIGURE 25.2 Euler’s method.

25.1 EULER’S METHOD 711

from x 5 0 to x 5 4 with a step size of 0.5. The initial condition at x 5 0 is y 5 1.

Recall that the exact solution is given by Eq. (PT7.16):

y 5 20.5×4 1 4×3 2 10×2 1 8.5x 1 1

Solution. Equation (25.2) can be used to implement Euler’s method:

y(0.5) 5 y(0) 1 f(0, 1)0.5

where y(0) 5 1 and the slope estimate at x 5 0 is

f(0, 1) 5 22(0)3 1 12(0)2 2 20(0) 1 8.5 5 8.5

Therefore,

y(0.5) 5 1.0 1 8.5(0.5) 5 5.25

The true solution at x 5 0.5 is

y 5 20.5(0.5)4 1 4(0.5)3 2 10(0.5)2 1 8.5(0.5) 1 1 5 3.21875

Thus, the error is

Et 5 true 2 approximate 5 3.21875 2 5.25 5 22.03125

or, expressed as percent relative error, et 5 263.1%. For the second step,

y(1) 5 y(0.5) 1 f(0.5, 5.25)0.5

5 5.25 1 [22(0.5)3 1 12(0.5)2 2 20(0.5) 1 8.5]0.5

5 5.875

The true solution at x 5 1.0 is 3.0, and therefore, the percent relative error is 295.8%.

The computation is repeated, and the results are compiled in Table 25.1 and Fig. 25.3.

TABLE 25.1 Comparison of true and approximate values of the integral of y9 5 22×3 1 12×2 2 20x 1 8.5, with the initial condition that y 5 1 at x 5 0. The approximate values were computed using Euler’s method with a step size of 0.5. The local error refers to the error incurred over a single step. It is calculated with a Taylor series expansion as in Example 25.2. The global error is the total discrepancy due to past as well as present steps.

Percent Relative Error

x ytrue yEuler Global Local

0.0 1.00000 1.00000 0.5 3.21875 5.25000 263.1 263.1 1.0 3.00000 5.87500 295.8 228.1 1.5 2.21875 5.12500 2131.0 21.4 2.0 2.00000 4.50000 2125.0 20.3 2.5 2.71875 4.75000 274.7 17.2 3.0 4.00000 5.87500 246.9 3.9 3.5 4.71875 7.12500 251.0 211.3 4.0 3.00000 7.00000 2133.3 253.1

712 RUNGE-KUTTA METHODS

Note that, although the computation captures the general trend of the true solution, the

error is considerable. As discussed in the next section, this error can be reduced by using

a smaller step size.

The preceding example uses a simple polynomial for the differential equation to

facilitate the error analyses that follow. Thus,

dy

dx 5 f(x)

Obviously, a more general (and more common) case involves ODEs that depend on both

x and y,

dy

dx 5 f(x, y)

As we progress through this part of the text, our examples will increasingly involve ODEs

that depend on both the independent and the dependent variables.

25.1.1 Error Analysis for Euler’s Method

The numerical solution of ODEs involves two types of error (recall Chaps. 3 and 4):

1. Truncation, or discretization, errors caused by the nature of the techniques employed

to approximate values of y.

FIGURE 25.3 Comparison of the true solution with a numerical solution using Euler’s method for the integral of y9 5 22×3 1 12×2 2 20x 1 8.5 from x 5 0 to x 5 4 with a step size of 0.5. The initial condition at x 5 0 is y 5 1.

y

4

0 x4

True solution

h = 0.5

20

25.1 EULER’S METHOD 713

2. Round-off errors caused by the limited numbers of signi! cant digits that can be

retained by a computer.

The truncation errors are composed of two parts. The ! rst is a local truncation error

that results from an application of the method in question over a single step. The second

is a propagated truncation error that results from the approximations produced during

the previous steps. The sum of the two is the total, or global truncation, error.

Insight into the magnitude and properties of the truncation error can be gained by

deriving Euler’s method directly from the Taylor series expansion. To do this, realize that

the differential equation being integrated will be of the general form

y¿ 5 f(x, y) (25.3)

where y9 5 dyydx and x and y are the independent and the dependent variables, respectively. If the solution—that is, the function describing the behavior of y—has continuous deriva-

tives, it can be represented by a Taylor series expansion about a starting value (xi, yi), as in

[recall Eq. (4.7)]

yi11 5 yi 1 y¿i h 1 y–i

2! h2 1 p 1

y(n)i

n! hn 1 Rn (25.4)

where h 5 xi11 2 xi and Rn 5 the remainder term, de! ned as

Rn 5 y(n11)(j)

(n 1 1)! hn11 (25.5)

where j lies somewhere in the interval from xi to xi11. An alternative form can be de-

veloped by substituting Eq. (25.3) into Eqs. (25.4) and (25.5) to yield

yi11 5 yi 1 f(xi, yi)h 1 f ¿(xi, yi)

2! h2 1 p 1

f (n21)(xi, yi)

n! hn 1 O(hn11) (25.6)

where O(hn11) speci! es that the local truncation error is proportional to the step size

raised to the (n 1 1)th power.

By comparing Eqs. (25.2) and (25.6), it can be seen that Euler’s method corresponds

to the Taylor series up to and including the term f(xi, yi)h. Additionally, the comparison

indicates that a truncation error occurs because we approximate the true solution using

a ! nite number of terms from the Taylor series. We thus truncate, or leave out, a part of

the true solution. For example, the truncation error in Euler’s method is attributable to

the remaining terms in the Taylor series expansion that were not included in Eq. (25.2).

Subtracting Eq. (25.2) from Eq. (25.6) yields

Et 5 f ¿(xi, yi)

2! h2 1 p 1 O(hn11) (25.7)

where Et 5 the true local truncation error. For suf! ciently small h, the errors in the terms

in Eq. (25.7) usually decrease as the order increases (recall Example 4.2 and the ac-

companying discussion), and the result is often represented as

Ea 5 f ¿(xi, yi)

2! h2 (25.8)

714 RUNGE-KUTTA METHODS

or

Ea 5 O(h 2) (25.9)

where Ea 5 the approximate local truncation error.

EXAMPLE 25.2 Taylor Series Estimate for the Error of Euler’s Method

Problem Statement. Use Eq. (25.7) to estimate the error of the ! rst step of Example 25.1. Also use it to determine the error due to each higher-order term of the Taylor series

expansion.

Solution. Because we are dealing with a polynomial, we can use the Taylor series to obtain exact estimates of the errors in Euler’s method. Equation (25.7) can be written as

Et 5 f ¿(xi, yi)

2! h2 1

f –(xi, yi)

3! h3 1

f (3)(xi, yi)

4! h4 (E25.2.1)

where f 9(xi, yi) 5 the ! rst derivative of the differential equation (that is, the second de-

rivative of the solution). For the present case, this is

f ¿(xi, yi) 5 26x 2

1 24x 2 20 (E25.2.2)

and f 0(xi, yi) is the second derivative of the ODE

f –(xi, yi) 5 212x 1 24 (E25.2.3)

and f (3)(xi, yi) is the third derivative of the ODE

f (3)(xi, yi) 5 212 (E25.2.4)

We can omit additional terms (that is, fourth derivatives and higher) from Eq. (E25.2.1)

because for this particular case they equal zero. It should be noted that for other func-

tions (for example, transcendental functions such as sinusoids or exponentials) this would

not necessarily be true, and higher-order terms would have nonzero values. However, for

the present case, Eqs. (E25.2.1) through (E25.2.4) completely de! ne the truncation error

for a single application of Euler’s method.

For example, the error due to truncation of the second-order term can be calculated as

Et, 2 5 26(0.0)2 1 24(0.0) 2 20

2 (0.5)2 5 22.5 (E25.2.5)

For the third-order term:

Et, 3 5 212(0.0) 1 24

6 (0.5)3 5 0.5

and the fourth-order term:

Et, 4 5 212

24 (0.5)4 5 20.03125

These three results can be added to yield the total truncation error:

Et 5 Et, 2 1 Et, 3 1 Et, 4 5 22.5 1 0.5 2 0.03125 5 22.03125

25.1 EULER’S METHOD 715

which is exactly the error that was incurred in the initial step of Example 25.1. Note

how Et, 2 . Et, 3 . Et, 4, which supports the approximation represented by Eq. (25.8).

As illustrated in Example 25.2, the Taylor series provides a means of quantifying

the error in Euler’s method. However, there are limitations associated with its use for

this purpose:

1. The Taylor series provides only an estimate of the local truncation error—that is, the

error created during a single step of the method. It does not provide a measure of the

propagated and, hence, the global truncation error. In Table 25.1, we have included

the local and global truncation errors for Example 25.1. The local error was computed

for each time step with Eq. (25.2) but using the true value of yi (the second column

of the table) to compute each yi1l rather than the approximate value (the third column),

as is done in the Euler method. As expected, the average absolute local truncation

error (25 percent) is less than the average global error (90 percent). The only reason

that we can make these exact error calculations is that we know the true value a

priori. Such would not be the case in an actual problem. Consequently, as discussed

below, you must usually apply techniques such as Euler’s method using a number of

different step sizes to obtain an indirect estimate of the errors involved.

2. As mentioned above, in actual problems we usually deal with functions that are more

complicated than simple polynomials. Consequently, the derivatives that are needed

to evaluate the Taylor series expansion would not always be easy to obtain.

Although these limitations preclude exact error analysis for most practical problems,

the Taylor series still provides valuable insight into the behavior of Euler’s method. Ac-

cording to Eq. (25.9), we see that the local error is proportional to the square of the step

size and the ! rst derivative of the differential equation. It can also be demonstrated that

the global truncation error is O(h), that is, it is proportional to the step size (Carnahan

et al., 1969). These observations lead to some useful conclusions:

1. The error can be reduced by decreasing the step size.

2. The method will provide error-free predictions if the underlying function (that is, the

solution of the differential equation) is linear, because for a straight line the second

derivative would be zero.

This latter conclusion makes intuitive sense because Euler’s method uses straight-line

segments to approximate the solution. Hence, Euler’s method is referred to as a rst-

order method.

It should also be noted that this general pattern holds for the higher-order one-step

methods described in the following pages. That is, an nth-order method will yield perfect

results if the underlying solution is an nth-order polynomial. Further, the local truncation

error will be O(hn11) and the global error O(hn).

EXAMPLE 25.3 Effect of Reduced Step Size on Euler’s Method

Problem Statement. Repeat the computation of Example 25.1 but use a step size of 0.25.

716 RUNGE-KUTTA METHODS

Solution. The computation is repeated, and the results are compiled in Fig. 25.4a. Halving the step size reduces the absolute value of the average global error to 40 percent

and the absolute value of the local error to 6.4 percent. This is compared to global and

local errors for Example 25.1 of 90 percent and 24.8 percent, respectively. Thus, as

expected, the local error is quartered and the global error is halved.

Also, notice how the local error changes sign for intermediate values along the range.

This is due primarily to the fact that the ! rst derivative of the differential equation is a

parabola that changes sign [recall Eq. (E25.2.2) and see Fig. 25.4b]. Because the local

error is proportional to this function, the net effect of the oscillation in sign is to keep the

global error from continuously growing as the calculation proceeds. Thus, from x 5 0 to

x 5 1.25, the local errors are all negative, and consequently, the global error increases

FIGURE 25.4 (a) Comparison of two numerical solutions with Euler’s method using step sizes of 0.5 and 0.25. (b) Comparison of true and estimated local truncation error for the case where the step size is 0.5. Note that the “estimated” error is based on Eq. (E25.2.5).

y

4

0 x4

True solution

h = 0.5

h = 0.25

2

(a)

0

y

– 0.5

0 x42

True

Estimated

(b)

25.1 EULER’S METHOD 717

over this interval. In the intermediate section of the range, positive local errors begin to

reduce the global error. Near the end, the process is reversed and the global error again

in” ates. If the local error continuously changes sign over the computation interval, the net

effect is usually to reduce the global error. However, where the local errors are of the

same sign, the numerical solution may diverge farther and farther from the true solution

as the computation proceeds. Such results are said to be unstable.

The effect of further step-size reductions on the global truncation error of Euler’s

method is illustrated in Fig. 25.5. This plot shows the absolute percent relative error at

x 5 5 as a function of step size for the problem we have been examining in Examples

25.1 through 25.3. Notice that even when h is reduced to 0.001, the error still exceeds

0.1 percent. Because this step size corresponds to 5000 steps to proceed from x 5 0 to

x 5 5, the plot suggests that a ! rst-order technique such as Euler’s method demands

great computational effort to obtain acceptable error levels. Later in this chapter, we

present higher-order techniques that attain much better accuracy for the same computa-

tional effort. However, it should be noted that, despite its inef! ciency, the simplicity of

Euler’s method makes it an extremely attractive option for many engineering problems.

Because it is very easy to program, the technique is particularly useful for quick analy-

ses. In the next section, a computer algorithm for Euler’s method is developed.

FIGURE 25.5 Effect of step size on the global truncation error of Euler’s method for the integral of y9 5 22×3 1 12×2 2 20x 1 8.5. The plot shows the absolute percent relative global error at x 5 5 as a function of step size.

1

10

100

0.1 0.1

Step size

A b

s o

lu te

p e rc

e n

t re

la ti

v e e

rr o

r

0.01 0.0011

50

Steps

500 50005

718 RUNGE-KUTTA METHODS

25.1.2 Algorithm for Euler’s Method

Algorithms for one-step techniques such as Euler’s method are extremely simple to

program. As speci! ed previously at the beginning of this chapter, all one-step methods

have the general form

New value 5 old value 1 slope 3 step size (25.10)

The only way in which the methods differ is in the calculation of the slope.

Suppose that you want to perform the simple calculation outlined in Table 25.1. That

is, you would like to use Euler’s method to integrate y9 5 22×3 1 12×2 2 20x 1 8.5,

with the initial condition that y 5 1 at x 5 0. You would like to integrate out to x 5 4

using a step size of 0.5, and display all the results. A simple pseudocode to accomplish

this task could be written as in Fig. 25.6.

Although this program will “do the job” of duplicating the results of Table 25.1, it

is not very well designed. First, and foremost, it is not very modular. Although this is

not very important for such a small program, it would be critical if we desired to mod-

ify and improve the algorithm.

Further, there are a number of issues related to the way we have set up the iterations.

For example, suppose that the step size were to be made very small to obtain better ac-

curacy. In such cases, because every computed value is displayed, the number of output

values might be very large. Further, the algorithm is predicated on the assumption that

the calculation interval is evenly divisible by the step size. Finally, the accumulation of

x in the line x 5 x 1 dx can be subject to quantizing errors of the sort previously dis-

FIGURE 25.6 Pseudocode for a “dumb” version of Euler’s method.

‘set integration range

xi 5 0

xf 5 4

‘initialize variables

x 5 xi

y 5 1

‘set step size and determine

‘number of calculation steps

dx 5 0.5

nc 5 (xf 2 xi)/dx

‘output initial condition

PRINT x, y

‘loop to implement Euler’s method

‘and display results

DOFOR i 5 1, nc

dydx 5 22×3 1 12×2 2 20x 1 8.5

y 5 y 1 dydx ? dx

x 5 x 1 dx

PRINT x, y

END DO

25.1 EULER’S METHOD 719

cussed in Sec. 3.4.1. For example, if dx were changed to 0.01 and standard IEEE ” oat-

ing point representation were used (about seven signi! cant digits), the result at the end

of the calculation would be 3.999997 rather than 4. For dx 5 0.001, it would be 3.999892!

A much more modular algorithm that avoids these dif! culties is displayed in Fig. 25.7.

The algorithm does not output all calculated values. Rather, the user speci! es an output

interval, xout, that dictates the interval at which calculated results are stored in arrays, xpm

and ypm. These values are stored in arrays so that they can be output in a variety of ways

after the computation is completed (for example, printed, graphed, or written to a ! le).

The Driver Program takes big output steps and calls an Integrator routine that takes

! ner calculation steps. Note that the loops controlling both large and small steps exit on

logical conditions. Thus, the intervals do not have to be evenly divisible by the step sizes.

The Integrator routine then calls an Euler routine that takes a single step with Euler’s

method. The Euler routine calls a Derivative routine that calculates the derivative value.

Whereas such modularization might seem like overkill for the present case, it will

greatly facilitate modifying the program in later sections. For example, although the

program in Fig. 25.7 is speci! cally designed to implement Euler’s method, the Euler

module is the only part that is method-speci! c. Thus, all that is required to apply this

algorithm to the other one-step methods is to modify this routine.

FIGURE 25.7 Pseudocode for an “improved” modular version of Euler’s method.

(a) Main or “Driver” Program

Assign values for

y 5 initial value dependent variable

xi 5 initial value independent variable

xf 5 final value independent variable

dx 5 calculation step size

xout 5 output interval

x 5 xi

m 5 0

xpm 5 x

ypm 5 y

DO

xend 5 x 1 xout

IF (xend . xf) THEN xend 5 xf

h 5 dx

CALL Integrator (x, y, h, xend)

m 5 m 1 1

xpm 5 x

ypm 5 y

IF (x $ xf) EXIT

END DO

DISPLAY RESULTS

END

(b) Routine to Take One Output Step

SUB Integrator (x, y, h, xend)

DO

IF (xend 2 x , h) THEN h 5 xend 2 x

CALL Euler (x, y, h, ynew)

y 5 ynew

IF (x $ xend) EXIT

END DO

END SUB

(c) Euler’s Method for a Single ODE

SUB Euler (x, y, h, ynew)

CALL Derivs (x, y, dydx)

ynew 5 y 1 dydx * h

x 5 x 1 h

END SUB

(d) Routine to Determine Derivative

SUB Derivs (x, y, dydx)

dydx 5 . . .

END SUB

720 RUNGE-KUTTA METHODS

EXAMPLE 25.4 Solving ODEs with the Computer

Problem Statement. A computer program can be developed from the pseudocode in Fig. 25.7. We can use this software to solve another problem associated with the falling

parachutist. You recall from Part One that our mathematical model for the velocity was

based on Newton’s second law in the form

dy

dt 5 g 2

c

m y (E25.4.1)

This differential equation was solved both analytically (Example 1.1) and numerically

using Euler’s method (Example 1.2). These solutions were for the case where g 5 9.81,

c 5 12.5, m 5 68.1, and y 5 0 at t 5 0.

The objective of the present example is to repeat these numerical computations

employing a more complicated model for the velocity based on a more complete math-

ematical description of the drag force caused by wind resistance. This model is given by

dy

dt 5 g 2

c

m cy 1 a a y

ymax bb d (E25.4.2)

where g, m, and c are the same as for Eq. (E25.4.1), and a, b, and ymax are empirical

constants, which for this case are equal to 8.3, 2.2, and 46, respectively. Note that this

model is more capable of accurately ! tting empirical measurements of drag forces versus

velocity than is the simple linear model of Example 1.1. However, this increased ” exibil-

ity is gained at the expense of evaluating three coef! cients rather than one. Furthermore,

the resulting mathematical model is more dif! cult to solve analytically. In this case,

Euler’s method provides a convenient alternative to obtain an approximate numerical

solution.

FIGURE 25.8 Graphical results for the solution of the nonlinear ODE [Eq. (E25.4.2)]. Notice that the plot also shows the solution for the linear model [Eq. (E25.4.1)] for comparative purposes.

60

y

40

20

0 t15

Nonlinear

Linear

5 100

25.2 IMPROVEMENTS OF EULER’S METHOD 721

Solution. The results for both the linear and nonlinear model are displayed in Fig. 25.8 with an integration step size of 0.1 s. The plot in Fig. 25.8 also shows an overlay of the

solution of the linear model for comparison purposes.

The results of the two simulations indicate how increasing the complexity of the for-

mulation of the drag force affects the velocity of the parachutist. In this case, the terminal

velocity is lowered because of resistance caused by the higher-order terms in Eq. (E25.4.2).

Alternative models could be tested in a similar fashion. The combination of a com-

puter-generated solution makes this an easy and ef! cient task. This convenience should

allow you to devote more of your time to considering creative alternatives and holistic

aspects of the problem rather than to tedious manual computations.

25.1.3 Higher-Order Taylor Series Methods

One way to reduce the error of Euler’s method would be to include higher-order terms

of the Taylor series expansion in the solution. For example, including the second-order

term from Eq. (25.6) yields

yi11 5 yi 1 f(xi, yi)h 1 f ¿(xi, yi)

2! h2 (25.11)

with a local truncation error of

Ea 5 f –(xi, yi)

6 h3

Although the incorporation of higher-order terms is simple enough to implement for

polynomials, their inclusion is not so trivial when the ODE is more complicated. In

particular, ODEs that are a function of both the dependent and independent variable

require chain-rule differentiation. For example, the ! rst derivative of f(x, y) is

f ¿(xi, yi) 5 0f(x, y)

0x 1 0f(x, y)

0y dy

dx

The second derivative is

f –(xi, yi) 5 0[0fy0x 1 (0fy0y)(dyydx)]

0x 1 0[0fy0x 1 (0fy0y)(dyydx)]

0y dy

dx

Higher-order derivatives become increasingly more complicated.

Consequently, as described in the following sections, alternative one-step methods

have been developed. These schemes are comparable in performance to the higher-order

Taylor-series approaches but require only the calculation of ! rst derivatives.

25.2 IMPROVEMENTS OF EULER’S METHOD

A fundamental source of error in Euler’s method is that the derivative at the beginning of

the interval is assumed to apply across the entire interval. Two simple modi! cations are

available to help circumvent this shortcoming. As will be demonstrated in Sec. 25.3, both

modi! cations actually belong to a larger class of solution techniques called Runge-Kutta

722 RUNGE-KUTTA METHODS

methods. However, because they have a very straightforward graphical interpretation, we

will present them prior to their formal derivation as Runge-Kutta methods.

25.2.1 Heun’s Method

One method to improve the estimate of the slope involves the determination of two

derivatives for the interval—one at the initial point and another at the end point. The two

derivatives are then averaged to obtain an improved estimate of the slope for the entire

interval. This approach, called Heun’s method, is depicted graphically in Fig. 25.9.

Recall that in Euler’s method, the slope at the beginning of an interval

y¿i 5 f(xi, yi) (25.12)

is used to extrapolate linearly to yi11:

y0i11 5 yi 1 f(xi, yi)h (25.13)

For the standard Euler method we would stop at this point. However, in Heun’s method

the y0i11 calculated in Eq. (25.13) is not the ! nal answer, but an intermediate prediction.

This is why we have distinguished it with a superscript 0. Equation (25.13) is called a

FIGURE 25.9 Graphical depiction of Heun’s method. (a) Predictor and (b) corrector.

y

xxi + 1xi

(a)

Slope = f (xi, yi)

Slope = f (xi + 1, y 0 i + 1)

y

xxi + 1xi

(b)

Slope = f (xi, yi) + f (xi + 1, yi + 1)

2

0

25.2 IMPROVEMENTS OF EULER’S METHOD 723

predictor equation. It provides an estimate of yi11 that allows the calculation of an esti-

mated slope at the end of the interval:

y¿i11 5 f(xi11, y 0 i11) (25.14)

Thus, the two slopes [Eqs. (25.12) and (25.14)] can be combined to obtain an average

slope for the interval:

y¿ 5 y¿i 1 y¿i11

2 5

f(xi, yi) 1 f(xi11, y 0 i11)

2

This average slope is then used to extrapolate linearly from yi to yi 1 l using Euler’s method:

yi11 5 yi 1 f(xi, yi) 1 f(xi11, y

0 i11)

2 h

which is called a corrector equation.

The Heun method is a predictor-corrector approach. All the multistep methods to

be discussed subsequently in Chap. 26 are of this type. The Heun method is the only

one-step predictor-corrector method described in this book. As derived above, it can be

expressed concisely as

Predictor (Fig. 25.9a): y0i11 5 yi 1 f(xi, yi)h (25.15)

Corrector (Fig. 25.9b): yi11 5 yi 1 f(xi, yi) 1 f(xi11, y

0 i11)

2 h (25.16)

Note that because Eq. (25.16) has yi1l on both sides of the equal sign, it can be applied

in an iterative fashion. That is, an old estimate can be used repeatedly to provide an im-

proved estimate of yi1l. The process is depicted in Fig. 25.10. It should be understood that

FIGURE 25.10 Graphical representation of iterating the corrector of Heun’s method to obtain an improved estimate.

f(x i , y

i ) + f (x

i+ 1 , y

i+ 1 )

y i + h

y i +

1

2

0

724 RUNGE-KUTTA METHODS

this iterative process does not necessarily converge on the true answer but will converge

on an estimate with a ! nite truncation error, as demonstrated in the following example.

As with similar iterative methods discussed in previous sections of the book, a ter-

mination criterion for convergence of the corrector is provided by [recall Eq. (3.5)]

Zea Z 5 ` y j i11 2 y

j21 i11

y j i11

` 100% (25.17) where y

j21 i11 and y

j i11 are the result from the prior and the present iteration of the correc-

tor, respectively.

EXAMPLE 25.5 Heun’s Method

Problem Statement. Use Heun’s method to integrate y9 5 4e0.8x 2 0.5y from x 5 0 to x 5 4 with a step size of 1. The initial condition at x 5 0 is y 5 2.

Solution. Before solving the problem numerically, we can use calculus to determine the following analytical solution:

y 5 4

1.3 (e0.8x 2 e20.5x) 1 2e20.5x (E25.5.1)

This formula can be used to generate the true solution values in Table 25.2.

First, the slope at (x0, y0) is calculated as

y¿0 5 4e 0

2 0.5(2) 5 3

This result is quite different from the actual average slope for the interval from 0 to 1.0,

which is equal to 4.1946, as calculated from the differential equation using Eq. (PT6.4).

The numerical solution is obtained by using the predictor [Eq. (25.15)] to obtain an

estimate of y at 1.0:

y01 5 2 1 3(1) 5 5

TABLE 25.2 Comparison of true and approximate values of the integral of y9 5 4e0.8x 2 0.5y, with the initial condition that y 5 2 at x 5 0. The approximate values were computed using the Heun method with a step size of 1. Two cases, corresponding to different numbers of corrector iterations, are shown, along with the absolute percent relative error.

Iterations of Heun’s Method

1 15

x ytrue y Heun |Et| (%) y Heun |Et| (%)

0 2.0000000 2.0000000 0.00 2.0000000 0.00 1 6.1946314 6.7010819 8.18 6.3608655 2.68 2 14.8439219 16.3197819 9.94 15.3022367 3.09 3 33.6771718 37.1992489 10.46 34.7432761 3.17 4 75.3389626 83.3377674 10.62 77.7350962 3.18

25.2 IMPROVEMENTS OF EULER’S METHOD 725

Note that this is the result that would be obtained by the standard Euler method. The true

value in Table 25.2 shows that it corresponds to a percent relative error of 19.3 percent.

Now, to improve the estimate for yi11, we use the value y 0 1 to predict the slope at

the end of the interval

y¿1 5 f(x1, y 0 1) 5 4e

0.8(1) 2 0.5(5) 5 6.402164

which can be combined with the initial slope to yield an average slope over the interval

from x 5 0 to 1

y¿ 5 3 1 6.402164

2 5 4.701082

which is closer to the true average slope of 4.1946. This result can then be substituted

into the corrector [Eq. (25.16)] to give the prediction at x 5 1

y1 5 2 1 4.701082(1) 5 6.701082

which represents a percent relative error of 28.18 percent. Thus, the Heun method with-

out iteration of the corrector reduces the absolute value of the error by a factor of 2.4

as compared with Euler’s method.

Now this estimate can be used to re! ne or correct the prediction of y1 by substitut-

ing the new result back into the right-hand side of Eq. (25.16):

y1 5 2 1 [3 1 4e0.8(1) 2 0.5(6.701082) ]

2 1 5 6.275811

which represents an absolute percent relative error of 1.31 percent. This result, in turn,

can be substituted back into Eq. (25.16) to further correct:

y1 5 2 1 [3 1 4e0.8(1) 2 0.5(6.275811) ]

2 1 5 6.382129

which represents an Zet Z of 3.03%. Notice how the errors sometimes grow as the iterations proceed. Such increases can occur, especially for large step sizes, and they prevent us

from drawing the general conclusion that an additional iteration will always improve the

result. However, for a suf! ciently small step size, the iterations should eventually con-

verge on a single value. For our case, 6.360865, which represents a relative error of 2.68

percent, is attained after 15 iterations. Table 25.2 shows results for the remainder of the

computation using the method with 1 and 15 iterations per step.

In the previous example, the derivative is a function of both the dependent variable

y and the independent variable x. For cases such as polynomials, where the ODE is solely

a function of the independent variable, the predictor step [Eq. (25.16)] is not required

and the corrector is applied only once for each iteration. For such cases, the technique

is expressed concisely as

yi11 5 yi 1 f(xi) 1 f(xi11)

2 h (25.18)

726 RUNGE-KUTTA METHODS

Notice the similarity between the right-hand side of Eq. (25.18) and the trapezoidal rule

[Eq. (21.3)]. The connection between the two methods can be formally demonstrated by

starting with the ordinary differential equation

dy

dx 5 f(x)

This equation can be solved for y by integration:

# yi11

yi

dy 5 #

xi11

xi

f(x) dx (25.19)

which yields

yi11 2 yi 5 # xi11

xi

f(x) dx (25.20)

or

yi11 5 yi 1 # xi11

xi

f(x) dx (25.21)

Now, recall from Chap. 21 that the trapezoidal rule [Eq. (21.3)] is de! ned as

# xi11

xi

f(x) dx >

f(xi) 1 f(xi11)

2 h (25.22)

where h 5 xi11 2 xi. Substituting Eq. (25.22) into Eq. (25.21) yields

yi11 5 yi 1 f(xi) 1 f(xi11)

2 h (25.23)

which is equivalent to Eq. (25.18).

Because Eq. (25.23) is a direct expression of the trapezoidal rule, the local truncation

error is given by [recall Eq. (21.6)]

Et 5 2 f –(j)

12 h3 (25.24)

where j is between xi and xi1l. Thus, the method is second order because the second de-

rivative of the ODE is zero when the true solution is a quadratic. In addition, the local and

global errors are O(h3) and O(h2), respectively. Therefore, decreasing the step size decreases

the error at a faster rate than for Euler’s method. Figure 25.11, which shows the result of

using Heun’s method to solve the polynomial from Example 25.1 demonstrates this behavior.

25.2.2 The Midpoint (or Improved Polygon) Method

Figure 25.12 illustrates another simple modi! cation of Euler’s method. Called the mid-

point method (or the improved polygon or the modi ed Euler), this technique uses Euler’s

method to predict a value of y at the midpoint of the interval (Fig. 25.12a):

yi11y2 5 yi 1 f(xi, yi) h

2 (25.25)

25.2 IMPROVEMENTS OF EULER’S METHOD 727

FIGURE 25.11 Comparison of the true solution with a numerical solution using Euler’s and Heun’s methods for the integral of y9 5 22×3 1 12×2 2 20x 1 8.5.

y

5

x

True solution

Euler’s method

Heun’s method

3

y

xxi + 1xi

y Slope = f (xi + 1/2, yi + 1/2)

xxi + 1/2xi

(b)

(a)

Slope = f (xi + 1/2, yi + 1/2)

FIGURE 25.12 Graphical depiction of the midpoint method. (a) Eq. (25.25) and (b) Eq. (25.27).

728 RUNGE-KUTTA METHODS

Then, this predicted value is used to calculate a slope at the midpoint:

y¿i11y2 5 f(xi11y2, yi11y2) (25.26)

which is assumed to represent a valid approximation of the average slope for the entire

interval. This slope is then used to extrapolate linearly from xi to xi1l (Fig. 25.12b):

yi11 5 yi 1 f(xi11y2, yi11y2)h (25.27)

Observe that because yi1l is not on both sides, the corrector [Eq. (25.27)] cannot be ap-

plied iteratively to improve the solution.

As in the previous section, this approach can also be linked to Newton-Cotes inte-

gration formulas. Recall from Table 21.4, that the simplest Newton-Cotes open integra-

tion formula, which is called the midpoint method, can be represented as

# b

a f(x) dx > (b 2 a) f(x1)

where x1 is the midpoint of the interval (a, b). Using the nomenclature for the present

case, it can be expressed as

# xi11

xi

f(x) dx > h f(xi11y2)

Substitution of this formula into Eq. (25.21) yields Eq. (25.27). Thus, just as the Heun

method can be called the trapezoidal rule, the midpoint method gets its name from the

underlying integration formula upon which it is based.

The midpoint method is superior to Euler’s method because it utilizes a slope estimate

at the midpoint of the prediction interval. Recall from our discussion of numerical differ-

entiation in Sec. 4.1.3 that centered ! nite divided differences are better approximations of

derivatives than either forward or backward versions. In the same sense, a centered ap-

proximation such as Eq. (25.26) has a local truncation error of O(h2) in comparison with

the forward approximation of Euler’s method, which has an error of O(h). Consequently,

the local and global errors of the midpoint method are O(h3) and O(h2), respectively.

25.2.3 Computer Algorithms for Heun and Midpoint Methods

Both the Heun method with a single corrector and the midpoint method can be easily

programmed using the general structure depicted in Fig. 25.7. As in Fig. 25.13a and b,

simple routines can be written to take the place of the Euler routine in Fig. 25.7.

However, when the iterative version of the Heun method is to be implemented, the

modi! cations are a bit more involved (although they are still localized within a single

module). We have developed pseudocode for this purpose in Fig. 25.13c. This algorithm

can be combined with Fig. 25.7 to develop software for the iterative Heun method.

25.2.4 Summary

By tinkering with Euler’s method, we have derived two new second-order techniques. Even

though these versions require more computational effort to determine the slope, the accom-

panying reduction in error will allow us to conclude in a subsequent section (Sec. 25.3.4)

25.3 RUNGE-KUTTA METHODS 729

that the improved accuracy is usually worth the effort. Although there are certain cases where

easily programmable techniques such as Euler’s method can be applied to advantage, the

Heun and midpoint methods are generally superior and should be implemented if they are

consistent with the problem objectives.

As noted at the beginning of this section, the Heun (without iterations), the midpoint

method, and in fact, the Euler technique itself are versions of a broader class of one-step

approaches called Runge-Kutta methods. We now turn to a formal derivation of these

techniques.

25.3 RUNGE-KUTTA METHODS

Runge-Kutta (RK) methods achieve the accuracy of a Taylor series approach without

requiring the calculation of higher derivatives. Many variations exist but all can be cast

in the generalized form of Eq. (25.1):

yi11 5 yi 1 f(xi, yi, h)h (25.28)

where f(xi, yi, h) is called an increment function, which can be interpreted as a represen-

tative slope over the interval. The increment function can be written in general form as

f 5 a1k1 1 a2k2 1 p 1 ankn (25.29)

(a) Simple Heun without Iteration

SUB Heun (x, y, h, ynew)

CALL Derivs (x, y, dy1dx)

ye 5 y 1 dy1dx ? h

CALL Derivs(x 1 h, ye, dy2dx)

Slope 5 (dy1dx 1 dy2dx)y2 ynew 5 y 1 Slope ? h

x 5 x 1 h

END SUB

(b) Midpoint Method

SUB Midpoint (x, y, h, ynew)

CALL Derivs(x, y, dydx)

ym 5 y 1 dydx ? hy2 CALL Derivs (x 1 hy2, ym, dymdx) ynew 5 y 1 dymdx ? h

x 5 x 1 h

END SUB

(c) Heun with Iteration

SUB HeunIter (x, y, h, ynew)

es 5 0.01

maxit 5 20

CALL Derivs(x, y, dy1dx)

ye 5 y 1 dy1dx ? h

iter 5 0

DO

yeold 5 ye

CALL Derivs(x 1 h, ye, dy2dx)

slope 5 (dy1dx 1 dy2dx)y2 ye 5 y 1 slope ? h

iter 5 iter 1 1

ea 5 ` ye 2 yeold ye

` 100% IF (ea # es OR iter . maxit) EXIT

END DO

ynew 5 ye

x 5 x 1 h

END SUB

FIGURE 25.13 Pseudocode to implement the (a) simple Heun, (b) midpoint, and (c) iterative Heun methods.

730 RUNGE-KUTTA METHODS

where the a’s are constants and the k’s are

k1 5 f(xi, yi) (25.29a)

k2 5 f(xi 1 p1h, yi 1 q11k1h) (25.29b)

k3 5 f(xi 1 p2h, yi 1 q21k1h 1 q22k2h) (25.29c)

#

#

#

kn 5 f(xi 1 pn21h, yi 1 qn21, 1k1h 1 qn21, 2k2h 1 p 1 qn21, n21kn21h) (25.29d)

where the p’s and q’s are constants. Notice that the k’s are recurrence relationships. That

is, k1 appears in the equation for k2, which appears in the equation for k3, and so forth.

Because each k is a functional evaluation, this recurrence makes RK methods ef! cient

for computer calculations.

Various types of Runge-Kutta methods can be devised by employing different num-

bers of terms in the increment function as speci! ed by n. Note that the ! rst-order RK

method with n 5 1 is, in fact, Euler’s method. Once n is chosen, values for the a’s, p’s,

and q’s are evaluated by setting Eq. (25.28) equal to terms in a Taylor series expansion

(Box 25.1). Thus, at least for the lower-order versions, the number of terms, n, usually

represents the order of the approach. For example, in the next section, second-order RK

methods use an increment function with two terms (n 5 2). These second-order methods

will be exact if the solution to the differential equation is quadratic. In addition, because

terms with h3 and higher are dropped during the derivation, the local truncation error is

O(h3) and the global error is O(h2). In subsequent sections, the third- and fourth-order

RK methods (n 5 3 and 4, respectively) are developed. For these cases, the global trun-

cation errors are O(h3) and O(h4), respectively.

25.3.1 Second-Order Runge-Kutta Methods

The second-order version of Eq. (25.28) is

yi11 5 yi 1 (a1k1 1 a2k2)h (25.30)

where

k1 5 f(xi, yi) (25.30a)

k2 5 f(xi 1 p1h, yi 1 q11k1h) (25.30b)

As described in Box 25.1, values for al, a2, p1, and q11 are evaluated by setting Eq. (25.30)

equal to a Taylor series expansion to the second-order term. By doing this, we derive three

equations to evaluate the four unknown constants. The three equations are

a1 1 a2 5 1 (25.31)

a2 p1 5 1

2 (25.32)

a2q11 5 1

2 (25.33)

25.3 RUNGE-KUTTA METHODS 731

Because we have three equations with four unknowns, we must assume a value of one

of the unknowns to determine the other three. Suppose that we specify a value for a2. Then

Eqs. (25.31) through (25.33) can be solved simultaneously for

a1 5 1 2 a2 (25.34)

p1 5 q11 5 1

2a2 (25.35)

Box 25.1 Derivation of the Second-Order Runge-Kutta Methods

The second-order version of Eq. (25.28) is

yi11 5 yi 1 (a1k1 1 a2k2)h (B25.1.1)

where

k1 5 f (xi, yi) (B25.1.2)

and

k2 5 f (xi 1 p1h, yi 1 q11k1h) (B25.1.3)

To use Eq. (B25.1.1) we have to determine values for the

constants a1, a2, p1, and q11. To do this, we recall that the second-

order Taylor series for yi11 in terms of yi and f(xi, yi) is written as

[Eq. (25.11)]

yi11 5 yi 1 f (xi, yi)h 1 f ¿(xi, yi)

2! h2 (B25.1.4)

where f 9(xi, yi) must be determined by chain-rule differentiation

(Sec. 25.1.3):

f ¿(xi, yi) 5 0f (x, y)

0x 1 0f (x, y)

0y dy

dx (B25.1.5)

Substituting Eq. (B25.1.5) into (B25.1.4) gives

yi11 5 yi 1 f (xi, yi)h 1 a 0f 0x

1 0f

0y dy

dx b h2

2! (B25.1.6)

The basic strategy underlying Runge-Kutta methods is to use alge-

braic manipulations to solve for values of a1, a2, p1, and q11 that

make Eqs. (B25.1.1) and (B25.1.6) equivalent.

To do this, we ! rst use a Taylor series to expand Eq. (25.1.3).

The Taylor series for a two-variable function is de! ned as [recall

Eq. (4.26)]

g(x 1 r, y 1 s) 5 g(x, y) 1 r 0g

0x 1 s 0g

0y 1p

Applying this method to expand Eq. (B25.1.3) gives

f (xi 1 p1h, yi 1 q11k1h) 5 f (xi, yi) 1 p1h 0f

0x

1 q11k1h 0f

0y 1 O(h2)

This result can be substituted along with Eq. (B25.1.2) into Eq.

(B25.1.1) to yield

yi11 5 yi 1 a1h f (xi, yi) 1 a2h f(xi, yi) 1 a2 p1h 2

0f

0x

1 a2q11h 2 f (xi, yi)

0f

0y 1 O(h3)

or, by collecting terms,

yi11 5 yi 1 [a1 f (xi, yi) 1 a2 f (xi, yi) ]h

1 c a2 p1 0f 0x

1 a2q11 f (xi, yi) 0f

0y d h2 1 O(h3)

(B25.1.7)

Now, comparing like terms in Eqs. (B25.1.6) and (B25.1.7), we

determine that for the two equations to be equivalent, the following

must hold:

a1 1 a2 5 1

a2 p1 5 1

2

a2q11 5 1

2

These three simultaneous equations contain the four unknown con-

stants. Because there is one more unknown than the number of

equations, there is no unique set of constants that satisfy the equa-

tions. However, by assuming a value for one of the constants, we

can determine the other three. Consequently, there is a family of

second-order methods rather than a single version.

732 RUNGE-KUTTA METHODS

Because we can choose an in! nite number of values for a2, there are an in! nite

number of second-order RK methods. Every version would yield exactly the same results

if the solution to the ODE were quadratic, linear, or a constant. However, they yield

different results when (as is typically the case) the solution is more complicated. We

present three of the most commonly used and preferred versions:

Heun Method with a Single Corrector (a2 5 1y2). If a2 is assumed to be 1y2, Eqs. (25.34) and (25.35) can be solved for a1 5 1y2 and pl 5 q11 5 1. These parameters, when substituted into Eq. (25.30), yield

yi11 5 yi 1 a1 2

k1 1 1

2 k2b h (25.36)

where

k1 5 f(xi, yi) (25.36a)

k2 5 f(xi 1 h, yi 1 k1h) (25.36b)

Note that k1 is the slope at the beginning of the interval and k2 is the slope at the end

of the interval. Consequently, this second-order Runge-Kutta method is actually Heun’s

technique without iteration.

The Midpoint Method (a2 5 1). If a2 is assumed to be 1, then a1 5 0, p1 5 q11 5 1y2, and Eq. (25.30) becomes

yi11 5 yi 1 k 2h (25.37)

where

k1 5 f(xi, yi) (25.37a)

k2 5 f axi 1 1 2

h, yi 1 1

2 k1hb (25.37b)

This is the midpoint method.

Ralston’s Method (a2 5 2y3). Ralston (1962) and Ralston and Rabinowitz (1978) determined that choosing a2 5 2y3 provides a minimum bound on the truncation error for the second-order RK algorithms. For this version, a1 5 1y3 and p1 5 q11 5 3y4 and yields

yi11 5 yi 1 a1 3

k1 1 2

3 k2b h (25.38)

where

k1 5 f(xi, yi) (25.38a)

k2 5 f axi 1 3 4

h, yi 1 3

4 k1hb (25.38b)

25.3 RUNGE-KUTTA METHODS 733

EXAMPLE 25.6 Comparison of Various Second-Order RK Schemes

Problem Statement. Use the midpoint method [Eq. (25.37)] and Ralston’s method [Eq. (25.38)] to numerically integrate Eq. (PT7.13)

f(x, y) 5 22×3 1 12×2 2 20x 1 8.5

from x 5 0 to x 5 4 using a step size of 0.5. The initial condition at x 5 0 is y 5 1.

Compare the results with the values obtained using another second-order RK algorithm,

that is, the Heun method without corrector iteration (Table 25.3).

Solution. The ! rst step in the midpoint method is to use Eq. (25.37a) to compute

k1 5 22(0) 3

1 12(0)2 2 20(0) 1 8.5 5 8.5

However, because the ODE is a function of x only, this result has no bearing on the

second step—the use of Eq. (25.37b) to compute

k2 5 22(0.25) 3

1 12(0.25)2 2 20(0.25) 1 8.5 5 4.21875

Notice that this estimate of the slope is much closer to the average value for the interval

(4.4375) than the slope at the beginning of the interval (8.5) that would have been used

for Euler’s approach. The slope at the midpoint can then be substituted into Eq. (25.37)

to predict

y(0.5) 5 1 1 4.21875(0.5) 5 3.109375 et 5 3.4%

The computation is repeated, and the results are summarized in Fig. 25.14 and Table 25.3.

FIGURE 25.14 Comparison of the true solution with numerical solutions using three second-order RK methods and Euler’s method.

y

4

0 x420

Analytical Euler Heun Midpoint Ralston

734 RUNGE-KUTTA METHODS

For Ralston’s method, k1 for the ! rst interval also equals 8.5 and [Eq. (25.38b)]

k2 5 22(0.375) 3

1 12(0.375)2 2 20(0.375) 1 8.5 5 2.58203125

The average slope is computed by

f 5 1

3 (8.5) 1

2

3 (2.58203125) 5 4.5546875

which can be used to predict

y(0.5) 5 1 1 4.5546875(0.5) 5 3.27734375 et 5 21.82%

The computation is repeated, and the results are summarized in Fig. 25.14 and Table

25.3. Notice how all the second-order RK methods are superior to Euler’s method.

25.3.2 Third-Order Runge-Kutta Methods

For n 5 3, a derivation similar to the one for the second-order method can be performed.

The result of this derivation is six equations with eight unknowns. Therefore, values for

two of the unknowns must be speci! ed a priori in order to determine the remaining

parameters. One common version that results is

yi11 5 yi 1 1

6 (k1 1 4k2 1 k3)h (25.39)

where

k1 5 f(xi, yi) (25.39a)

TABLE 25.3 Comparison of true and approximate values of the integral of y9 5 22×3 1 12×2 2 20x 1 8.5, with the initial condition that y 5 1 at x 5 0. The approximate values were computed using three versions of second-order RK methods with a step size of 0.5.

Second-Order Heun Midpoint Ralston RK

x ytrue y |Et| (%) y |Et| (%) y |Et| (%)

0.0 1.00000 1.00000 0 1.00000 0 1.00000 0 0.5 3.21875 3.43750 6.8 3.109375 3.4 3.277344 1.8 1.0 3.00000 3.37500 12.5 2.81250 6.3 3.101563 3.4 1.5 2.21875 2.68750 21.1 1.984375 10.6 2.347656 5.8 2.0 2.00000 2.50000 25.0 1.75 12.5 2.140625 7.0 2.5 2.71875 3.18750 17.2 2.484375 8.6 2.855469 5.0 3.0 4.00000 4.37500 9.4 3.81250 4.7 4.117188 2.9 3.5 4.71875 4.93750 4.6 4.609375 2.3 4.800781 1.7 4.0 3.00000 3.00000 0 3 0 3.031250 1.0

25.3 RUNGE-KUTTA METHODS 735

k2 5 f axi 1 1 2

h, yi 1 1

2 k1hb (25.39b)

k3 5 f(xi 1 h, yi 2 k1h 1 2k2h) (25.39c)

Note that if the derivative is a function of x only, this third-order method reduces to

Simpson’s 1y3 rule. Ralston (1962) and Ralston and Rabinowitz (1978) have developed an alternative version that provides a minimum bound on the truncation error. In any

case, the third-order RK methods have local and global errors of O(h4) and O(h3), re-

spectively, and yield exact results when the solution is a cubic. When dealing with

polynomials, Eq. (25.39) will also be exact when the differential equation is cubic and

the solution is quartic. This is because Simpson’s 1y3 rule provides exact integral esti- mates for cubics (recall Box 21.3).

25.3.3 Fourth-Order Runge-Kutta Methods

The most popular RK methods are fourth order. As with the second-order approaches,

there are an in! nite number of versions. The following is the most commonly used form,

and we therefore call it the classical fourth-order RK method:

yi11 5 yi 1 1

6 (k1 1 2k2 1 2k3 1 k4)h (25.40)

where

k1 5 f(xi, yi) (25.40a)

k2 5 f axi 1 1 2

h, yi 1 1

2 k1hb (25.40b)

FIGURE 25.15 Graphical depiction of the slope estimates comprising the fourth-order RK method.

y

xxi+1/2

h

xi

k2

k1

k3

k3

k2

k1

k4

xi+1

736 RUNGE-KUTTA METHODS

k3 5 f axi 1 1 2

h, yi 1 1

2 k2hb (25.40c)

k4 5 f(xi 1 h, yi 1 k3h) (25.40d)

Notice that for ODEs that are a function of x alone, the classical fourth-order RK

method is similar to Simpson’s 1y3 rule. In addition, the fourth-order RK method is similar to the Heun approach in that multiple estimates of the slope are developed in order

to come up with an improved average slope for the interval. As depicted in Fig. 25.15,

each of the k’s represents a slope. Equation (25.40) then represents a weighted average

of these to arrive at the improved slope.

EXAMPLE 25.7 Classical Fourth-Order RK Method

Problem Statement.

(a) Use the classical fourth-order RK method [Eq. (25.40)] to integrate

f(x, y) 5 22×3 1 12×2 2 20x 1 8.5

using a step size of h 5 0.5 and an initial condition of y 5 1 at x 5 0.

(b) Similarly, integrate

f(x, y) 5 4e0.8x 2 0.5y

using h 5 0.5 with y(0) 5 2 from x 5 0 to 0.5.

Solution.

(a) Equations (25.40a) through (25.40d) are used to compute k1 5 8.5, k2 5 4.21875,

k3 5 4.21875 and k4 5 1.25, which are substituted into Eq. (25.40) to yield

y(0.5) 5 1 1 e 1 6

[8.5 1 2(4.21875) 1 2(4.21875) 1 1.25] f 0.5 5 3.21875

which is exact. Thus, because the true solution is a quartic [Eq. (PT7.16)], the fourth-

order method gives an exact result.

(b) For this case, the slope at the beginning of the interval is computed as

k1 5 f(0, 2) 5 4e 0.8(0)

2 0.5(2) 5 3

This value is used to compute a value of y and a slope at the midpoint,

y(0.25) 5 2 1 3(0.25) 5 2.75

k2 5 f(0.25, 2.75) 5 4e 0.8(0.25)

2 0.5(2.75) 5 3.510611

This slope in turn is used to compute another value of y and another slope at the midpoint,

y(0.25) 5 2 1 3.510611(0.25) 5 2.877653

k3 5 f(0.25, 2.877653) 5 4e 0.8(0.25)

2 0.5(2.877653) 5 3.446785

Next, this slope is used to compute a value of y and a slope at the end of the interval,

y(0.5) 5 2 1 3.071785(0.5) 5 3.723392

k4 5 f(0.5, 3.723392) 5 4e 0.8(0.5)

2 0.5(3.723392) 5 4.105603

25.3 RUNGE-KUTTA METHODS 737

Finally, the four slope estimates are combined to yield an average slope. This average

slope is then used to make the ! nal prediction at the end of the interval.

f 5 1

6 [3 1 2(3.510611) 1 2(3.446785) 1 4.105603] 5 3.503399

y(0.5) 5 2 1 3.503399(0.5) 5 3.751699

which compares favorably with the true solution of 3.751521.

25.3.4 Higher-Order Runge-Kutta Methods

Where more accurate results are required, Butcher’s (1964) fth-order RK method is

recommended:

yi11 5 yi 1 1

90 (7k1 1 32k3 1 12k4 1 32k5 1 7k6)h (25.41)

where

k1 5 f(xi, yi) (25.41a)

k2 5 f axi 1 1 4

h, yi 1 1

4 k1hb (25.41b)

k3 5 f axi 1 1 4

h, yi 1 1

8 k1h 1

1

8 k2hb (25.41c)

k4 5 f axi 1 1 2

h, yi 2 1

2 k2h 1 k3hb (25.41d)

k5 5 f axi 1 3 4

h, yi 1 3

16 k1h 1

9

16 k4hb (25.41e)

k6 5 f axi 1 h, yi 2 3 7

k1h 1 2

7 k2h 1

12

7 k3h 2

12

7 k4h 1

8

7 k5hb (25.41f)

Note the similarity between Butcher’s method and Boole’s rule in Table 21.2. Higher-order

RK formulas such as Butcher’s method are available, but in general, beyond fourth-order

methods the gain in accuracy is offset by the added computational effort and complexity.

EXAMPLE 25.8 Comparison of Runge-Kutta Methods

Problem Statement. Use ! rst- through ! fth-order RK methods to solve

f(x, y) 5 4e0.8x 2 0.5y

with y(0) 5 2 from x 5 0 to x 5 4 with various step sizes. Compare the accuracy of

the various methods for the result at x 5 4 based on the exact answer of y(4) 5 75.33896.

Solution. The computation is performed using Euler’s, the noniterative Heun, the third- order RK [Eq. (25.39)], the classical fourth-order RK, and Butcher’s ! fth-order RK

methods. The results are presented in Fig. 25.16, where we have plotted the absolute

738 RUNGE-KUTTA METHODS

value of the percent relative error versus the computational effort. This latter quantity is

equivalent to the number of function evaluations required to attain the result, as in

Effort 5 nf b 2 a

h (E25.8.1)

where nf 5 the number of function evaluations involved in the particular RK computa-

tion. For orders # 4, nf is equal to the order of the method. However, note that Butcher’s

! fth-order technique requires six function evaluations [Eq. (25.41a) through (25.41f)].

The quantity (b 2 a)yh is the total integration interval divided by the step size—that is, it is the number of applications of the RK technique required to obtain the result. Thus,

because the function evaluations are usually the primary time-consuming steps, Eq. (E25.8.1)

provides a rough measure of the run time required to attain the answer.

Inspection of Fig. 25.16 leads to a number of conclusions: ! rst, that the higher-order

methods attain better accuracy for the same computational effort and, second, that the

gain in accuracy for the additional effort tends to diminish after a point. (Notice that the

curves drop rapidly at ! rst and then tend to level off.)

Example 25.8 and Fig. 25.16 might lead one to conclude that higher-order RK tech-

niques are always the preferred methods. However, other factors such as programming

FIGURE 25.16 Comparison of percent relative error versus computational effort for fi rst- through fi fth-order RK methods.

100

1

10– 2

10– 4

10– 6

Euler

Heun

RK–3d

RK–4th

Butcher

Effort

P e rc

e n

t re

la ti

v e e

rr o

r

25.4 SYSTEMS OF EQUATIONS 739

costs and the accuracy requirements of the problem also must be considered when choos-

ing a solution technique. Such trade-offs will be explored in detail in the engineering

applications in Chap. 28 and in the epilogue for Part Seven.

25.3.5 Computer Algorithms for Runge-Kutta Methods

As with all the methods covered in this chapter, the RK techniques ! t nicely into the

general algorithm embodied in Fig. 25.7. Figure 25.17 presents pseudocode to determine

the slope of the classic fourth-order RK method [Eq. (25.40)]. Subroutines to compute

slopes for all the other versions can be easily programmed in a similar fashion.

25.4 SYSTEMS OF EQUATIONS

Many practical problems in engineering and science require the solution of a system of

simultaneous ordinary differential equations rather than a single equation. Such systems

may be represented generally as

dy1

dx 5 f1(x, y1, y2, p , yn)

dy2

dx 5 f2(x, y1, y2, p , yn)

#

#

#

dyn

dx 5 fn(x, y1, y2, p , yn) (25.42)

The solution of such a system requires that n initial conditions be known at the starting

value of x.

SUB RK4 (x, y, h, ynew)

CALL Derivs(x, y, k1)

ym 5 y 1 k1 ? hy2 CALL Derivs(x 1 hy2, ym, k2) ym 5 y 1 k2 ? hy2 CALL Derivs(x 1 hy2, ym, k3) ye 5 y 1 k3 ? h

CALL Derivs(x 1 h, ye, k4)

slope 5 (k1 1 2(k2 1 k3) 1 k4)y6 ynew 5 y 1 slope ? h

x 5 x 1 h

END SUB

FIGURE 25.17 Pseudocode to determine a single step of the fourth-order RK method.

740 RUNGE-KUTTA METHODS

25.4.1 Euler’s Method

All the methods discussed in this chapter for single equations can be extended to the

system shown above. Engineering applications can involve thousands of simultaneous

equations. In each case, the procedure for solving a system of equations simply involves

applying the one-step technique for every equation at each step before proceeding to the

next step. This is best illustrated by the following example for the simple Euler’s method.

EXAMPLE 25.9 Solving Systems of ODEs Using Euler’s Method

Problem Statement. Solve the following set of differential equations using Euler’s method, assuming that at x 5 0, y1 5 4, and y2 5 6. Integrate to x 5 2 with a step size

of 0.5.

dy1

dx 5 20.5y1

dy2

dx 5 4 2 0.3y2 2 0.1y1

Solution. Euler’s method is implemented for each variable as in Eq. (25.2):

y1(0.5) 5 4 1 [20.5(4)]0.5 5 3

y2(0.5) 5 6 1 [4 2 0.3(6) 2 0.1(4)]0.5 5 6.9

Note that y1(0) 5 4 is used in the second equation rather than the y1(0.5) 5 3 computed

with the ! rst equation. Proceeding in a like manner gives

x y1 y2

0 4 6 0.5 3 6.9 1.0 2.25 7.715 1.5 1.6875 8.44525 2.0 1.265625 9.094087

25.4.2 Runge-Kutta Methods

Note that any of the higher-order RK methods in this chapter can be applied to systems

of equations. However, care must be taken in determining the slopes. Figure 25.15 is help-

ful in visualizing the proper way to do this for the fourth-order method. That is, we ! rst

develop slopes for all variables at the initial value. These slopes (a set of k1’s) are then

used to make predictions of the dependent variable at the midpoint of the interval. These

midpoint values are in turn used to compute a set of slopes at the midpoint (the k2’s). These

new slopes are then taken back to the starting point to make another set of midpoint pre-

dictions that lead to new slope predictions at the midpoint (the k3’s). These are then em-

ployed to make predictions at the end of the interval that are used to develop slopes at the

end of the interval (the k4’s). Finally, the k’s are combined into a set of increment functions

[as in Eq. (25.40)] and brought back to the beginning to make the ! nal prediction. The

following example illustrates the approach.

25.4 SYSTEMS OF EQUATIONS 741

EXAMPLE 25.10 Solving Systems of ODEs Using the Fourth-Order RK Method

Problem Statement. Use the fourth-order RK method to solve the ODEs from Ex- ample 25.9.

Solution. First, we must solve for all the slopes at the beginning of the interval:

k1,1 5 f1(0, 4, 6) 5 20.5(4) 5 22

k1, 2 5 f2(0, 4, 6) 5 4 2 0.3(6) 2 0.1(4) 5 1.8

where ki, j is the ith value of k for the jth dependent variable. Next, we must calculate

the ! rst values of y1 and y2 at the midpoint:

y1 1 k1,1 h

2 5 4 1 (22)

0.5

2 5 3.5

y2 1 k1, 2 h

2 5 6 1 (1.8)

0.5

2 5 6.45

which can be used to compute the ! rst set of midpoint slopes,

k2, 1 5 f1(0.25, 3.5, 6.45) 5 21.75

k2, 2 5 f2(0.25, 3.5, 6.45) 5 1.715

These are used to determine the second set of midpoint predictions,

y1 1 k2,1 h

2 5 4 1 (21.75)

0.5

2 5 3.5625

y2 1 k2, 2 h

2 5 6 1 (1.715)

0.5

2 5 6.42875

which can be used to compute the second set of midpoint slopes,

k3, 1 5 f1(0.25, 3.5625, 6.42875) 5 21.78125

k3, 2 5 f2(0.25, 3.5625, 6.42875) 5 1.715125

These are used to determine the predictions at the end of the interval

y1 1 k3,1h 5 4 1 (21.78125)(0.5) 5 3.109375

y2 1 k3, 2h 5 6 1 (1.715125)(0.5) 5 6.857563

which can be used to compute the endpoint slopes,

k4,1 5 f1(0.5, 3.109375, 6.857563) 5 21.554688

k4, 2 5 f2(0.5, 3.109375, 6.857563) 5 1.631794

The values of k can then be used to compute [Eq. (25.40)]:

y1(0.5) 5 4 1 1

6 [22 1 2(21.75 2 1.78125) 2 1.554688]0.5 5 3.115234

y2(0.5) 5 6 1 1

6 [1.8 1 2(1.715 1 1.715125) 1 1.631794]0.5 5 6.857670

742 RUNGE-KUTTA METHODS

Proceeding in a like manner for the remaining steps yields

x y1 y2

0 4 6 0.5 3.115234 6.857670 1.0 2.426171 7.632106 1.5 1.889523 8.326886 2.0 1.471577 8.946865

25.4.3 Computer Algorithm for Solving Systems of ODEs

The computer code for solving a single ODE with Euler’s method (Fig. 25.7) can be

easily extended to systems of equations. The modi! cations include:

1. Inputting the number of equations, n.

2. Inputting the initial values for each of the n dependent variables.

3. Modifying the algorithm so that it computes slopes for each of the dependent

variables.

4. Including additional equations to compute derivative values for each of the ODEs.

5. Including loops to compute a new value for each dependent variable.

Such an algorithm is outlined in Fig. 25.18 for the fourth-order RK method. Notice

how similar it is in structure and organization to Fig. 25.7. Most of the differences relate

to the fact that

1. There are n equations.

2. The added detail of the fourth-order RK method.

EXAMPLE 25.11 Solving Systems of ODEs with the Computer

Problem Statement. A computer program to implement the fourth-order RK method for systems can be easily developed based on Fig. 25.18. Such software makes it con-

venient to compare different models of a physical system. For example, a linear model

for a swinging pendulum is given by [recall Eq. (PT7.11)]

dy1

dx 5 y2

dy2

dx 5 216.1y1

where y1 and y2 5 angular displacement and velocity. A nonlinear model of the same

system is [recall Eq. (PT7.9)]

dy3

dx 5 y4

dy4

dx 5 216.1 sin(y3)

where y3 and y4 5 angular displacement and velocity for the nonlinear case. Solve these

systems for two cases: (a) a small initial displacement (y1 5 y3 5 0.1 radians; y2 5 y4 5 0)

and (b) a large displacement (y1 5 y3 5 py4 5 0.785398 radians; y2 5 y4 5 0).

25.4 SYSTEMS OF EQUATIONS 743

(a) Main or “Driver” Program

Assign values for

n 5 number of equations

yi 5 initial values of n dependent

variables

xi 5 initial value independent

variable

xf 5 final value independent variable

dx 5 calculation step size

xout 5 output interval

x 5 xi

m 5 0

xpm 5 x

DOFOR i 5 1, n

ypi,m 5 yii

yi 5 yii

END DO

DO

xend 5 x 1 xout

IF (xend . xf) THEN xend 5 xf

h 5 dx

CALL Integrator (x, y, n, h, xend)

m 5 m 1 1

xpm 5 x

DOFOR i 5 1, n

ypi,m 5 yi

END DO

IF (x $ xf) EXIT

END DO

DISPLAY RESULTS

END

(b) Routine to Take One Output Step

SUB Integrator (x, y, n, h, xend)

DO

IF (xend 2 x , h) THEN h 5 xend 2 x

CALL RK4 (x, y, n, h)

IF (x $ xend) EXIT

END DO

END SUB

(c) Fourth-Order RK Method for a System of ODEs

SUB RK4 (x, y, n, h)

CALL Derivs (x, y, k1)

DOFOR i 5 1, n

ymi 5 yi 1 k1i * h / 2

END DO

CALL Derivs (x 1 h / 2, ym, k2)

DOFOR i 5 1, n

ymi 5 yi 1 k2i * h / 2

END DO

CALL Derivs (x 1 h / 2, ym, k3)

DOFOR i 5 1, n

yei 5 yi 1 k3i * h

END DO

CALL Derivs (x 1 h, ye, k4)

DOFOR i 5 1, n

slopei 5 (k1i 1 2*(k2i1k3i)1k4i)/6

yi 5 yi 1 slopei * h

END DO

x 5 x 1 h

END SUB

(d ) Routine to Determine Derivatives

SUB Derivs (x, y, dy)

dy1 5 …

dy2 5 …

END SUB

FIGURE 25.18 Pseudocode for the fourth-order RK method for systems.

744 RUNGE-KUTTA METHODS

Solution.

(a) The calculated results for the linear and nonlinear models are almost identical

(Fig. 25.19a). This is as expected because when the initial displacement is small,

sin (u) > u. (b) When the initial displacement is py4 5 0.785398, the solutions are much different

and the difference is magni! ed as time becomes larger and larger (Fig. 25.19b). This

is expected because the assumption that sin (u) 5 u is poor when theta is large.

25.5 ADAPTIVE RUNGE-KUTTA METHODS

To this point, we have presented methods for solving ODEs that employ a constant step

size. For a signi! cant number of problems, this can represent a serious limitation. For

example, suppose that we are integrating an ODE with a solution of the type depicted

in Fig. 25.20. For most of the range, the solution changes gradually. Such behavior sug-

gests that a fairly large step size could be employed to obtain adequate results. However,

for a localized region from x 5 1.75 to x 5 2.25, the solution undergoes an abrupt change.

The practical consequence of dealing with such functions is that a very small step size

would be required to accurately capture the impulsive behavior. If a constant step-size al-

gorithm were employed, the smaller step size required for the region of abrupt change would

have to be applied to the entire computation. As a consequence, a much smaller step size

than necessary—and, therefore, many more calculations—would be wasted on the regions

of gradual change.

4

2

0y

0 321

x

– 4

– 2

4

y1, y3

y2, y4

(a)

4

2

0y

0 2 31

x

– 4

– 2

4

y2 y4

y3

y1

(b)

FIGURE 25.19 Solutions obtained with a computer program for the fourth-order RK method. The plots represent solutions for both linear and nonlinear pendulums with (a) small and (b) large initial displacements.

25.5 ADAPTIVE RUNGE-KUTTA METHODS 745

Algorithms that automatically adjust the step size can avoid such overkill and hence

be of great advantage. Because they “adapt” to the solution’s trajectory, they are said to

have adaptive step-size control. Implementation of such approaches requires that an es-

timate of the local truncation error be obtained at each step. This error estimate can then

serve as a basis for either lengthening or decreasing the step size.

Before proceeding, we should mention that aside from solving ODEs, the methods

described in this chapter can also be used to evaluate de! nite integrals. As mentioned

previously in the introduction to Part Six, the evaluation of the integral

I 5 # b

a f(x) dx

is equivalent to solving the differential equation

dy

dx 5 f(x)

for y(b) given the initial condition y(a) 5 0. Thus, the following techniques can be em-

ployed to ef! ciently evaluate de! nite integrals involving functions that are generally

smooth but exhibit regions of abrupt change.

There are two primary approaches to incorporate adaptive step-size control into one-

step methods. In the ! rst, the error is estimated as the difference between two predictions

using the same-order RK method but with different step sizes. In the second, the local

FIGURE 25.20 An example of a solution of an ODE that exhibits an abrupt change. Automatic step-size adjustment has great advantages for such cases.

1

0 1 2 3

y

x

746 RUNGE-KUTTA METHODS

truncation error is estimated as the difference between two predictions using different-

order RK methods.

25.5.1 Adaptive RK or Step-Halving Method

Step halving (also called adaptive RK) involves taking each step twice, once as a full

step and independently as two half steps. The difference in the two results represents an

estimate of the local truncation error. If y1 designates the single-step prediction and y2

designates the prediction using the two half steps, the error D can be represented as

¢ 5 y2 2 y1 (25.43)

In addition to providing a criterion for step-size control, Eq. (25.43) can also be used to

correct the y2 prediction. For the fourth-order RK version, the correction is

y2 d y2 1 ¢

15 (25.44)

This estimate is ! fth-order accurate.

EXAMPLE 25.12 Adaptive Fourth-Order RK Method

Problem Statement. Use the adaptive fourth-order RK method to integrate y9 5 4e0.8x 2 0.5y from x 5 0 to 2 using h 5 2 and an initial condition of y(0) 5 2. This is the same

differential equation that was solved previously in Example 25.5. Recall that the true

solutions is y(2) 5 14.84392.

Solution. The single prediction with a step of h is computed as

y(2) 5 2 1 1

6 [3 1 2(6.40216 1 4.70108) 1 14.11105]2 5 15.10584

The two half-step predictions are

y(1) 5 2 1 1

6 [3 1 2(4.21730 1 3.91297) 1 5.945681]1 5 6.20104

and

y(2) 5 6.20104 1 1

6 [5.80164 1 2(8.72954 1 7.99756) 1 12.71283]1 5 14.86249

Therefore, the approximate error is

Ea 5 14.86249 2 15.10584

15 5 20.01622

which compares favorably with the true error of

Et 5 14.84392 2 14.86249 5 20.01857

The error estimate can also be used to correct the prediction

y(2) 5 14.86249 2 0.01622 5 14.84627

which has an Et 5 20.00235.

25.5 ADAPTIVE RUNGE-KUTTA METHODS 747

25.5.2 Runge-Kutta Fehlberg

Aside from step halving as a strategy to adjust step size, an alternative approach for

obtaining an error estimate involves computing two RK predictions of different order.

The results can then be subtracted to obtain an estimate of the local truncation error. One

shortcoming of this approach is that it greatly increases the computational overhead. For

example, a fourth- and ! fth-order prediction amount to a total of 10 function evaluations

per step. The Runge-Kutta Fehlberg or embedded RK method cleverly circumvents this

problem by using a ! fth-order RK method that employs the function evaluations from

the accompanying fourth-order RK method. Thus, the approach yields the error estimate

on the basis of only six function evaluations!

For the present case, we use the following fourth-order estimate

yi11 5 yi 1 a 37 378

k1 1 250

621 k3 1

125

594 k4 1

512

1771 k6b h (25.45)

along with the ! fth-order formula:

yi11 5 yi 1 a 2825 27,648

k1 1 18,575

48,384 k3 1

13,525

55,296 k4 1

277

14,336 k5 1

1

4 k6b h (25.46)

where

k1 5 f(xi, yi)

k2 5 f axi 1 1 5

h, yi 1 1

5 k1hb

k3 5 f axi 1 3 10

h, yi 1 3

40 k1h 1

9

40 k2hb

k4 5 f axi 1 3 5

h, yi 1 3

10 k1h 2

9

10 k2h 1

6

5 k3hb

k5 5 f axi 1 h, yi 2 11 54

k1h 1 5

2 k2h 2

70

27 k3h 1

35

27 k4hb

k6 5 f axi 1 7 8

h, yi 1 1631

55,296 k1h 1

175

512 k2h 1

575

13,824 k3h 1

44,275

110,592 k4h

1 253

4096 k5hb

Thus, the ODE can be solved with Eq. (25.46) and the error estimated as the difference

of the ! fth- and fourth-order estimates. It should be noted that the particular coef! cients

used above were developed by Cash and Karp (1990). Therefore, it is sometimes called

the Cash-Karp RK method.

EXAMPLE 25.13 Runge-Kutta Fehlberg Method

Problem Statement. Use the Cash-Karp version of the Runge-Kutta Fehlberg approach to perform the same calculation as in Example 25.12 from x 5 0 to 2 using h 5 2.

748 RUNGE-KUTTA METHODS

Solution. The calculation of the k’s can be summarized in the following table:

x y f(x, y)

k1 0 2 3 k2 0.4 3.2 3.908511 k3 0.6 4.20883 4.359883 k4 1.2 7.228398 6.832587 k5 2 15.42765 12.09831 k6 1.75 12.17686 10.13237

These can then be used to compute the fourth-order prediction

y1 5 2 1 a 37 378

3 1 250

621 4.359883 1

125

594 6.832587 1

512

1771 10.13237b 2 5 14.83192

along with a ! fth-order formula:

y1 5 2 1 a 2825 27,648

3 1 18,575

48,384 4.359883 1

13,525

55,296 6.832587

1 227

14,336 12.09831 1

1

4 10.13237b 2 5 14.83677

The error estimate is obtained by subtracting these two equations to give

Ea 5 14.83677 2 14.83192 5 0.004842

25.5.3 Step-Size Control

Now that we have developed ways to estimate the local truncation error, it can be used

to adjust the step size. In general, the strategy is to increase the step size if the error is

too small and decrease it if the error is too large. Press et al. (2007) have suggested the

following criterion to accomplish this:

hnew 5 hpresent ` ¢new ¢present

` a (25.47) where hpresent and hnew 5 the present and the new step sizes, respectively, Dpresent 5 the

computed present accuracy, Dnew 5 the desired accuracy, and a 5 a constant power that

is equal to 0.2 when the step size is increased (that is, when Dpresent # Dnew) and 0.25

when the step size is decreased (Dpresent . Dnew).

The key parameter in Eq. (25.47) is obviously Dnew because it is your vehicle for

specifying the desired accuracy. One way to do this would be to relate Dnew to a rela-

tive error level. Although this works well when only positive values occur, it can cause

problems for solutions that pass through zero. For example, you might be simulating

an oscillating function that repeatedly passes through zero but is bounded by maximum

absolute values. For such a case, you might want these maximum values to ! gure in

the desired accuracy.

25.5 ADAPTIVE RUNGE-KUTTA METHODS 749

A more general way to handle such cases is to determine Dnew as

¢new 5 eyscale

where e 5 an overall tolerance level. Your choice of yscale will then determine how the error

is scaled. For example, if yscale 5 y, the accuracy will be couched in terms of fractional

relative errors. If you are dealing with a case where you desire constant errors relative to

a prescribed maximum bound, set yscale equal to that bound. A trick suggested by Press

et al. (2007) to obtain the constant relative errors except very near zero crossings is

yscale 5 Zy Z 1 ` h dy dx `

This is the version we will use in our algorithm.

25.5.4 Computer Algorithm

Figures 25.21 and 25.22 outline pseudocode to implement the Cash-Karp version of the

Runge-Kutta Fehlberg algorithm. This algorithm is patterned after a more detailed imple-

mentation by Press et al. (2007) for systems of ODEs.

Figure 25.21 implements a single step of the Cash-Karp routine (that is Eqs. 25.45

and 25.46). Figure 25.22 outlines a general driver program along with a subroutine that

actually adapts the step size.

SUBROUTINE RKkc (y,dy,x,h,yout,yerr)

PARAMETER (a250.2,a350.3,a450.6,a551.,a650.875,

b2150.2,b3153.y40.,b3259.y40.,b4150.3,b42520.9,

b4351.2,b515211.y54.,b5252.5,b535270.y27.,

b54535.y27.,b6151631.y55296.,b625175.y512.,

b635575.y13824.,b64544275.y110592.,b655253.y4096.,

c1537.y378.,c35250.y621.,c45125.y594.,

c65512.y1771.,dc15c122825.y27648.,

dc35c3218575.y48384.,dc45c4213525.y55296.,

dc552277.y14336.,dc65c620.25)

ytemp5y1b21*h*dy

CALL Derivs (x1a2*h,ytemp,k2)

ytemp5y1h*(b31*dy1b32*k2)

CALL Derivs(x1a3*h,ytemp,k3)

ytemp5y1h*(b41*dy1b42*k21b43*k3)

CALL Derivs(x1a4*h,ytemp,k4)

ytemp5y1h*(b51*dy1b52*k21b53*k31b54*k4)

CALL Derivs(x1a5*h,ytemp,k5)

ytemp5y1h*(b61*dy1b62*k21b63*k31b64*k41b65*k5)

CALL Derivs(x1a6*h,ytemp,k6)

yout5y1h*(c1*dy1c3*k31c4*k41c6*k6)

yerr5h*(dc1*dy1dc3*k31dc4*k41dc5*k51dc6*k6)

END RKkc

FIGURE 25.21 Pseudocode for a single step of the Cash-Karp RK method.

750 RUNGE-KUTTA METHODS

EXAMPLE 25.14 Computer Application of an Adaptive Fourth-Order RK Scheme

Problem Statement. The adaptive RK method is well-suited for the following ordinary differential equation

dy

dx 1 0.6y 5 10e2(x22)

2y[2(0.075)2] (E25.14.1)

Notice for the initial condition, y(0) 5 0.5, the general solution is

y 5 0.5e20.6x (E25.14.2)

which is a smooth curve that gradually approaches zero as x increases. In contrast, the

particular solution undergoes an abrupt transition in the vicinity of x 5 2 due to the nature

of the forcing function (Fig. 25.23a). Use a standard fourth-order RK scheme to solve

Eq. (E25.14.1) from x 5 0 to 4. Then employ the adaptive scheme described in this sec-

tion to perform the same computation.

Solution. First, the classical fourth-order scheme is used to compute the solid curve in Fig. 25.23b. For this computation, a step size of 0.1 is used so that 4y(0.1) 5 40 applica- tions of the technique are made. Then, the calculation is repeated with a step size of 0.05

for a total of 80 applications. The major discrepancy between the two results occurs in the

region from 1.8 to 2.0. The magnitude of the discrepancy is about 0.1 to 0.2 percent.

(a) Driver Program

INPUT xi, xf, yi

maxstep5100

hi5.5; tiny 5 1. 3 10230

eps50.00005

print *, xi,yi

x5xi

y5yi

h5hi

istep50

DO

IF (istep . maxstep AND x # xf) EXIT

istep5istep11

CALL Derivs(x,y,dy)

yscal5ABS(y)1ABS(h*dy)1tiny

IF (x1h.xf) THEN h5xf2x

CALL Adapt (x,y,dy,h,yscal,eps,hnxt)

PRINT x,y

h5hnxt

END DO

END

(b) Adaptive Step Routine

SUB Adapt (x,y,dy,htry,yscal,eps,hnxt)

PARAMETER (safety50.9, econ51.89e24)

h5htry

DO

CALL RKkc (y,dy,x,h,ytemp,yerr)

emax5abs(yerr/yscal/eps)

IF emax # 1 EXIT

htemp5safety*h*emax 20.25

h5max(abs(htemp),0.25*abs(h))

xnew5x1h

IF xnew5x THEN pause

END DO

IF emax . econ THEN

hnxt5safety*emax 2.2 *h

ELSE

hnxt54.*h

END IF

x5x1h

y5ytemp

END Adapt

FIGURE 25.22 Pseudocode for a (a) driver program and an (b) adaptive step routine to solve a single ODE.

25.5 ADAPTIVE RUNGE-KUTTA METHODS 751

Next, the algorithm in Figs. 25.21 and 25.22 is developed into a computer program

and used to solve the same problem. An initial step size of 0.5 and an e 5 0.00005 were

chosen. The results were superimposed on Fig. 25.23b. Notice how large steps are taken

in the regions of gradual change. Then, in the vicinity of x 5 2, the steps are decreased

to accommodate the abrupt nature of the forcing function.

FIGURE 25.23 (a) A bell-shaped forcing function that induces an abrupt change in the solution of an ODE [Eq. (E25.14.1)]. (b) The solution. The points indicate the predictions of an adaptive step-size routine.

0

1

2

0 2 4 x

(b)

0

5

10

0 2 4 x

(a)

The utility of an adaptive integration scheme obviously depends on the nature of the

functions being modeled. It is particularly advantageous for those solutions with long

smooth stretches and short regions of abrupt change. In addition, it has utility in those

situations where the correct step size is not known a priori. For these cases, an adaptive

routine will “feel” its way through the solution while keeping the results within the

desired tolerance. Thus, it will tiptoe through the regions of abrupt change and step out

briskly when the variations become more gradual.

752 RUNGE-KUTTA METHODS

PROBLEMS

25.1 Solve the following initial value problem over the interval from

t 5 0 to 2 where y(0) 5 1. Display all your results on the same graph.

dy

dt 5 yt 2 2 1.1y

(a) Analytically.

(b) Euler’s method with h 5 0.5 and 0.25.

(c) Midpoint method with h 5 0.5.

(d) Fourth-order RK method with h 5 0.5.

25.2 Solve the following problem over the interval from x 5 0 to 1

using a step size of 0.25 where y(0) 5 1. Display all your results on

the same graph.

dy

dt 5 (1 1 4t)1y

(a) Analytically.

(b) Euler’s method.

(c) Heun’s method without iteration.

(d) Ralston’s method.

(e) Fourth-order RK method.

25.3 Use the (a) Euler and (b) Heun (without iteration) methods to

solve

d 2y

dt 2 2 0.5t 1 y 5 0

where y(0) 5 2 and y9(0) 5 0. Solve from x 5 0 to 4 using h 5 0.1.

Compare the methods by plotting the solutions.

25.4 Solve the following problem with the fourth-order RK method:

d 2y

dx 2 1 0.6

dy

dx 1 8y 5 0

where y(0) 5 4 and y9(0) 5 0. Solve from x 5 0 to 5 with h 5 0.5.

Plot your results.

25.5 Solve from t 5 0 to 3 with h 5 0.1 using (a) Heun (without

corrector) and (b) Ralston’s second-order RK method:

dy

dt 5 y sin3(t) y(0) 5 1

25.6 Solve the following problem numerically from t 5 0 to 3:

dy

dt 5 22y 1 t2 y(0) 5 1

Use the third-order RK method with a step size of 0.5.

25.7 Use (a) Euler’s and (b) the fourth-order RK method to solve

dy

dt 5 22y 1 5e2t

dz

dt 5 2

yz2

2

over the range t 5 0 to 0.4 using a step size of 0.1 with y(0) 5 2 and

z(0) 5 4.

25.8 Compute the ” rst step of Example 25.14 using the adaptive

fourth-order RK method with h 5 0.5. Verify whether step-size

adjustment is in order.

25.9 If e 5 0.001, determine whether step size adjustment is re-

quired for Example 25.12.

25.10 Use the RK-Fehlberg approach to perform the same calcula-

tion as in Example 25.12 from x 5 0 to 1 with h 5 1.

25.11 Write a computer program based on Fig. 25.7. Among other

things, place documentation statements throughout the program to

identify what each section is intended to accomplish.

25.12 Test the program you developed in Prob. 25.11 by duplicat-

ing the computations from Examples 25.1 and 25.4.

25.13 Develop a user-friendly program for the Heun method with

an iterative corrector. Test the program by duplicating the results in

Table 25.2.

25.14 Develop a user-friendly computer program for the classical

fourth-order RK method. Test the program by duplicating Exam-

ple 25.7.

25.15 Develop a user-friendly computer program for systems of

equations using the fourth-order RK method. Use this program to

duplicate the computation in Example 25.10.

25.16 The motion of a damped spring-mass system (Fig. P25.16)

is described by the following ordinary differential equation:

m d 2x

dt2 1 c

dx

dt 1 kx 5 0

where x 5 displacement from equilibrium position (m), t 5 time

(s), m 5 20-kg mass, and c 5 the damping coef” cient (N ? s/m).

The damping coef” cient c takes on three values of 5 (under-

damped), 40 (critically damped), and 200 (overdamped). The

spring constant k 5 20 N/m. The initial velocity is zero, and the

initial displacement x 5 1 m. Solve this equation using a numerical

method over the time period 0 # t # 15 s. Plot the displacement

versus time for each of the three values of the damping coef” cient

on the same curve.

FIGURE P25.16

k

c

x

m

PROBLEMS 753

25.21 The logistic model is used to simulate population as in

dp

dt 5 kgm(1 2 pypmax)p

where p 5 population, kgm 5 the maximum growth rate under un-

limited conditions, and pmax 5 the carrying capacity. Simulate the

world’s population from 1950 to 2000 using one of the numerical

methods described in this chapter. Employ the following initial

conditions and parameter values for your simulation: p0 (in 1950) 5

2555 million people, kgm 5 0.026/yr, and pmax 5 12,000 million

people. Have the function generate output corresponding to the

dates for the following measured population data. Develop a plot of

your simulation along with these data.

t 1950 1960 1970 1980 1990 2000

p 2555 3040 3708 4454 5276 6079

25.22 Suppose that a projectile is launched upward from the

earth’s surface. Assume that the only force acting on the object is

the downward force of gravity. Under these conditions, a force

balance can be used to derive,

dy

dt 5 2g(0)

R2

(R 1 x)2

where y 5 upward velocity (m/s), t 5 time (s), x 5 altitude (m)

measured upwards from the earth’s surface, g(0) 5 the gravita-

tional acceleration at the earth’s surface (> 9.81 m/s2), and R 5 the earth’s radius (> 6.37 3 106 m). Recognizing that dx/dt 5 y, use Euler’s method to determine the maximum height that would be

obtained if y(t 5 0) 5 1500 m/s.

25.23 The following function exhibits both # at and steep regions

over a relatively short x region:

f (x) 5 1

(x 2 0.3)2 1 0.01 1

1

(x 2 0.9)2 1 0.04 2 6

Determine the value of the de” nite integral of this function between

x 5 0 and 1 using an adaptive RK method.

25.17 If water is drained from a vertical cylindrical tank by open-

ing a valve at the base, the water will # ow fast when the tank is full

and slow down as it continues to drain. As it turns out, the rate at

which the water level drops is:

dy

dt 5 2k1y

where k is a constant depending on the shape of the hole and the

cross-sectional area of the tank and drain hole. The depth of the

water y is measured in meters and the time t in minutes. If k 5 0.06,

determine how long it takes the tank to drain if the # uid level is

initially 3 m. Solve by applying Euler’s equation and writing a

computer program or using Excel. Use a step of 0.5 minutes.

25.18 The following is an initial value, second-order differential

equation:

d 2x

dt 2 1 (5x)

dx

dt 1 (x 1 7) sin(vt) 5 0

where

dx

dt (0) 5 1.5 and x(0) 5 6

Note that v 5 1. Decompose the equation into two ” rst-order dif-

ferential equations. After the decomposition, solve the system from

t 5 0 to 15 and plot the results.

25.19 Assuming that drag is proportional to the square of velocity,

we can model the velocity of a falling object like a parachutist with

the following differential equation:

dy

dt 5 g 2

cd

m y2

where y is velocity (m/s), t 5 time (s), g is the acceleration due to

gravity (9.81 m/s2), cd 5 a second-order drag coef” cient (kg/m),

and m 5 mass (kg). Solve for the velocity and distance fallen by a

90-kg object with a drag coef” cient of 0.225 kg/m. If the initial

height is 1 km, determine when it hits the ground. Obtain your solu-

tion with (a) Euler’s method and (b) the fourth-order RK method.

25.20 A spherical tank has a circular ori” ce in its bottom through

which the liquid # ows out (Fig. P25.20). The # ow rate through the

hole can be estimated as

Qout 5 CA12gH where Qout 5 out# ow (m

3/s), C 5 an empirically-derived coef” –

cient, A 5 the area of the ori” ce (m2), g 5 the gravitational con-

stant (5 9.81 m/s2), and H 5 the depth of liquid in the tank. Use

one of the numerical methods described in this chapter to determine

how long it will take for the water to # ow out of a 3-m-diameter

tank with an initial height of 2.75 m. Note that the ori” ce has a di-

ameter of 3 cm and C 5 0.55.

FIGURE P25.20 A spherical tank.

H

r

754 RUNGE-KUTTA METHODS

from its equilibrium position (m), and g 5 gravitational acceleration

(9.81 m/s2). Solve these equations for the positions and velocities of

the three jumpers given the initial conditions that all positions and

velocities are zero at t 5 0. Use the following parameters for your

calculations: m1 5 60 kg, m2 5 70 kg, m3 5 80 kg, k1 5 k3 5 50,

and k2 5 100 (N/m).

25.24 Given the initial conditions, y(0) 5 1 and y9(0) 5 0, solve

the following initial-value problem from t 5 0 to 4:

d 2y

dt 2 1 4y 5 0

Obtain your solutions with (a) Euler’s method and (b) the fourth-

order RK method. In both cases, use a step size of 0.125. Plot both

solutions on the same graph along with the exact solution y 5 cos 2t.

25.25 Use the following differential equations to compute the

velocity and position of a soccer ball that is kicked straight up in the

air with an initial velocity of 40 m/s:

dy

dt 5 y

dv

dt 5 2g 2

cd

m y Zy Z

where y 5 upward distance (m), t 5 time (s), y 5 upward velocity

(m/s), g 5 gravitational constant (5 9.81 m/s2), cd 5 drag coef” –

cient (kg/m), and m 5 mass (kg). Note that the drag coef” cient is

related to more fundamental parameters by

cd 5 1

2 rACd

where r 5 air density (kg/m3), A 5 area (m2), and Cd 5 the di-

mensionless drag coef” cient. Use the following parameter values

for your calculation: d 5 22 cm, m 5 0.4 kg, r 5 1.3 kg/m3, and

Cd 5 0.52.

25.26 Three linked bungee jumpers are depicted in Fig. P25.26. If

the bungee cords are idealized as linear springs (i.e., governed by

Hooke’s law), the following differential equations based on force

balances can be developed

m1 d 2×1

dt 2 5 m1g 1 k2(x2 2 x1) 2 k1x1

m2 d 2×2

dt 2 5 m2g 1 k3(x3 2 x2) 1 k2(x1 2 x2)

m3 d 2×3

dt 2 5 m3g 1 k3(x2 2 x3)

where mi 5 the mass of jumper i (kg), kj 5 the spring constant for

cord j (N/m), xi 5 the displacement of jumper i measured downward

FIGURE P25.26 Three individuals connected by bungee cords.

x1 = 0

(a) Unstretched (b) Stretched

x2 = 0

x3 = 0

26 C H A P T E R 26

755

Stiffness and Multistep Methods

This chapter covers two areas. First, we describe stiff ODEs. These are both indi-

vidual and systems of ODEs that have both fast and slow components to their solution.

We introduce the idea of an implicit solution technique as one commonly used remedy

for this problem. Then we discuss multistep methods. These algorithms retain informa-

tion of previous steps to more effectively capture the trajectory of the solution. They

also yield the truncation error estimates that can be used to implement adaptive step-

size control.

26.1 STIFFNESS

Stiffness is a special problem that can arise in the solution of ordinary differential equa-

tions. A stiff system is one involving rapidly changing components together with slowly

changing ones. In many cases, the rapidly varying components are ephemeral transients

that die away quickly, after which the solution becomes dominated by the slowly varying

components. Although the transient phenomena exist for only a short part of the integra-

tion interval, they can dictate the time step for the entire solution.

Both individual and systems of ODEs can be stiff. An example of a single stiff

ODE is

dy

dt 5 21000y 1 3000 2 2000e2t (26.1)

If y(0) 5 0, the analytical solution can be developed as

y 5 3 2 0.998e21000t 2 2.002e2t (26.2)

As in Fig. 26.1, the solution is initially dominated by the fast exponential term

(e21000t). After a short period (t , 0.005), this transient dies out and the solution becomes

dictated by the slow exponential (e2t).

Insight into the step size required for stability of such a solution can be gained by

examining the homogeneous part of Eq. (26.1),

dy

dt 5 2ay (26.3)

756 STIFFNESS AND MULTISTEP METHODS

If y(0) 5 y0, calculus can be used to determine the solution as

y 5 y0e 2at

Thus, the solution starts at y0 and asymptotically approaches zero.

Euler’s method can be used to solve the same problem numerically:

yi11 5 yi 1 dyi

dt h

Substituting Eq. (26.3) gives

yi11 5 yi 2 ayih

or

yi11 5 yi(1 2 ah) (26.4)

The stability of this formula clearly depends on the step size h. That is, 01 2 ah 0 must be less than 1. Thus, if h . 2ya, 0 yi 0 n q as i n q. For the fast transient part of Eq. (26.2), this criterion can be used to show that the step

size to maintain stability must be , 2y1000 5 0.002. In addition, it should be noted that, whereas this criterion maintains stability (that is, a bounded solution), an even smaller step

size would be required to obtain an accurate solution. Thus, although the transient occurs for

only a small fraction of the integration interval, it controls the maximum allowable step size.

Super! cially, you might suppose that the adaptive step-size routines described at the

end of the last chapter might offer a solution for this dilemma. You might think that they

would use small steps during the rapid transients and large steps otherwise. However,

this is not the case, because the stability requirement will still necessitate using very

small steps throughout the entire solution.

FIGURE 26.1 Plot of a stiff solution of a single ODE. Although the solution appears to start at 1, there is actually a fast transient from y 5 0 to 1 that occurs in less than 0.005 time unit. This transient is perceptible only when the response is viewed on the fi ner timescale in the inset.

3

y

2

1

0 42 t0

1

0 0.020.010

26.1 STIFFNESS 757

Rather than using explicit approaches, implicit methods offer an alternative remedy.

Such representations are called implicit because the unknown appears on both sides of

the equation. An implicit form of Euler’s method can be developed by evaluating the

derivative at the future time,

yi11 5 yi 1 dyi11

dt h

This is called the backward, or implicit, Euler’s method. Substituting Eq. (26.3) yields

yi11 5 yi 2 ayi11 h

which can be solved for

yi11 5 yi

1 1 ah (26.5)

For this case, regardless of the size of the step, 0 yi 0 n 0 as i n q. Hence, the approach is called unconditionally stable.

EXAMPLE 26.1 Explicit and Implicit Euler

Problem Statement. Use both the explicit and implicit Euler methods to solve

dy

dt 5 21000y 1 3000 2 2000e2t

where y(0) 5 0. (a) Use the explicit Euler with step sizes of 0.0005 and 0.0015 to solve

for y between t 5 0 and 0.006. (b) Use the implicit Euler with a step size of 0.05 to

solve for y between 0 and 0.4.

Solution.

(a) For this problem, the explicit Euler’s method is

yi11 5 yi 1 (21000yi 1 3000 2 2000e 2ti)h

The result for h 5 0.0005 is displayed in Fig. 26.2a along with the analytical solu-

tion. Although it exhibits some truncation error, the result captures the general shape

of the analytical solution. In contrast, when the step size is increased to a value just

below the stability limit (h 5 0.0015), the solution manifests oscillations. Using

h . 0.002 would result in a totally unstable solution, that is, it would go in! nite

as the solution progressed.

(b) The implicit Euler’s method is

yi11 5 yi 1 (21000yi11 1 3000 2 2000e 2ti11)h

Now because the ODE is linear, we can rearrange this equation so that yi11 is isolated

on the left-hand side,

yi11 5 yi 1 3000h 2 2000he

2ti11

1 1 1000h

The result for h 5 0.05 is displayed in Fig. 26.2b along with the analytical solution.

Notice that even though we have used a much bigger step size than the one that

758 STIFFNESS AND MULTISTEP METHODS

induced instability for the explicit Euler, the numerical solution tracks nicely on

the analytical result.

FIGURE 26.2 Solution of a “stiff” ODE with (a) the explicit and (b) implicit Euler methods.

1.5

y

1

0.5

0 0.0060.004

h = 0.0015

h = 0.0005

Exact

(a)

t0 0.002

2

y

1

0 0.40.3

Exact

h = 0.05

(b)

t0 0.20.1

Systems of ODEs can also be stiff. An example is

dy1

dt 5 25y1 1 3y2 (26.6a)

dy2

dt 5 100y1 2 301y2 (26.6b)

For the initial conditions y1(0) 5 52.29 and y2(0) 5 83.82, the exact solution is

y1 5 52.96e 23.9899t

2 0.67e2302.0101t (26.7a)

y2 5 17.83e 23.9899t

1 65.99e2302.0101t (26.7b)

Note that the exponents are negative and differ by about 2 orders of magnitude. As with

the single equation, it is the large exponents that respond rapidly and are at the heart of

the system’s stiffness.

26.2 MULTISTEP METHODS 759

An implicit Euler’s method for systems can be formulated for the present example as

y1, i11 5 y1, i 1 (25y1, i11 1 3y2, i11)h (26.8a)

y2, i11 5 y2, i 1 (100y1, i11 2 301y2, i11)h (26.8b)

Collecting terms gives

(1 1 5h)y1, i11 2 3hy2, i11 5 y1, i (26.9a)

2100hy1, i11 1 (1 1 301h)y2, i11 5 y2, i (26.9b)

Thus, we can see that the problem consists of solving a set of simultaneous equations

for each time step.

For nonlinear ODEs, the solution becomes even more dif! cult since it involves

solving a system of nonlinear simultaneous equations (recall Sec. 6.6). Thus, although

stability is gained through implicit approaches, a price is paid in the form of added solu-

tion complexity.

The implicit Euler method is unconditionally stable and only ! rst-order accurate. It

is also possible to develop in a similar manner a second-order accurate implicit trapezoi-

dal rule integration scheme for stiff systems. It is usually desirable to have higher-order

methods. The Adams-Moulton formulas described later in this chapter can also be used

to devise higher-order implicit methods. However, the stability limits of such approaches

are very stringent when applied to stiff systems. Gear (1971) developed a special series

of implicit schemes that have much larger stability limits based on backward difference

formulas. Extensive efforts have been made to develop software to ef! ciently implement

Gear’s methods. As a result, this is probably the most widely used method to solve stiff

systems. In addition, Rosenbrock and others (see Press et al., 2007) have proposed

implicit Runge-Kutta algorithms where the k terms appear implicitly. These methods have

good stability characteristics and are quite suitable for solving systems of stiff ordinary

differential equations.

26.2 MULTISTEP METHODS

The one-step methods described in the previous sections utilize information at a single

point xi to predict a value of the dependent variable yi11 at a future point xi11 (Fig. 26.3a).

Alternative approaches, called multistep methods (Fig. 26.3b), are based on the insight

that, once the computation has begun, valuable information from previous points is at

our command. The curvature of the lines connecting these previous values provides

information regarding the trajectory of the solution. The multistep methods explored in

this chapter exploit this information to solve ODEs. Before describing the higher-order

versions, we will present a simple second-order method that serves to demonstrate the

general characteristics of multistep approaches.

26.2.1 The Non-Self-Starting Heun Method

Recall that the Heun approach uses Euler’s method as a predictor [Eq. (25.15)]:

y0i11 5 yi 1 f(xi, yi)h (26.10)

760 STIFFNESS AND MULTISTEP METHODS

and the trapezoidal rule as a corrector [Eq. (25.16)]:

yi11 5 yi 1 f(xi, yi) 1 f(xi11, y

0 i11)

2 h (26.11)

Thus, the predictor and the corrector have local truncation errors of O(h2) and O(h3),

respectively. This suggests that the predictor is the weak link in the method because it

has the greatest error. This weakness is signi! cant because the ef! ciency of the iterative

corrector step depends on the accuracy of the initial prediction. Consequently, one way

to improve Heun’s method is to develop a predictor that has a local error of O(h3). This

can be accomplished by using Euler’s method and the slope at yi, and extra information

from a previous point yi21, as in

y0i11 5 yi21 1 f(xi, yi)2h (26.12)

Notice that Eq. (26.12) attains O(h3) at the expense of employing a larger step size, 2h. In

addition, note that Eq. (26.12) is not self-starting because it involves a previous value of the

dependent variable yi 2 1. Such a value would not be available in a typical initial-value problem.

Because of this fact, Eqs. (26.11) and (26.12) are called the non-self-starting Heun method.

As depicted in Fig. 26.4, the derivative estimate in Eq. (26.12) is now located at the

midpoint rather than at the beginning of the interval over which the prediction is made.

As demonstrated subsequently, this centering improves the error of the predictor to O(h3).

However, before proceeding to a formal derivation of the non-self-starting Heun, we will

summarize the method and express it using a slightly modi! ed nomenclature:

Predictor: y0i11 5 y m i21 1 f(xi, y

m i )2h (26.13)

Corrector: y j i11 5 y

m i 1

f(xi, y m i ) 1 f(xi11, y

j21 i11 )

2 h

(for j 5 1, 2, p , m) (26.14)

FIGURE 26.3 Graphical depiction of the fundamental difference between (a) one-step and (b) multistep methods for solving ODEs.

y

xi

(a)

xxi + 1

y

xi

(b)

xxi + 1xi – 1xi – 2

26.2 MULTISTEP METHODS 761

where the superscripts have been added to denote that the corrector is applied iteratively

from j 5 1 to m to obtain re! ned solutions. Note that ymi and y m i21 are the ! nal results

of the corrector iterations at the previous time steps. The iterations are terminated at any

time step on the basis of the stopping criterion

Zea Z 5 ` y j i11 2 y

j21 i11

y j i11

` 100% (26.15) When ea is less than a prespeci! ed error tolerance es, the iterations are terminated. At this

point, j 5 m. The use of Eqs. (26.13) through (26.15) to solve an ODE is demonstrated

in the following example.

EXAMPLE 26.2 Non-Self-Starting Heun Method

Problem Statement. Use the non-self-starting Heun method to perform the same com- putations as were performed previously in Example 25.5 using Heun’s method. That is,

FIGURE 26.4 A graphical depiction of the non-self-starting Heun method. (a) The midpoint method that is used as a predictor. (b) The trapezoidal rule that is employed as a corrector.

y

xxi+1

xi–1

xi

(a)

(b)

Slope = f (xi+1, yi+1) 0

y

xxi+1xi

Slope = f (xi, yi) + f (xi+1, yi+1)

2

0

762 STIFFNESS AND MULTISTEP METHODS

integrate y9 5 4e0.8x 2 0.5y from x 5 0 to x 5 4 using a step size of 1.0. As with Example

25.5, the initial condition at x 5 0 is y 5 2. However, because we are now dealing with a

multistep method, we require the additional information that y is equal to 20.3929953 at

x 5 21.

Solution. The predictor [Eq. (26.13)] is used to extrapolate linearly from x 5 21 to x 5 1.

y01 5 20.3929953 1 [4e 0.8(0)

2 0.5(2)] 2 5 5.607005

The corrector [Eq. (26.14)] is then used to compute the value:

y11 5 2 1 4e0.8(0) 2 0.5(2) 1 4e0.8(1) 2 0.5(5.607005)

2 1 5 6.549331

which represents a percent relative error of 25.73 percent (true value 5 6.194631). This

error is somewhat smaller than the value of 28.18 percent incurred in the self-starting Heun.

Now, Eq. (26.14) can be applied iteratively to improve the solution:

y21 5 2 1 3 1 4e0.8(1) 2 0.5(6.549331)

2 1 5 6.313749

which represents an et of 21.92%. An approximate estimate of the error can also be

determined using Eq. (26.15):

0 ea 0 5 ` 6.313749 2 6.549331 6.313749

` 100% 5 3.7% Equation (26.14) can be applied iteratively until ea falls below a prespeci! ed value of

es. As was the case with the Heun method (recall Example 25.5), the iterations converge

on a value of 6.360865 (et 5 22.68%). However, because the initial predictor value is

more accurate, the multistep method converges at a somewhat faster rate.

For the second step, the predictor is

y02 5 2 1 [4e 0.8(1)

2 0.5(6.360865) ] 2 5 13.44346 et 5 9.43%

which is superior to the prediction of 12.08260 (et 5 18%) that was computed with the

original Heun method. The ! rst corrector yields 15.76693 (et 5 6.8%), and subsequent

iterations converge on the same result as was obtained with the self-starting Heun method:

15.30224 (et 5 23.1%). As with the previous step, the rate of convergence of the corrector

is somewhat improved because of the better initial prediction.

Derivation and Error Analysis of Predictor-Corrector Formulas. We have just em- ployed graphical concepts to derive the non-self-starting Heun. We will now show how

the same equations can be derived mathematically. This derivation is particularly interest-

ing because it ties together ideas from curve ! tting, numerical integration, and ODEs.

The exercise is also useful because it provides a simple procedure for developing higher-

order multistep methods and estimating their errors.

The derivation is based on solving the general ODE

dy

dx 5 f(x, y)

26.2 MULTISTEP METHODS 763

This equation can be solved by multiplying both sides by dx and integrating between

limits at i and i 1 1:

# yi11

yi

dy 5 #

xi11

xi

f(x, y) dx

The left side can be integrated and evaluated using [recall Eq. (25.21)]:

yi11 5 yi 1 # xi11

xi

f(x, y) dx (26.16)

Equation (26.16) represents a solution to the ODE if the integral can be evaluated.

That is, it provides a means to compute a new value of the dependent variable yi11 on

the basis of a prior value yi and the differential equation.

Numerical integration formulas such as those developed in Chap. 21 provide one

way to make this evaluation. For example, the trapezoidal rule [Eq. (21.3)] can be used

to evaluate the integral, as in

# xi11

xi

f(x, y) dx 5

f(xi, yi) 1 f(xi11, yi11)

2 h (26.17)

where h 5 xi1 1 2 xi is the step size. Substituting Eq. (26.17) into Eq. (26.16) yields

yi11 5 yi 1 f(xi, yi) 1 f(xi11, yi11)

2 h

which is the corrector equation for the Heun method. Because this equation is based on

the trapezoidal rule, the truncation error can be taken directly from Table 21.2,

Ec 5 2 1

12 h3y(3)(jc) 5 2

1

12 h3f –(jc) (26.18)

where the subscript c designates that this is the error of the corrector.

A similar approach can be used to derive the predictor. For this case, the integration

limits are from i 2 1 to i 1 1:

# yi11

yi21

dy 5 #

xi11

xi21

f(x, y) dx

which can be integrated and rearranged to yield

yi11 5 yi21 1 # xi11

xi21

f(x, y) dx (26.19)

Now, rather than using a closed formula from Table 21.2, the ! rst Newton-Cotes open

integration formula (see Table 21.4) can be used to evaluate the integral, as in

# xi11

xi 2 1

f(x, y) dx 5 2h f(xi, yi) (26.20)

which is called the midpoint method. Substituting Eq. (26.20) into Eq. (26.19) yields

yi11 5 yi21 1 2h f(xi, yi)

764 STIFFNESS AND MULTISTEP METHODS

which is the predictor for the non-self-starting Heun. As with the corrector, the local

truncation error can be taken directly from Table 21.4:

Ep 5 1

3 h3y(3)(jp) 5

1

3 h3f –(jp) (26.21)

where the subscript p designates that this is the error of the predictor.

Thus, the predictor and the corrector for the non-self-starting Heun method have

truncation errors of the same order. Aside from upgrading the accuracy of the predic-

tor, this fact has additional bene! ts related to error analysis, as elaborated in the next

section.

Error Estimates. If the predictor and the corrector of a multistep method are of the same order, the local truncation error may be estimated during the course of a computa-

tion. This is a tremendous advantage because it establishes a criterion for adjustment of

the step size.

The local truncation error for the predictor is estimated by Eq. (26.21). This error

estimate can be combined with the estimate of yi1l from the predictor step to yield [recall

our basic de! nition of Eq. (3.1)]

True value 5 y0i11 1 1

3 h3y(3)(jp) (26.22)

Using a similar approach, the error estimate for the corrector [Eq. (26.18)] can be com-

bined with the corrector result yi1l to give

True value 5 y mi11 2 1

12 h3y(3)(jc) (26.23)

Equation (26.22) can be subtracted from Eq. (26.23) to yield

0 5 ymi11 2 y 0 i11 2

5

12 h3y(3)(j) (26.24)

where j is now between xi2l and xi1l. Now, dividing Eq. (26.24) by 5 and rearranging

the result gives

y0i11 2 y m i11

5 5 2

1

12 h3y(3)(j) (26.25)

Notice that the right-hand sides of Eqs. (26.18) and (26.25) are identical, with the excep-

tion of the argument of the third derivative. If the third derivative does not vary appre-

ciably over the interval in question, we can assume that the right-hand sides are equal,

and therefore, the left-hand sides should also be equivalent, as in

Ec 5 2 y0i11 2 y

m i11

5 (26.26)

Thus, we have arrived at a relationship that can be used to estimate the per-step truncation

error on the basis of two quantities—the predictor (y0i11) and the corrector (y m i11)—that

are routine by-products of the computation.

26.2 MULTISTEP METHODS 765

EXAMPLE 26.3 Estimate of Per-Step Truncation Error

Problem Statement. Use Eq. (26.26) to estimate the per-step truncation error of Example 26.2. Note that the true values at x 5 1 and 2 are 6.194631 and 14.84392,

respectively.

Solution. At xi1l 5 1, the predictor gives 5.607005 and the corrector yields 6.360865. These values can be substituted into Eq. (26.26) to give

Ec 5 2 6.360865 2 5.607005

5 5 20.1507722

which compares well with the exact error,

Et 5 6.194631 2 6.360865 5 20.1662341

At xi1l 5 2, the predictor gives 13.44346 and the corrector yields 15.30224, which

can be used to compute

Ec 5 2 15.30224 2 13.44346

5 5 20.3717550

which also compares favorably with the exact error, Et 5 14.84392 2 15.30224 5

20.4583148.

The ease with which the error can be estimated using Eq. (26.26) provides a ratio-

nal basis for step-size adjustment during the course of a computation. For example, if

Eq. (26.26) indicates that the error is greater than an acceptable level, the step size could

be decreased.

Modifi ers. Before discussing computer algorithms, we must note two other ways in which the non-self-starting Heun method can be made more accurate and ef! cient. First,

you should realize that besides providing a criterion for step-size adjustment, Eq. (26.26)

represents a numerical estimate of the discrepancy between the ! nal corrected value at

each step yi11 and the true value. Thus, it can be added directly to yi11 to re! ne the

estimate further:

ymi11d y m i11 2

ymi11 2 y 0 i11

5 (26.27)

Equation (26.27) is called a corrector modi! er. (The symbol m is read “is replaced by.”)

The left-hand side is the modi! ed value of ymi11.

A second improvement, one that relates more to program ef! ciency, is a predictor

modi! er, which is designed to adjust the predictor result so that it is closer to the ! nal

convergent value of the corrector. This is advantageous because, as noted previously at

the beginning of this section, the number of iterations of the corrector is highly dependent

on the accuracy of the initial prediction. Consequently, if the prediction is modi! ed

properly, we might reduce the number of iterations required to converge on the ultimate

value of the corrector.

766 STIFFNESS AND MULTISTEP METHODS

Such a modi! er can be derived simply by assuming that the third derivative is

relatively constant from step to step. Therefore, using the result of the previous step at

i, Eq. (26.25) can be solved for

h3y(3)(j) 5 2 12

5 (y0i 2 y

m i ) (26.28)

which, assuming that y(3) (j) > y(3) (jp), can be substituted into Eq. (26.21) to give

Ep 5 4

5 (ymi 2 y

0 i ) (26.29)

which can then be used to modify the predictor result:

y0i11d y 0 i11 1

4

5 (ymi 2 y

0 i ) (26.30)

EXAMPLE 26.4 Effect of Modifi ers on Predictor-Corrector Results

Problem Statement. Recompute Example 26.3 using both modi! ers.

Solution. As in Example 26.3, the initial predictor result is 5.607005. Because the predictor modi! er [Eq. (26.30)] requires values from a previous iteration, it cannot be

employed to improve this initial result. However, Eq. (26.27) can be used to modify the

corrected value of 6.360865 (et 5 22.684%), as in

ym1 5 6.360865 2 6.360865 2 5.607005

5 5 6.210093

which represents an et 5 20.25%. Thus, the error is reduced over an order of magnitude.

For the next iteration, the predictor [Eq. (26.13)] is used to compute

y02 5 2 1 [4e 0.8(0)

2 0.5(6.210093) ] 2 5 13.59423 et 5 8.42%

which is about half the error of the predictor for the second iteration of Example 26.3,

which was et 5 18.6%. This improvement occurs because we are using a superior

estimate of y (6.210093 as opposed to 6.360865) in the predictor. In other words,

the propagated and global errors are reduced by the inclusion of the corrector

modifier.

Now because we have information from the prior iteration, Eq. (26.30) can be em-

ployed to modify the predictor, as in

y02 5 13.59423 1 4

5 (6.360865 2 5.607005) 5 14.19732 et 5 24.36%

which, again, halves the error.

This modi! cation has no effect on the ! nal outcome of the subsequent corrector

step. Regardless of whether the unmodi! ed or modi! ed predictors are used, the correc-

tor will ultimately converge on the same answer. However, because the rate or ef! ciency

of convergence depends on the accuracy of the initial prediction, the modi! cation can

reduce the number of iterations required for convergence.

26.2 MULTISTEP METHODS 767

Implementing the corrector yields a result of 15.21178 (et 5 22.48%), which rep-

resents an improvement over Example 26.3 because of the reduction of global error.

Finally, this result can be modi! ed using Eq. (26.27):

ym2 5 15.21178 2 15.21178 2 13.59423

5 5 14.88827 et 5 20.30%

Again, the error has been reduced an order of magnitude.

As in the previous example, the addition of the modi! ers increases both the ef! –

ciency and accuracy of multistep methods. In particular, the corrector modi! er effectively

increases the order of the technique. Thus, the non-self-starting Heun with modi! ers is

third order rather than second order as is the case for the unmodi! ed version. However,

it should be noted that there are situations where the corrector modi! er will affect the

stability of the corrector iteration process. As a consequence, the modi! er is not included

in the algorithm for the non-self-starting Heun delineated in Fig. 26.5. Nevertheless, the

corrector modi! er can still have utility for step-size control, as discussed next.

FIGURE 26.5 The sequence of formulas used to implement the non-self-starting Heun method. Note that the corrector error estimates can be used to modify the corrector. However, because this can affect the corrector’s stability, the modifi er is not included in this algorithm. The corrector error estimate is included because of its utility for step-size adjustment.

Predictor:

y0i11 5 yi m 21 1 f (xi, y i

m)2h

(Save result as y0i11,u 5 y 0 i11 where the subscript u designates that the variable is unmodifi ed.)

Predictor Modifi er:

y0i11d y 0 i11,u 1

4

5 (y mi,u 2 y

0 i,u)

Corrector:

y ji11 5 y m i 1

f (xi, y m i ) 1 f (xi11, y

j21 i11)

2 h (for j 5 1 to maximum iterations m)

Error Check:

Zea Z 5 ` y j i11 2 y

j21 i11

y ji11 ` 100%

(If |ea| . error criterion, set j 5 j 11 and repeat corrector; if ea # error criterion, save result as y i

m 11,u 5 y i

m 11.)

Corrector Error Estimate:

Ec 5 2 1

5 (y mi11,u 2 y

0 i11,u)

(If computation is to continue, set i 5 i 1 1 and return to predictor.)

768 STIFFNESS AND MULTISTEP METHODS

26.2.2 Step-Size Control and Computer Programs

Constant Step Size. It is relatively simple to develop a constant step-size version of the non-self-starting Heun method. About the only complication is that a one-step method

is required to generate the extra point to start the computation.

Additionally, because a constant step size is employed, a value for h must be chosen

prior to the computation. In general, experience indicates that an optimal step size should

be small enough to ensure convergence within two iterations of the corrector (Hull and

Creemer, 1963). In addition, it must be small enough to yield a suf! ciently small trunca-

tion error. At the same time, the step size should be as large as possible to minimize

run-time cost and round-off error. As with other methods for ODEs, the only practical

way to assess the magnitude of the global error is to compare the results for the same

problem but with a halved step size.

Variable Step Size. Two criteria are typically used to decide whether a change in step size is warranted. First, if Eq. (26.26) is greater than some prespeci! ed error criterion,

the step size is decreased. Second, the step size is chosen so that the convergence criterion

of the corrector is satis! ed in two iterations. This criterion is intended to account for the

trade-off between the rate of convergence and the total number of steps in the calculation.

For smaller values of h, convergence will be more rapid but more steps are required. For

larger h, convergence is slower but fewer steps result. Experience (Hull and Creemer,

1963) suggests that the total steps will be minimized if h is chosen so that the corrector

converges within two iterations. Therefore, if over two iterations are required, the step

size is decreased, and if less than two iterations are required, the step size is increased.

Although the above strategy speci! es when step size modi! cations are in order, it

does not indicate how they should be changed. This is a critical question because mul-

tistep methods by de! nition require several points to compute a new point. Once the step

size is changed, a new set of points must be determined. One approach is to restart the

computation and use the one-step method to generate a new set of starting points.

A more ef! cient strategy that makes use of existing information is to increase and

decrease by doubling and halving the step size. As depicted in Fig. 26.6b, if a suf! cient

number of previous values have been generated, increasing the step size by doubling is

a relatively straightforward task (Fig. 26.6c). All that is necessary is to keep track of

subscripts so that old values of x and y become the appropriate new values. Halving the

step size is somewhat more complicated because some of the new values will be unavail-

able (Fig. 26.6a). However, interpolating polynomials of the type developed in Chap. 18

can be used to determine these intermediate values.

In any event, the decision to incorporate step-size control represents a trade-off

between initial investment in program complexity versus the long-term return because

of increased ef! ciency. Obviously, the magnitude and importance of the problem itself

will have a strong bearing on this trade-off. Fortunately, several software packages and

libraries have multistep routines that you can use to obtain solutions without having to

program them from scratch. We will mention some of these when we review packages

and libraries at the end of Chap. 27.

26.2.3 Integration Formulas

The non-self-starting Heun method is characteristic of most multistep methods. It em-

ploys an open integration formula (the midpoint method) to make an initial estimate.

26.2 MULTISTEP METHODS 769

This predictor step requires a previous data point. Then, a closed integration formula (the

trapezoidal rule) is applied iteratively to improve the solution.

It should be obvious that a strategy for improving multistep methods would be to use

higher-order integration formulas as predictors and correctors. For example, the higher-

order Newton-Cotes formulas developed in Chap. 21 could be used for this purpose.

Before describing these higher-order methods, we will review the most common inte-

gration formulas upon which they are based. As mentioned above, the ! rst of these are the

Newton-Cotes formulas. However, there is a second class called the Adams formulas that

we will also review and that are often preferred. As depicted in Fig. 26.7, the fundamental

difference between the Newton-Cotes and Adams formulas relates to the manner in which

the integral is applied to obtain the solution. As depicted in Fig. 26.7a, the Newton-Cotes

formulas estimate the integral over an interval spanning several points. This integral is then

used to project from the beginning of the interval to the end. In contrast, the Adams for-

mulas (Fig. 26.7b) use a set of points from an interval to estimate the integral solely for

the last segment in the interval. This integral is then used to project across this last segment.

FIGURE 26.6 A plot indicating how a halving-doubling strategy allows the use of (b) previously calculated val- ues for a third-order multistep method. (a) Halving; (c) doubling.

y

x

Interpolation

(a)

y

x

(b)

y

x

(c)

770 STIFFNESS AND MULTISTEP METHODS

Newton-Cotes Formulas. Some of the most common formulas for solving ordinary differential equations are based on ! tting an nth-degree interpolating polynomial to n 1 1

known values of y and then using this equation to compute the integral. As discussed

previously in Chap. 21, the Newton-Cotes integration formulas are based on such an

approach. These formulas are of two types: open and closed forms.

Open Formulas. For n equally spaced data points, the open formulas can be expressed

in the form of a solution of an ODE, as was done previously for Eq. (26.19). The general

equation for this purpose is

yi11 5 yi2n 1 # xi11

xi2n

fn(x) dx (26.31)

y

xi + 1 xxixi – 1

(a)

xi – 2

yi + 1 = yi – 2 +

xi + 1

xi – 2 f (x, y) dx

y

xi + 1 xxixi – 1

(b)

xi – 2

yi + 1 = yi +

xi + 1

xi f (x, y) dx

FIGURE 26.7 Illustration of the fundamental difference between the Newton-Cotes and Adams integration for- mulas. (a) The Newton-Cotes formulas use a series of points to obtain an integral estimate over a number of segments. The estimate is then used to project across the entire range. (b) The Adams formulas use a series of points to obtain an integral estimate for a single segment. The estimate is then used to project across the segment.

26.2 MULTISTEP METHODS 771

where fn(x) is an nth-order interpolating polynomial. The evaluation of the integral em-

ploys the nth-order Newton-Cotes open integration formula (Table 21.4). For example,

if n 5 1,

yi11 5 yi21 1 2h fi (26.32)

where fi is an abbreviation for f(xi, yi)—that is, the differential equation evaluated at xi

and yi. Equation (26.32) is referred to as the midpoint method and was used previously

as the predictor in the non-self-starting Heun method. For n 5 2,

yi11 5 yi22 1 3h

2 ( fi 1 fi21)

and for n 5 3,

yi11 5 yi23 1 4h

3 (2 fi 2 fi21 1 2 fi22) (26.33)

Equation (26.33) is depicted graphically in Fig. 26.8a.

Closed Formulas. The closed form can be expressed generally as

yi11 5 yi2n11 1 # xi11

xi2n11

fn(x) dx (26.34)

where the integral is approximated by an nth-order Newton-Cotes closed integration

formula (Table 21.2). For example, for n 5 1,

yi11 5 yi 1 h

2 ( fi 1 fi11)

which is equivalent to the trapezoidal rule. For n 5 2,

yi11 5 yi21 1 h

3 ( fi21 1 4fi 1 fi11) (26.35)

which is equivalent to Simpson’s 1y3 rule. Equation (26.35) is depicted in Fig. 26.8b.

Adams Formulas. The other types of integration formulas that can be used to solve ODEs are the Adams formulas. Many popular computer algorithms for multistep solution

of ODEs are based on these methods.

Open Formulas (Adams-Bashforth). The Adams formulas can be derived in a variety

of ways. One technique is to write a forward Taylor series expansion around xi:

yi11 5 yi 1 fi h 1 f ¿i

2 h2 1

f –i

6 h3 1p

which can also be written as

yi11 5 yi 1 h afi 1 h 2

f ¿i 1 h2

3 f –i 1

pb (26.36)

772 STIFFNESS AND MULTISTEP METHODS

Recall from Sec. 4.1.3 that a backward difference can be used to approximate the

derivative:

f ¿i 5 fi 2 fi21

h 1

f –i

2 h 1 O(h2)

which can be substituted into Eq. (26.36),

yi11 5 yi 1 h e fi 1 h 2

c fi 2 fi21 h

1 f –i

2 h 1 O(h2) d 1 h2

6 f –i 1

p f or, collecting terms,

yi11 5 yi 1 h a3 2

fi 2 1

2 fi21b 1 5

12 h3 f –i 1 O(h

4) (26.37)

y

xi + 1 xxixi – 1

(a)

xi – 2xi – 3

y

xi + 1 xxixi – 1

(b)

FIGURE 26.8 Graphical depiction of open and closed Newton-Cotes integration formulas. (a) The third open formula [Eq. (26.33)] and (b) Simpson’s 1/3 rule [Eq. (26.35)].

26.2 MULTISTEP METHODS 773

This formula is called the second-order open Adams formula. Open Adams formulas are

also referred to as Adams-Bashforth formulas. Consequently, Eq. (26.37) is sometimes

called the second Adams-Bashforth formula.

Higher-order Adams-Bashforth formulas can be developed by substituting higher-

difference approximations into Eq. (26.36). The nth-order open Adams formula can be

represented generally as

yi11 5 yi 1 h a n21

k50 bk fi2k 1 O(h

n11) (26.38)

The coef! cients bk are compiled in Table 26.1. The fourth-order version is depicted in

Fig. 26.9a. Notice that the ! rst-order version is Euler’s method.

Closed Formulas (Adams-Moulton). A backward Taylor series around xi1l can be

written as

yi 5 yi11 2 fi11h 1 f ¿i11

2 h2 2

f –i11

3 h3 1p

Solving for yi1l yields

yi11 5 yi 1 h a fi11 2 h 2

f ¿i11 1 h2

6 f –i11 1

pb (26.39) A difference can be used to approximate the ! rst derivative:

f ¿i11 5 fi11 2 fi

h 1

f –i11

2 h 1 O(h2)

TABLE 26.1 Coeffi cients and truncation error for Adams-Bashforth predictors.

Local Truncation Order B0 B1 B2 B3 B4 B5 Error

1 1 1

2 h2f ¿(j)

2 3/2 21/2 5

12 h3f ¿¿(j)

3 23/12 216/12 5/12 9

24 h4f 132(j)

4 55/24 259/24 37/24 29/24 251

720 h5f 142(j)

5 1901/720 22774/720 2616/720 21274/720 251/720 475

1440 h6f 152(j)

6 4277/720 27923/720 9982/720 27298/720 2877/720 2475/720 19,087

60,480 h7f 162(j)

774 STIFFNESS AND MULTISTEP METHODS

which can be substituted into Eq. (26.39), and collecting terms gives

yi11 5 yi 1 h a1 2

fi11 1 1

2 fib 2 1

12 h3f –i11 2 O(h

4)

This formula is called the second-order closed Adams formula or the second Adams-

Moulton formula. Also, notice that it is the trapezoidal rule.

The nth-order closed Adams formula can be written generally as

yi11 5 yi 1 h a n21

k50 bk fi112k 1 O(h

n11)

The coef! cients bk are listed in Table 26.2. The fourth-order method is depicted in Fig.

26.9b.

FIGURE 26.9 Graphical depiction of open and closed Adams integration formulas. (a) The fourth Adams- Bashforth open formula and (b) the fourth Adams-Moulton closed formula.

y

xi + 1 xxixi – 1

(a)

xi – 2xi – 3

y

xi + 1 xxixi – 1

(b)

xi – 2

26.2 MULTISTEP METHODS 775

26.2.4 Higher-Order Multistep Methods

Now that we have formally developed the Newton-Cotes and Adams integration formu-

las, we can use them to derive higher-order multistep methods. As was the case with the

non-self-starting Heun method, the integration formulas are applied in tandem as predictor-

corrector methods. In addition, if the open and closed formulas have local truncation

Box 26.1 Derivation of General Relationships for Modifi ers

The relationship between the true value, the approximation, and the

error of a predictor can be represented generally as

True value 5 y0i11 1 hp

dp hn11 y(n11)(jp) (B26.1.1)

where hp and dp 5 the numerator and denominator, respectively, of

the constant of the truncation error for either an open Newton-

Cotes (Table 21.4) or an Adams-Bashforth (Table 26.1) predictor,

and n is the order.

A similar relationship can be developed for the corrector:

True value 5 ymi11 2 hc

dc hn11 y(n11)(jc) (B26.1.2)

where hc and dc 5 the numerator and denominator, respectively, of

the constant of the truncation error for either a closed Newton-

Cotes (Table 21.2) or an Adams-Moulton (Table 26.2) corrector. As

was done in the derivation of Eq. (26.24), Eq. (B26.1.1) can be

subtracted from Eq. (B26.1.2) to yield

0 5 ymi11 2 y 0 i11 2

hc 1 hpdcydp dc

hn11 y(n11)(j) (B26.1.3)

Now, dividing the equation by hc 1 hpdcydp, multiplying the last term by dpydp, and rearranging provides an estimate of the local

truncation error of the corrector:

Ec > 2 hcdp

hcdp 1 hpdc (ymi11 2 y

0 i11) (B26.1.4)

For the predictor modi! er, Eq. (B26.1.3) can be solved at the

previous step for

hny(n11)(j) 5 2 dcdp

hcdp 1 hpdc (y0i 2 y

m i )

which can be substituted into the error term of Eq. (B26.1.1) to

yield

Ep 5 hpdc

hcdp 1 hpdc (ymi 2 y

0 i ) (B26.1.5)

Equations (B26.1.4) and (B26.1.5) are general versions of modi! –

ers that can be used to improve multistep algorithms. For example,

Milne’s method has hp 5 14, dp 5 45, hc 5 1, dc 5 90. Substituting

these values into Eqs. (B26.1.4) and (B26.1.5) yields Eqs. (26.43)

and (26.42), respectively. Similar modi! ers can be developed for

other pairs of open and closed formulas that have local truncation

errors of the same order.

TABLE 26.2 Coeffi cients and truncation error for Adams-Moulton correctors.

Local Truncation Order B0 B1 B2 B3 B B5 Error

2 1/2 1/2 2 1

12 h3f –(j)

3 5/12 8/12 21/12 2 1

24 h4f (3)(j)

4 9/24 19/24 25/24 1/24 2 19

720 h5f (4)(j)

5 251/720 646/720 2264/720 106/720 219/720 2 27

1440 h6f (5)(j)

6 475/1440 1427/1440 2798/1440 482/1440 2173/1440 27/1440 2 863

60,480 h7f (6)(j)

776 STIFFNESS AND MULTISTEP METHODS

errors of the same order, modi! ers of the type listed in Fig. 26.5 can be incorporated to

improve accuracy and allow step-size control. Box 26.1 provides general equations for

these modi! ers. In the following section, we present two of the most common higher-

order multistep approaches: Milne’s method and the fourth-order Adams method.

Milne’s Method. Milne’s method is the most common multistep method based on Newton-Cotes integration formulas. It uses the three-point Newton-Cotes open formula

as a predictor:

y0i11 5 y m i23 1

4h

3 (2 f mi 2 f

m i21 1 2 f

m i22) (26.40)

and the three-point Newton-Cotes closed formula (Simpson’s 1y3 rule) as a corrector:

y j i11 5 y

m i21 1

h

3 ( f mi21 1 4 f

m i 1 f

j21 i11) (26.41)

where j is an index representing the number of iterations of the modi! er. The predictor and

corrector modi! ers for Milne’s method can be developed from the formulas in Box 26.1

and the error coef! cients in Tables 21.2 and 21.4:

Ep 5 28

29 (ymi 2 y

0 i ) (26.42)

Ec > 2 1

29 (ymi11 2 y

0 i11) (26.43)

EXAMPLE 26.5 Milne’s Method

Problem Statement. Use Milne’s method to integrate y9 5 4e0.8x 2 0.5y from x 5 0 to x 5 4 using a step size of 1. The initial condition at x 5 0 is y 5 2. Because we are

dealing with a multistep method, previous points are required. In an actual application,

a one-step method such as a fourth-order RK would be used to compute the required

points. For the present example, we will use the analytical solution [recall Eq. (E25.5.1)

from Example 25.5] to compute exact values at xi23 5 23, xi22 5 22, and xi21 5 21

of yi23 5 24.547302, yi22 5 22.306160, and yi21 5 20.3929953, respectively.

Solution. The predictor [Eq. (26.40)] is used to calculate a value at x 5 1:

y01 5 24.54730 1 4(1)

3 [2(3) 2 1.99381 1 2(1.96067)] 5 6.02272 et 5 2.8%

The corrector [Eq. (26.41)] is then employed to compute

y11 5 20.3929953 1 1

3 [1.99381 1 4(3) 1 5.890802] 5 6.235210 et 5 20.66%

This result can be substituted back into Eq. (26.41) to iteratively correct the estimate.

This process converges on a ! nal corrected value of 6.204855 (et 5 20.17%).

This value is more accurate than the comparable estimate of 6.360865 (et 522.68%)

obtained previously with the non-self-starting Heun method (Examples 26.2 through 26.4).

The results for the remaining steps are y(2) 5 14.86031 (et 5 20.11%), y(3) 5 33.72426

(et 5 20.14%), and y(4) 5 75.43295 (et 5 20.12%).

26.2 MULTISTEP METHODS 777

As in the previous example, Milne’s method usually yields results of high accuracy.

However, there are certain cases where it performs poorly (see Ralston and Rabinowitz,

1978). Before elaborating on these cases, we will describe another higher-order multistep

approach—the fourth-order Adams method.

Fourth-Order Adams Method. A popular multistep method based on the Adams integration formulas uses the fourth-order Adams-Bashforth formula (Table 26.1) as the

predictor:

y0i11 5 y m i 1 h a55

24 f mi 2

59

24 f mi21 1

37

24 f mi22 2

9

24 f mi23b (26.44)

and the fourth-order Adams-Moulton formula (Table 26.2) as the corrector:

y ji11 5 y m i 1 h a 9

24 f j21i11 1

19

24 f mi 2

5

24 f mi21 1

1

24 f mi22b (26.45)

The predictor and the corrector modi! ers for the fourth-order Adams method can be

developed from the formulas in Box 26.1 and the error coef! cients in Tables 26.1 and

26.2 as

Ep 5 251

270 (ymi 2 y

0 i ) (26.46)

Ec 5 2 19

270 (ymi11 2 y

0 i11) (26.47)

EXAMPLE 26.6 Fourth-Order Adams Method

Problem Statement. Use the fourth-order Adams method to solve the same problem as in Example 26.5.

Solution. The predictor [Eq. (26.44)] is used to compute a value at x 5 1.

y01 5 2 1 1 a55 24

3 2 59

24 1.993814 1

37

24 1.960667 2

9

24 2.6365228b 5 6.007539

et 5 3.1%

which is comparable to but somewhat less accurate than the result using the Milne

method. The corrector [Eq. (26.45)] is then employed to calculate

y11 5 2 1 1 a 9 24

5.898394 1 19

24 3 2

5

24 1.993814 1

1

24 1.960666b 5 6.253214

et 5 20.96%

which again is comparable to but less accurate than the result using Milne’s method.

This result can be substituted back into Eq. (26.45) to iteratively correct the estimate.

The process converges on a ! nal corrected value of 6.214424 (et 5 0.32%), which

is an accurate result but again somewhat inferior to that obtained with the Milne

method.

778 STIFFNESS AND MULTISTEP METHODS

Stability of Multistep Methods. The superior accuracy of the Milne method exhibited in Examples 26.5 and 26.6 would be anticipated on the basis of the error terms for the

predictors [Eqs. (26.42) and (26.46)] and the correctors [Eqs. (26.43) and (26.47)]. The

coef! cients for the Milne method, 14y45 and 1y90, are smaller than for the fourth-order Adams, 251y720 and 19y720. Additionally, the Milne method employs fewer function evaluations to attain these higher accuracies. At face value, these results might lead to the

conclusion that the Milne method is superior and, therefore, preferable to the fourth-order

Adams. Although this conclusion holds for many cases, there are instances where the Milne

method performs unacceptably. Such behavior is exhibited in the following example.

EXAMPLE 26.7 Stability of Milne’s and Fourth-Order Adams Methods

Problem Statement. Employ Milne’s and the fourth-order Adams methods to solve

dy

dx 5 2y

with the initial condition that y 5 1 at x 5 0. Solve this equation from x 5 0 to x 5 10

using a step size of h 5 0.5. Note that the analytical solution is y 5 e2x.

Solution. The results, as summarized in Fig. 26.10, indicate problems with Milne’s method. Shortly after the onset of the computation, the errors begin to grow and oscillate

FIGURE 26.10 Graphical depiction of the instability of Milne’s method.

0.005

0 5 10 x

y

Milne’s method

True solution

PROBLEMS 779

in sign. By x 5 10, the relative error has in# ated to 2831 percent and the predicted value

itself has started to oscillate in sign.

In contrast, the results for the Adams method would be much more acceptable.

Although the error also grows, it would do so at a slow rate. Additionally, the discrepancies

would not exhibit the wild swings in sign exhibited by the Milne method.

The unacceptable behavior manifested in the previous example by the Milne method

is referred to as instability. Although it does not always occur, its possibility leads to the

conclusion that Milne’s approach should be avoided. Thus, the fourth-order Adams

method is normally preferred.

The instability of Milne’s method is due to the corrector. Consequently, attempts

have been made to rectify the shortcoming by developing stable correctors. One com-

monly used alternative that employs this approach is Hamming’s method, which uses the

Milne predictor and a stable corrector:

y j i11 5

9ymi 2 y m i22 1 3h(y

j21 i11 1 2 f

m i 2 f

m i21)

8

which has a local truncation error:

Ec 5 1

40 h5y(4)(jc)

Hamming’s method also includes modi! ers of the form

Ep 5 9

121 (ymi 2 y

0 i )

Ec 5 2 112

121 (ymi11 2 y

0 i11)

The reader can obtain additional information on this and other multistep methods else-

where (Hamming, 1973; Lapidus and Sein! eld, 1971).

PROBLEMS

26.1 Given

dy

dx 5 2200,000y 1 200,000e2x 2e2x

(a) Estimate the step-size required to maintain stability using the

explicit Euler method.

(b) If y(0) 5 0, use the implicit Euler to obtain a solution from t 5

0 to 2 using a step size of 0.1.

26.2 Given

dy

dt 5 30(cos t 2 y) 1 3 sin t

If y(0) 5 1, use the implicit Euler to obtain a solution from t 5 0

to 4 using a step size of 0.4.

26.3 Given

dx1

dt 5 1999×1 1 2999×2

dx2

dt 5 22000×1 2 3000×2

If x1(0) 5 x2(0) 5 1, obtain a solution from t 5 0 to 0.2 using a step

size of 0.05 with the (a) explicit and (b) implicit Euler methods.

780 STIFFNESS AND MULTISTEP METHODS

26.13 Consider the thin rod of length l moving in the x-y plane as

shown in Fig. P26.13. The rod is ! xed with a pin on one end and a

mass at the other. Note that g 5 9.81 m/s2 and l 5 0.5 m. This sys-

tem can be solved using

u $

2 g

l u 5 0

Let u 5 0 and u # (0) 5 0.25 rad/s. Solve using any method studied

in this chapter. Plot the angle versus time and the angular velocity

versus time. (Hint: Decompose the second-order ODE.)

26.14 Given the ! rst-order ODE

dx

dt 5 2700x 2 1000e2t

x(t 5 0) 5 4

Solve this stiff differential equation using a numerical method over

the time period 0 # t # 5. Also solve analytically and plot the ana-

lytic and numerical solution for both the fast transient and slow

transition phase of the timescale.

26.15 The following second-order ODE is considered to be stiff

d 2y

dx2 5 21001

dy

dx 2 1000y

Solve this differential equation (a) analytically and (b) numerically

for x 5 0 to 5. For (b) use an implicit approach with h 5 0.5. Note

that the initial conditions are y(0) 5 1 and y9(0) 5 0. Display both

results graphically.

26.16 Solve the following differential equation from t 5 0 to 1

dy

dt 5 210y

with the initial condition y(0) 5 1. Use the following techniques to

obtain your solutions: (a) analytically, (b) the explicit Euler

method, and (c) the implicit Euler method. For (b) and (c) use h 5

0.1 and 0.2. Plot your results.

26.4 Solve the following initial-value problem over the interval

from t 5 2 to 3:

dy

dt 5 20.4y 1 e22t

Use the non-self-starting Heun method with a step size of 0.5 and

initial conditions of y(l.5) 5 5.800007 and y(2.0) 5 4.762673. Iter-

ate the corrector to es 5 0.1%. Compute the true percent relative

errors et for your results based on the analytical solution.

26.5 Repeat Prob. 26.4, but use the fourth-order Adams method.

[Note: y(0.5) 5 8.46909 and y(1.0) 5 7.037566.] Iterate the correc-

tor to es 5 0.01%.

26.6 Solve the following initial-value problem from t 5 4 to 5:

dy

dt 5 2

2y

t

Use a step size of 0.5 and initial values of y(2.5) 5 0.48, y(3) 5

0.333333, y(3.5) 5 0.244898, and y(4) 5 0.1875. Obtain your solu-

tions using the following techniques: (a) the non-self-starting Heun

method (es 5 1%), and (b) the fourth-order Adams method (es 5

0.01%). [Note: The exact answers obtained analytically are y(4.5)

5 0.148148 and y(5) 5 0.12.] Compute the true percent relative

errors et for your results.

26.7 Solve the following initial-value problem from x 5 0 to

x 5 0.75:

dy

dx 5 yx2 2 y

Use the non-self-starting Heun method with a step size of 0.25. If

y(0) 5 1, employ the fourth-order RK method with a step size of

0.25 to predict the starting value at y(0.25).

26.8 Solve the following initial-value problem from t 5 1.5 to

t 5 2.5

dy

dt 5

22y

1 1 t

Use the fourth-order Adams method. Employ a step size of 0.5

and the fourth-order RK method to predict the start-up values if

y(0) 5 2.

26.9 Develop a program for the implicit Euler method for a single

linear ODE. Test it by duplicating Prob. 26.1b.

26.10 Develop a program for the implicit Euler method for a pair

of linear ODEs. Test it by solving Eq. (26.6).

26.11 Develop a user-friendly program for the non-self-starting

Heun method with a predictor modi! er. Employ a fourth-order RK

method to compute starter values. Test the program by duplicating

Example 26.4.

26.12 Use the program developed in Prob. 26.11 to solve Prob. 26.7.

FIGURE P26.13

u

m

l

27 C H A P T E R 27

781

Boundary-Value and Eigenvalue Problems

Recall from our discussion at the beginning of Part Seven that an ordinary differential

equation is accompanied by auxiliary conditions. These conditions are used to evaluate the

constants of integration that result during the solution of the equation. For an nth-order

equation, n conditions are required. If all the conditions are speci! ed at the same value of

the independent variable, then we are dealing with an initial-value problem (Fig. 27.1a).

To this point, the material in Part Seven has been devoted to this type of problem.

FIGURE 27.1 Initial-value versus boundary- value problems. (a) An initial- value problem where all the conditions are specifi ed at the same value of the independent variable. (b) A boundary-value problem where the conditions are specifi ed at different values of the independent variable.

y

y1

y2

t

y2, 0

y1, 0

(a)

0

Initial conditions

Boundary condition

Boundary conditiony

yL

x

y0

(b)

0 L

= f1(t, y1, y2) dy1

dt

= f2(t, y1, y2) dy2

dt

where at t = 0, y1 = y1, 0 and y2 = y2, 0

= f (x, y) d2y

dx2

where at x = 0, y = y0 x = L, y = yL

782 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

In contrast, there is another application for which the conditions are not known at

a single point, but rather, are known at different values of the independent variable.

Because these values are often speci! ed at the extreme points or boundaries of a system,

they are customarily referred to as boundary-value problems (Fig. 27.1b). A variety of

signi! cant engineering applications fall within this class. In this chapter, we discuss two

general approaches for obtaining their solution: the shooting method and the ! nite-

difference approach. Additionally, we present techniques to approach a special type of

boundary-value problem: the determination of eigenvalues. Of course, eigenvalues also

have many applications beyond those involving boundary-value problems.

27.1 GENERAL METHODS FOR BOUNDARY-VALUE PROBLEMS

The conservation of heat can be used to develop a heat balance for a long, thin rod

(Fig. 27.2). If the rod is not insulated along its length and the system is at a steady

state, the equation that results is

d 2T

dx2 1 h¿(Ta 2 T ) 5 0 (27.1)

where h9 is a heat transfer coef! cient (m22) that parameterizes the rate of heat dissipation

to the surrounding air and Ta is the temperature of the surrounding air (8C).

To obtain a solution for Eq. (27.1), there must be appropriate boundary conditions.

A simple case is where the temperatures at the ends of the rod are held at ! xed values.

These can be expressed mathematically as

T(0) 5 T1

T(L) 5 T2

With these conditions, Eq. (27.1) can be solved analytically using calculus. For a 10-m

rod with Ta 5 20, T1 5 40, T2 5 200, and h9 5 0.01, the solution is

T 5 73.4523e0.1x 2 53.4523e20.1x 1 20 (27.2)

In the following sections, the same problem will be solved using numerical approaches.

FIGURE 27.2 A noninsulated uniform rod positioned between two bodies of constant but different temperature. For this case T1 . T2 and T2 . Ta.

x = Lx = 0

T1 T2

Ta

Ta

27.1 GENERAL METHODS FOR BOUNDARY-VALUE PROBLEMS 783

27.1.1 The Shooting Method

The shooting method is based on converting the boundary-value problem into an equiv-

alent initial-value problem. A trial-and-error approach is then implemented to solve the

initial-value version. The approach can be illustrated by an example.

EXAMPLE 27.1 The Shooting Method

Problem Statement. Use the shooting method to solve Eq. (27.1) for a 10-m rod with h9 5 0.01 m22, Ta 5 20, and the boundary conditions

T(0) 5 40 T(10) 5 200

Solution. Using the same approach as was employed to transform Eq. (PT7.2) into Eqs. (PT7.3) through (PT7.6), the second-order equation can be expressed as two ! rst-

order ODEs:

dT

dx 5 z (E27.1.1)

dz

dx 5 h¿(T 2 Ta) (E27.1.2)

To solve these equations, we require an initial value for z. For the shooting method, we

guess a value—say, z(0) 5 10. The solution is then obtained by integrating Eq. (E27.1.1)

and (E27.1.2) simultaneously. For example, using a fourth-order RK method with a step

size of 2, we obtain a value at the end of the interval of T(10) 5 168.3797 (Fig. 27.3a),

which differs from the boundary condition of T(10) 5 200. Therefore, we make another guess,

z(0) 5 20, and perform the computation again. This time, the result of T(10) 5 285.8980 is

obtained (Fig. 27.3b).

Now, because the original ODE is linear, the values

z(0) 5 10 T(10) 5 168.3797

and

z(0) 5 20 T(10) 5 285.8980

are linearly related. As such, they can be used to compute the value of z(0) that yields

T(10) 5 200. A linear interpolation formula [recall Eq. (18.2)] can be employed for this

purpose:

z(0) 5 10 1 20 2 10

285.8980 2 168.3797 (200 2 168.3797) 5 12.6907

This value can then be used to determine the correct solution, as depicted in Fig. 27.3c.

784 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

Nonlinear Two-Point Problems. For nonlinear boundary-value problems, linear inter- polation or extrapolation through two solution points will not necessarily result in an

accurate estimate of the required boundary condition to attain an exact solution. An al-

ternative is to perform three applications of the shooting method and use a quadratic

interpolating polynomial to estimate the proper boundary condition. However, it is un-

likely that such an approach would yield the exact answer, and additional iterations would

be necessary to obtain the solution.

Another approach for a nonlinear problem involves recasting it as a roots problem.

Recall that the general form of a roots problem is to ! nd the value of x that makes the

FIGURE 27.3 The shooting method: (a) the fi rst “shot,” (b) the second “shot,” and (c) the fi nal exact “hit.”

0 8 1064

(c)

(b)

20

100

200

0

100

200

(a)

0

100

200

27.1 GENERAL METHODS FOR BOUNDARY-VALUE PROBLEMS 785

function f(x) 5 0. Now, let us use Example 27.1 to understand how the shooting method

can be recast in this form.

First, recognize that the solution of the pair of differential equations is also a “func-

tion” in the sense that we guess a condition at the left-hand end of the rod, z0, and the

integration yields a prediction of the temperature at the right-hand end, T10. Thus, we

can think of the integration as

T10 5 f(z0)

That is, it represents a process whereby a guess of z0 yields a prediction of T10. Viewed

in this way, we can see that what we desire is the value of z0 that yields a speci! c value

of T10. If, as in the example, we desire T10 5 200, the problem can be posed as

200 5 f(z0)

By bringing the goal of 200 over to the right-hand side of the equation, we generate a

new function, g(z0), that represents the difference between what we have, f(z0), and what

we want, 200.

g(z0) 5 f(z0) 2 200

If we drive this new function to zero, we will obtain the solution. The next example

illustrates the approach.

EXAMPLE 27.2 The Shooting Method for Nonlinear Problems

Problem Statement. Although it served our purposes for proving a simple boundary- value problem, our model for the rod in Eq. (27.1) was not very realistic. For one thing,

such a rod would lose heat by mechanisms such as radiation that are nonlinear.

Suppose that the following nonlinear ODE is used to simulate the temperature of

the heated rod:

d 2T

dx2 1 h–(Ta 2 T)

4 5 0

where h0 5 5 3 1028. Now, although it is still not a very good representation of heat

transfer, this equation is straightforward enough to allow us to illustrate how the shoot-

ing method can be used to solve a two-point nonlinear boundary-value problem. The

remaining problem conditions are as speci! ed in Example 27.1.

Solution. The second-order equation can be expressed as two ! rst-order ODEs:

dT

dx 5 z

dz

dx 5 h–(T 2 Ta)

4

Now, these equations can be integrated using any of the methods described in Chaps. 25

and 26. We used the constant step-size version of the fourth-order RK approach described

in Chap. 25. We implemented this approach as an Excel macro function written in Visual

786 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

BASIC. The function integrated the equations based on an initial guess for z(0) and

returned the temperature at x 5 10. The difference between this value and the goal of 200

was then placed in a spreadsheet cell. The Excel Solver was then invoked to adjust the

value of z(0) until the difference was driven to zero.

The result is shown in Fig. 27.4 along with the original linear case. As might be

expected, the nonlinear case is curved more than the linear model. This is due to the

power of four term in the heat transfer relationship.

200

T, C

100

0 z10

Nonlinear

Linear

50

FIGURE 27.4 The result of using the shooting method to solve a nonlinear problem.

The shooting method can become arduous for higher-order equations where the

necessity to assume two or more conditions makes the approach somewhat more dif! cult.

For these reasons, alternative methods are available, as described next.

27.1.2 Finite-Difference Methods

The most common alternatives to the shooting method are ! nite-difference approaches.

In these techniques, ! nite divided differences are substituted for the derivatives in the

original equation. Thus, a linear differential equation is transformed into a set of simul-

taneous algebraic equations that can be solved using the methods from Part Three.

For the case of Fig. 27.2, the ! nite-divided-difference approximation for the second

derivative is (recall Fig. 23.3)

d 2T

dx2 5

Ti11 2 2Ti 1 Ti21

¢x2

This approximation can be substituted into Eq. (27.1) to give

Ti11 2 2Ti 1 Ti21

¢x2 2 h¿ (Ti 2 Ta) 5 0

27.1 GENERAL METHODS FOR BOUNDARY-VALUE PROBLEMS 787

Collecting terms gives

2Ti21 1 (2 1 h¿ ¢x 2)Ti 2 Ti11 5 h¿¢x

2Ta (27.3)

This equation applies for each of the interior nodes of the rod. The ! rst and last interior

nodes, Ti21 and Ti11, respectively, are speci! ed by the boundary conditions. Therefore,

the resulting set of linear algebraic equations will be tridiagonal. As such, it can be solved

with the ef! cient algorithms that are available for such systems (Sec. 11.1).

EXAMPLE 27.3 Finite-Difference Approximation of Boundary-Value Problems

Problem Statement. Use the ! nite-difference approach to solve the same problem as in Example 27.1.

Solution. Employing the parameters in Example 27.1, we can write Eq. (27.3) for the rod from Fig. 27.2. Using four interior nodes with a segment length of Dx 5 2 m results

in the following equations:D2.04 21 0 021 2.04 21 0 0 21 2.04 21

0 0 21 2.04

T dT1T2 T3

T4

t 5 d 40.80.8 0.8

200.8

t which can be solved for

{T}T 5 :65.9698 93.7785 124.5382 159.4795 ; Table 27.1 provides a comparison between the analytical solution [Eq. (27.2)] and

the numerical solutions obtained in Examples 27.1 and 27.3. Note that there are some

discrepancies among the approaches. For both numerical methods, these errors can be

mitigated by decreasing their respective step sizes. Although both techniques perform

well for the present case, the ! nite-difference approach is preferred because of the ease

with which it can be extended to more complex cases.

The ! xed (or Dirichlet) boundary condition used in the previous example is but one of

several types that are commonly employed in engineering and science. A common alterna-

tive, called the Neumann boundary condition, is the case where the derivative is given.

TABLE 27.1 Comparison of the exact analytical solution with the shooting and fi nite- difference methods.

x True Shooting Method Finite Difference

0 40 40 40 2 65.9518 65.9520 65.9698 4 93.7478 93.7481 93.7785 6 124.5036 124.5039 124.5382 8 159.4534 159.4538 159.4795 10 200 200 200

788 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

We can use the heated rod model to demonstrate how derivative boundary condition

can be incorporated into the ! nite-difference approach,

0 5 d 2T

dx2 1 h¿ (Tq 2 T)

However, in contrast to our previous discussions, we will prescribe a derivative boundary

condition at one end of the rod,

dT

dx (0) 5 T ¿a

T(L) 5 Tb

Thus, we have a derivative boundary condition at one end of the solution domain and a

! xed boundary condition at the other.

As was done in Example 27.3, the rod is divided into a series of nodes and a ! nite-

difference version of the differential equation (Eq. 27.3) is applied to each interior node.

However, because its temperature is not speci! ed, the node at the left end must also be

included. Writing Eq. (27.3) for this node gives

2T21 1 (2 1 h¿¢x 2)T0 2 T1 5 h¿¢x

2Tq (27.3a)

Notice that an imaginary node (21) lying to the left of the rod’s end is required for

this equation. Although this exterior point might seem to represent a dif! culty, it actually

serves as the vehicle for incorporating the derivative boundary condition into the prob-

lem. This is done by representing the ! rst derivative in the x dimension at (0) by the

centered difference

dT

dx 5

T1 2 T21

2¢x

which can be solved for

T21 5 T1 2 2¢x dT

dx

Now we have a formula for T21 that actually re# ects the impact of the derivative. It can

be substituted into Eq. (27.3a) to give

(2 1 h¿¢x2)T0 2 2T1 5 h¿¢x 2Tq 2 2¢x

dT

dx (27.3b)

Consequently, we have incorporated the derivative into the balance.

A common example of a derivative boundary condition is the situation where the

end of the rod is insulated. In this case, the derivative is set to zero. This conclusion

follows directly from Fourier’s law, which states that the heat # ux is directly proportional

to the temperature gradient. Thus, insulating a boundary means that the heat # ux (and

consequently the gradient) must be zero.

Aside from the shooting and ! nite-difference methods, there are other techniques avail-

able for solving boundary-value problems. Some of these will be described in Part Eight.

These include steady-state (Chap. 29) and transient (Chap. 30) solution of two-dimensional

27.2 EIGENVALUE PROBLEMS 789

boundary-value problems using ! nite differences and steady-state solutions of the one-

dimensional problem with the ! nite-element approach (Chap. 31).

27.2 EIGENVALUE PROBLEMS

Eigenvalue, or characteristic-value, problems are a special class of boundary-value prob-

lems that are common in engineering problem contexts involving vibrations, elasticity,

and other oscillating systems. In addition, they are used in a wide variety of engineering

contexts beyond boundary-value problems. Before describing numerical methods for solv-

ing these problems, we will present some general background information. This includes

discussion of both the mathematics and the engineering signi! cance of eigenvalues.

27.2.1 Mathematical Background

Part Three dealt with methods for solving sets of linear algebraic equations of the general

form

[A]{X} 5 {B}

Such systems are called nonhomogeneous because of the presence of the vector {B} on

the right-hand side of the equality. If the equations comprising such a system are linearly

independent (that is, have a nonzero determinant), they will have a unique solution. In

other words, there is one set of x values that will make the equations balance.

In contrast, a homogeneous linear algebraic system has the general form

[A]{X} 5 0

Although nontrivial solutions (that is, solutions other than all x’s 5 0) of such systems

are possible, they are generally not unique. Rather, the simultaneous equations establish

relationships among the x’s that can be satis! ed by various combinations of values.

Eigenvalue problems associated with engineering are typically of the general form

(a11 2 l)x1 1 a12x2 1 p 1 a1n xn 5 0

a21x1 1 (a22 2 l)x2 1 p 1 a2n xn 5 0

. . . .

. . . .

. . . .

an1x1 1 an2x2 1 p 1 (ann 2 l)xn 5 0

where l is an unknown parameter called the eigenvalue, or characteristic value. A solution

{X} for such a system is referred to as an eigenvector. The above set of equations may

also be expressed concisely as

[[A] 2 l[I]]{X} 5 0 (27.4)

The solution of Eq. (27.4) hinges on determining l. One way to accomplish this is

based on the fact that the determinant of the matrix [[A] 2 l[I]] must equal zero for

nontrivial solutions to be possible. Expanding the determinant yields a polynomial in l.

The roots of this polynomial are the solutions for the eigenvalues. An example of this

approach will be provided in the next section.

790 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

27.2.2 Physical Background

The mass-spring system in Fig. 27.5a is a simple context to illustrate how eigenvalues

occur in physical problem settings. It also will help to illustrate some of the mathemat-

ical concepts introduced in the previous section.

To simplify the analysis, assume that each mass has no external or damping forces

acting on it. In addition, assume that each spring has the same natural length l and the

same spring constant k. Finally, assume that the displacement of each spring is measured

relative to its own local coordinate system with an origin at the spring’s equilibrium

position (Fig. 27.5a). Under these assumptions, Newton’s second law can be employed

to develop a force balance for each mass (recall Sec. 12.4),

m1 d 2×1

dt2 5 2kx1 1 k(x2 2 x1)

and

m2 d 2×2

dt2 5 2k(x2 2 x1) 2 kx2

where xi is the displacement of mass i away from its equilibrium position (Fig. 27.5b).

These equations can be expressed as

m1 d 2×1

dt2 2 k(22×1 1 x2) 5 0 (27.5a)

m2 d 2×2

dt2 2 k(x1 2 2×2) 5 0 (27.5b)

From vibration theory, it is known that solutions to Eq. (27.5) can take the form

xi 5 Ai sin(vt) (27.6)

x

(a) 0

0

0 x1 0 x2

x

(b)

m1 m2

m1 m2

FIGURE 27.5 Positioning the masses away from equilibrium creates forces in the springs that upon release lead to oscillations of the masses. The positions of the masses can be referenced to local coordinates with origins at their respective equilibrium positions.

27.2 EIGENVALUE PROBLEMS 791

where Ai 5 the amplitude of the vibration of mass i and v 5 the frequency of the vibra-

tion, which is equal to

v 5 2p

TP (27.7)

where Tp is the period. From Eq. (27.6) it follows that

x–i 5 2Ai v 2 sin (vt) (27.8)

Equations (27.6) and (27.8) can be substituted into Eq. (27.5), which, after collection of

terms, can be expressed asa 2k m1

2 v 2b A1 2 km1 A2 5 0 (27.9a) 2

k

m2 A1 1 a 2km2 2 v2b A2 5 0 (27.9b)

Comparison of Eq. (27.9) with Eq. (27.4) indicates that at this point, the solution has

been reduced to an eigenvalue problem.

EXAMPLE 27.4 Eigenvalues and Eigenvectors for a Mass-Spring System

Problem Statement. Evaluate the eigenvalues and the eigenvectors of Eq. (27.9) for the case where ml 5 m2 5 40 kg and k 5 200 N/m.

Solution. Substituting the parameter values into Eq. (27.9) yields

(10 2 v2) A1 2 5A2 5 0

25A1 1 (10 2 v 2) A2 5 0

The determinant of this system is [recall Eq. (9.3)]

(v2)2 2 20v2 1 75 5 0

which can be solved by the quadratic formula for v2 5 15 and 5 s22. Therefore, the

frequencies for the vibrations of the masses are v 5 3.873 s21 and 2.236 s21, respectively.

These values can be used to determine the periods for the vibrations with Eq. (27.7). For

the ! rst mode, Tp 5 1.62 s, and for the second, Tp 5 2.81 s.

As stated in Sec. 27.2.1, a unique set of values cannot be obtained for the unknowns.

However, their ratios can be speci! ed by substituting the eigenvalues back into the equa-

tions. For example, for the ! rst mode (v2 5 15 s22), Al 5 2A2. For the second mode

(v2 5 5 s22), A1 5 A2.

This example provides valuable information regarding the behavior of the system in

Fig. 27.5. Aside from its period, we know that if the system is vibrating in the ! rst mode,

the amplitude of the second mass will be equal but of opposite sign to the amplitude of

the ! rst. As in Fig. 27.6a, the masses vibrate apart and then together inde! nitely.

In the second mode, the two masses have equal amplitudes at all times. Thus, as in

Fig. 27.6b, they vibrate back and forth in unison. It should be noted that the con! gura-

tion of the amplitudes provides guidance on how to set their initial values to attain pure

792 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

motion in either of the two modes. Any other con! guration will lead to superposition of

the modes (recall Chap. 19).

27.2.3 A Boundary-Value Problem

Now that you have been introduced to eigenvalues, we turn to the type of problem that

is the subject of the present chapter: boundary-value problems for ordinary differential

equations. Figure 27.7 shows a physical system that can serve as a context for examining

this type of problem.

The curvature of a slender column subject to an axial load P can be modeled by

d 2y

dx 2 5

M

EI (27.10)

where d2yydx2 speci! es the curvature, M 5 the bending moment, E 5 the modulus of elasticity, and I 5 the moment of inertia of the cross section about its neutral axis. Con-

sidering the free body in Fig. 27.7b, it is clear that the bending moment at x is M 5 2Py.

Substituting this value into Eq. (27.10) gives

d 2y

dx2 1 p2y 5 0 (27.11)

TF = 1.625

t

TF = 2.815

(a) First mode (b) Second mode

FIGURE 27.6 The principal modes of vibration of two equal masses connected by three identical springs be- tween fi xed walls.

27.2 EIGENVALUE PROBLEMS 793

where

p2 5 P

EI (27.12)

For the system in Fig. 27.7, subject to the boundary conditions

y(0) 5 0 (27.13a)

y(L) 5 0 (27.13b)

the general solution for Eq. (27.11) is

y 5 A sin(px) 1 B cos(px) (27.14)

where A and B are arbitrary constants that are to be evaluated via the boundary condi-

tions. According to the ! rst condition [Eq. (27.13a)],

0 5 A sin(0) 1 B cos(0)

Therefore, we conclude that B 5 0.

According to the second condition [Eq. (27.13b)],

0 5 A sin (pL) 1 B cos (pL)

But, since B 5 0, A sin (pL) 5 0. Because A 5 0 represents a trivial solution, we con-

clude that sin (pL) 5 0. For this equality to hold,

pL 5 np for n 5 1, 2, 3, p p (27.15)

Thus, there are an in! nite number of values that meet the boundary condition. Equation

(27.15) can be solved for

p 5 np

L for n 5 1, 2, 3, p (27.16)

which are the eigenvalues for the column.

FIGURE 27.7 (a) A slender rod. (b) A free- body diagram of a rod.

(a)

(0, 0)

P

P9

(L, 0)

x

x

y

y

P9

M

(b)

P

794 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

Figure 27.8, which shows the solution for the ! rst four eigenvalues, can provide

insight into the physical signi! cance of the results. Each eigenvalue corresponds to a

way in which the column buckles. Combining Eqs. (27.12) and (27.16) gives

P 5 n2p2EI

L2 for n 5 1, 2, 3, p (27.17)

These can be thought of as buckling loads because they represent the levels at which the

column moves into each succeeding buckling con! guration. In a practical sense, it is

usually the ! rst value that is of interest because failure will usually occur when the

column ! rst buckles. Thus, a critical load can be de! ned as

P 5 p2EI

L2

which is formally known as Euler’s formula.

EXAMPLE 27.5 Eigenvalue Analysis of an Axially Loaded Column

Problem Statement. An axially loaded wooden column has the following characteris- tics: E 5 10 3 109 Pa, I 5 1.25 3 1025 m4, and L 5 3 m. Determine the ! rst eight

eigenvalues and the corresponding buckling loads.

FIGURE 27.8 The fi rst four eigenvalues for the slender rod from Fig. 27.7.

(a) n = 1

P = p 2EI

L2

(b) n = 2

P = 4p 2EI

L2 P = 9p

2EI

L2 P = 16p

2EI

L2

(c) n = 3 (d) n = 4

27.2 EIGENVALUE PROBLEMS 795

Solution. Equations (27.16) and (27.17) can be used to compute

n p, m22 P, kN

1 1.0472 137.078 2 2.0944 548.311 3 3.1416 1233.701 4 4.1888 2193.245 5 5.2360 3426.946 6 6.2832 4934.802 7 7.3304 6716.814 8 8.3776 8772.982

The critical buckling load is, therefore, 137.078 kN.

Although analytical solutions of the sort obtained above are useful, they are often

dif! cult or impossible to obtain. This is usually true when dealing with complicated

systems or those with heterogeneous properties. In such cases, numerical methods of the

sort described next are the only practical alternative.

27.2.4 The Polynomial Method

Equation (27.11) can be solved numerically by substituting a central ! nite-divided-difference

approximation (Fig. 23.3) for the second derivative to give

yi11 2 2yi 1 yi21

h2 1 p2yi 5 0

which can be expressed as

yi21 2 (2 2 h 2 p2)yi 1 yi11 5 0 (27.18)

Writing this equation for a series of nodes along the axis of the column yields a homo-

geneous system of equations. For example, if the column is divided into ! ve segments

(that is, four interior nodes), the result is

≥ (2 2 h 2p2) 21 0 0

21 (2 2 h2p2) 21 0

0 21 (2 2 h2p2) 21

0 0 21 (2 2 h2p2)

¥ µ y1y2 y3

y4

∂ 5 0 (27.19) Expansion of the determinant of the system yields a polynomial, the roots of which are

the eigenvalues. This approach, called the polynomial method, is performed in the fol-

lowing example.

EXAMPLE 27.6 The Polynomial Method

Problem Statement. Employ the polynomial method to determine the eigenvalues for the axially loaded column from Example 27.5 using (a) one, (b) two, (c) three, and (d) four

interior nodes.

796 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

Solution.

(a) Writing Eq. (27.18) for one interior node yields (h 5 3y2)

2(2 2 2.25p2)y1 5 0

Thus, for this simple case, the eigenvalue is analyzed by setting the determinant

equal to zero

2 2 2.25p2 5 0

and solving for p 5 60.9428, which is about 10 percent less than the exact value

of 1.0472 obtained in Example 27.4.

(b) For two interior nodes (h 5 3y3), Eq. (27.18) is written asc (2 2 p2) 21 21 (2 2 p2)

d e y1 y2 f 5 0

Expansion of the determinant gives

(2 2 p2)2 2 1 5 0

which can be solved for p 5 61 and 61.73205. Thus, the ! rst eigenvalue is now about

4.5 percent low and a second eigenvalue is obtained that is about 17 percent low.

(c) For three interior points (h 5 3y4), Eq. (27.18) yields

£ 2 2 0.5625p2 21 021 2 2 0.5625p2 21 0 21 2 2 0.5625p2

§ • y1y2 y3

¶ 5 0 (E27.6.1) The determinant can be set equal to zero and expanded to give

(2 2 0.5625p2)3 2 2(2 2 0.5625p2) 5 0

For this equation to hold, 2 2 0.5625p2 5 0 and 2 2 0.5625p2 5 12. Therefore, the ! rst three eigenvalues can be determined as

p 5 ;1.0205 Zet Z 5 2.5%

p 5 ;1.8856 Zet Z 5 10%

p 5 ;2.4637 Zet Z 5 22%

(d) For four interior points (h 5 3y5), the result is Eq. (27.19) with 2 2 0.36p2 on the diagonal. Setting the determinant equal to zero and expanding it gives

(2 2 0.36p2)4 2 3(2 2 0.36p2)2 1 1 5 0

which can be solved for the ! rst four eigenvalues

p 5 ;1.0301 Zet Z 5 1.6%

p 5 ;1.9593 Zet Z 5 6.5%

p 5 ;2.6967 Zet Z 5 14%

p 5 ;3.1702 Zet Z 5 24%

27.2 EIGENVALUE PROBLEMS 797

Table 27.2, which summarizes the results of this example, illustrates some funda-

mental aspects of the polynomial method. As the segmentation is made more re! ned,

additional eigenvalues are determined and the previously determined values become pro-

gressively more accurate. Thus, the approach is best suited for cases where the lower

eigenvalues are required.

TABLE 27.2 The results of applying the polynomial method to an axially loaded column. The numbers in parentheses represent the absolute value of the true percent relative error.

Polynomial Method

Eigenvalue True h 5 3/2 h 5 3/3 h 5 3/4 h 5 3/5

1 1.0472 0.9428 1.0000 1.0205 1.0301 (10%) (4.5%) (2.5%) (1.6%) 2 2.0944 1.7321 1.8856 1.9593 (21%) (10%) (65%) 3 3.1416 2.4637 2.6967 (22%) (14%) 4 4.1888 3.1702 (24%)

27.2.5 The Power Method

The power method is an iterative approach that can be employed to determine the largest

eigenvalue. With slight modi! cation, it can also be employed to determine the smallest

and the intermediate values. It has the additional bene! t that the corresponding eigenvector

is obtained as a by-product of the method.

Determination of the Largest Eigenvalue. To implement the power method, the system being analyzed must be expressed in the form

[A]{X} 5 l{X} (27.20)

As illustrated by the following example, Eq. (27.20) forms the basis for an iterative solu-

tion technique that eventually yields the highest eigenvalue and its associated eigenvector.

EXAMPLE 27.7 Power Method for Highest Eigenvalue

Problem Statement. Employ the power method to determine the highest eigenvalue for part (c) of Example 27.6.

Solution. The system is ! rst written in the form of Eq. (27.20),

3.556×1 2 1.778×2 5 lx1

21.778×1 1 3.556×2 2 1.778×3 5 lx2

21.778×2 1 3.556×3 5 lx3

798 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

Then, assuming the x’s on the left-hand side of the equation are equal to 1,

3.556(1) 2 1.778(1) 5 1.778

21.778(1) 1 3.556(1) 2 1.778(1) 5 0

21.778(1) 1 3.556(1) 5 1.778

Next, the right-hand side is normalized by 1.778 to make the largest element equal to

•1.7780 1.778

¶ 5 1.778 •10 1

¶ Thus, the ! rst estimate of the eigenvalue is 1.778. This iteration can be expressed con-

cisely in matrix form as

£ 3.556 21.778 021.778 3.556 21.778 0 21.778 3.556

§ •11 1

¶ 5 •1.7780 1.778

¶ 5 1.778•10 1

¶ The next iteration consists of multiplying [A] by :1 0 1 ;T to give £ 3.556 21.778 021.778 3.556 21.778

0 21.778 3.556

§ •10 1

¶ 5 • 3.55623.556 3.556

¶ 5 3.556• 121 1

¶ Therefore, the eigenvalue estimate for the second iteration is 3.556, which can be em-

ployed to determine the error estimate

Zea Z 5 ` 3.556 2 1.778 3.556

` 100% 5 50% The process can then be repeated.

Third iteration:

£ 3.556 21.778 021.778 3.556 21.778 0 21.778 3.556

§ • 121 1

¶ 5 • 5.33427.112 5.334

¶ 5 27.112•20.751 20.75

¶ where 0ea 0 5 150% (which is high because of the sign change). Fourth iteration:

£ 3.556 21.778 021.778 3.556 21.778 0 21.778 3.556

§ •20.751 20.75

¶ 5 •24.4456.223 24.445

¶ 5 6.223•20.7141 20.714

¶ where 0ea 0 5 214% (again in# ated because of sign change). Fifth iteration:

£ 3.556 21.778 021.778 3.556 21.778 0 21.778 3.556

§ •20.7141 20.714

¶ 5 •24.3176.095 24.317

¶ 5 6.095•20.7081 20.708

27.2 EIGENVALUE PROBLEMS 799

Thus, the normalizing factor is converging on the value of 6.070 (52.46372) obtained

in part (c) of Example 27.6.

Note that there are some instances where the power method will converge to the second-

largest eigenvalue instead of to the largest. James, Smith, and Wolford (1985) provide an

illustration of such a case. Other special cases are discussed in Fadeev and Fadeeva (1963).

Determination of the Smallest Eigenvalue. There are often cases in engineering where we are interested in determining the smallest eigenvalue. Such was the case for

the rod in Fig. 27.7, where the smallest eigenvalue could be used to identify a critical

buckling load. This can be done by applying the power method to the matrix inverse of

[A]. For this case, the power method will converge on the largest value of 1yl—in other words, the smallest value of l.

EXAMPLE 27.8 Power Method for Lowest Eigenvalue

Problem Statement. Employ the power method to determine the lowest eigenvalue for part (c) of Example 27.6.

Solution. After dividing Eq. E27.6.1 by h2 (5 0.5625), its matrix inverse can be evaluated as

[A]21 5 £ 0.422 0.281 0.1410.281 0.562 0.281 0.141 0.281 0.422

§ Using the same format as in Example 27.7, the power method can be applied to this matrix.

First iteration:

£ 0.422 0.281 0.1410.281 0.562 0.281 0.141 0.281 0.422

§ •11 1

¶ 5 •0.8841.124 0.884

¶ 5 1.124 •0.7511 0.751

¶ Second iteration:

£ 0.422 0.281 0.1410.281 0.562 0.281 0.141 0.281 0.422

§ •0.7511 0.751

¶ 5 •0.7040.984 0.704

¶ 5 0.984 •0.7151 0.715

¶ where 0ea 0 5 14.6%. Third iteration:

£ 0.422 0.281 0.1410.281 0.562 0.281 0.141 0.281 0.422

§ •0.7151 0.715

¶ 5 •0.6840.964 0.684

¶ 5 0.964 •0.7091 0.709

¶ where 0ea 0 5 4%. Thus, after only three iterations, the result is converging on the value of 0.9602, which is

the reciprocal of the smallest eigenvalue, 1.0205(511y0.9602), obtained in Example 27.6c.

800 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

Determination of Intermediate Eigenvalues. After ! nding the largest eigenvalue, it is possible to determine the next highest by replacing the original matrix by one that

includes only the remaining eigenvalues. The process of removing the largest known

eigenvalue is called de” ation. The technique outlined here, Hotelling’s method, is de-

signed for symmetric matrices. This is because it exploits the orthogonality of the eigen-

vectors of such matrices, which can be expressed as

{X}Ti {X}j 5 e0 for i ? j 1 for i 5 j

(27.21)

where the components of the eigenvector {X} have been normalized so that {X}T{X} 5 1,

that is, so that the sum of the squares of the components equals 1. This can be accom-

plished by dividing each of the elements by the normalizing factor

B a n

k51

x2k

Now, a new matrix [A]2 can be computed as

[A]2 5 [A]1 2 l1{X}1{X} T 1 (27.22)

where [A]1 5 the original matrix and l1 5 the largest eigenvalue. If the power method

is applied to this matrix, the iteration process will converge to the second largest eigen-

value, l2. To show this, ! rst postmultiply Eq. (27.22) by {X}1,

[A]2{X}1 5 [A]1{X}1 2 l1{X}1{X} T 1{X}1

Invoking the orthogonality principle converts this equation to

[A]2{X}1 5 [A]1{X}1 2 l1{X}1

where the right-hand side is equal to zero according to Eq. (27.20). Thus, [A]2{X}1 5 0.

Consequently, l 5 0 and {X} 5 {X}1 is a solution to [A]2{X} 5 l{X}. In other words,

the [A]2 has eigenvalues of 0, l2, l3, . . . , ln. The largest eigenvalue, l1, has been replaced

by a 0 and, therefore, the power method will converge on the next biggest l2.

The above process can be repeated by generating a new matrix [A]3, etc. Although

in theory this process could be continued to determine the remaining eigenvalues, it is

limited by the fact that errors in the eigenvectors are passed along at each step. Thus, it

is only of value in determining several of the highest eigenvalues. Although this is some-

what of a shortcoming, such information is precisely what is required in many engineer-

ing problems.

27.2.6 Other Methods

A wide variety of additional methods are available for solving eigenvalue problems. Most

are based on a two-step process. The ! rst step involves transforming the original matrix

to a simpler form (for example, tridiagonal) that retains all the original eigenvalues. Then,

iterative methods are used to determine these eigenvalues.

Many of these approaches are designed for special types of matrices. In particular,

a variety of techniques are devoted to symmetric systems. For example, Jacobi’s

27.3 ODES AND EIGENVALUES WITH SOFTWARE PACKAGES 801

method transforms a symmetric matrix to a diagonal matrix by eliminating off-diagonal

terms in a systematic fashion. Unfortunately, the method requires an in! nite number

of operations because the removal of each nonzero element often creates a new nonzero

value at a previous zero element. Although an in! nite time is required to create all

nonzero off-diagonal elements, the matrix will eventually tend toward a diagonal form.

Thus, the approach is iterative in that it is repeated until the off-diagonal terms are

“suf! ciently” small.

Given’s method also involves transforming a symmetric matrix into a simpler form.

However, in contrast to the Jacobi method, the simpler form is tridiagonal. In addition,

it differs in that the zeros that are created in off-diagonal positions are retained. Conse-

quently, it is ! nite and, thus, more ef! cient than Jacobi’s method.

Householder’s method also transforms a symmetric matrix into a tridiagonal form.

It is a ! nite method and is more ef! cient than Given’s approach in that it reduces whole

rows and columns of off-diagonal elements to zero.

Once a tridiagonal system is obtained from Given’s or Householder’s method, the

remaining step involves ! nding the eigenvalues. A direct way to do this is to expand the

determinant. The result is a sequence of polynomials that can be evaluated iteratively for

the eigenvalues.

Aside from symmetric matrices, there are also techniques that are available when all

eigenvalues of a general matrix are required. These include the LR method of Rutishauser

and the QR method of Francis. Although the QR method is less ef! cient, it is usually the

preferred approach because it is more stable. As such, it is considered to be the best

general-purpose solution method.

Finally, it should be mentioned that the aforementioned techniques are often used in

tandem to capitalize on their respective strengths. For example, Given’s and Householder’s

methods can also be applied to nonsymmetric systems. The result will not be tridiagonal

but rather a special type called the Hessenberg form. One approach is to exploit the speed

of Householder’s approach by employing it to transform the matrix to this form and then

use the stable QR algorithm to ! nd the eigenvalues. Additional information on these and

other issues related to eigenvalues can be found in Ralston and Rabinowitz (1978),

Wilkinson (1965), Fadeev and Fadeeva (1963), and Householder (1953, 1964). Computer

codes can be found in a number of sources including Press et al. (2007). Rice (1983)

discusses available software packages.

27.3 ODES AND EIGENVALUES WITH SOFTWARE PACKAGES

Software packages have great capabilities for solving ODEs and determining eigenvalues.

This section outlines some of the ways in which they can be applied for this purpose.

27.3.1 Excel

Excel’s direct capabilities for solving eigenvalue problems and ODEs are limited. How-

ever, if some programming is done (for example, macros), they can be combined with

Excel’s visualization and optimization tools to implement some interesting applications.

Section 28.1 provides an example of how the Excel Solver can be used for parameter

estimation of an ODE.

802 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

27.3.2 MATLAB

As might be expected, the standard MATLAB software package has excellent capa-

bilities for determining eigenvalues and eigenvectors. However, it also has built-in

functions for solving ODEs. The standard ODE solvers include two functions to im-

plement the adaptive step-size Runge-Kutta Fehlberg method (recall Sec. 25.5.2).

These are ode23, which uses second- and third-order formulas to attain medium

accuracy, and ode45, which uses fourth- and ! fth-order formulas to attain higher

accuracy. The following example illustrates how they can be used to solve a system

of ODEs.

EXAMPLE 27.9 Using MATLAB for Eigenvalues and ODEs

Problem Statement. Explore how MATLAB can be used to solve the following set of nonlinear ODEs from t 5 0 to 20:

dx

dt 5 1.2x 2 0.6x y

dy

dt 5 20.8y 1 0.3xy

where x 5 2 and y 5 1 at t 5 0. As we will see in the next chapter (Sec. 28.2), such

equations are referred to as predator-prey equations.

Solution. Before obtaining a solution with MATLAB, you must use a text processor to create an M-! le containing the right-hand side of the ODEs. This M-! le will then be

accessed by the ODE solver [where x 5 y(1) and y 5 y(2)]:

We stored this M-! le under the name: predprey.m.

Next, start up MATLAB, and enter the following commands to specify the integra-

tion range and the initial conditions:

The solver can then be invoked by

This command will then solve the differential equations in predprey.m over the range

de! ned by using the initial conditions found in . The results can be displayed

by simply typing

which yields Fig. 27.9.

27.3 ODES AND EIGENVALUES WITH SOFTWARE PACKAGES 803

In addition, it is also instructive to generate a state-space plot, that is, a plot of the

dependent variables versus each other by

which yields Fig. 27.10.

FIGURE 27.9 Solution of predator-prey model with MATLAB.

FIGURE 27.10 State-space plot of predator-prey model with MATLAB.

MATLAB also has a range of functions designed for stiff systems. These include

ode15s and ode23s. As in the following example, they succeed where the standard

functions fail.

804 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

EXAMPLE 27.10 MATLAB for Stiff ODEs

Problem Statement. Van der Pol’s equation can be written as

dy1

dt 5 y2

dy2

dt 5 m(1 2 y21)y2 2 y1

As the parameter m gets large, the system becomes progressively stiffer. Given the

initial conditions, y1(0) 5 y2(0) 5 1, use MATLAB to solve the following two cases

(a) For m 5 1, use ode45 to solve from t 5 0 to 20.

(b) For m 5 1000, use ode23s to solve from t 5 0 to 3000.

Solution.

(a) An M-! le can be created to hold the differential equations,

Then, as in Example 27.9, ode45 can be invoked and the results plotted (Fig. 27.11),

(b) If a standard solver like ode45 is used for the stiff case (m 5 1000), it will fail miser-

ably (try it, if you like). However, ode23s does an ef! cient job. After revising the M-! le

to re” ect the new value of m, the solution can be obtained and graphed (Fig. 27.12),

FIGURE 27.11 Nonstiff form of Van der Pol’s equation solved with MATLAB’s ode45 function.

27.3 ODES AND EIGENVALUES WITH SOFTWARE PACKAGES 805

Notice how this solution has much sharper edges than for case (a). This is a visual

manifestation of the “stiffness” of the solution.

FIGURE 27.12 Stiff form of Van der Pol’s equation solved with MATLAB’s ode23s function.

For eigenvalues, the capabilities are also very easy to apply. Recall that, in our discus-

sion of stiff systems in Chap. 26, we presented the stiff system de! ned by Eq. (26.6).

Such linear ODEs can be written as an eigenvalue problem of the formc 5 2 l 23 2100 301 2 l

d e e1 e2 f 5 {0}

where l and {e} 5 the eigenvalue and eigenvector, respectively.

MATLAB can then be employed to evaluate both the eigenvalues (d) and eigenvec-

tors (v) with the following simple commands:

Thus, we see that the eigenvalues are of quite different magnitudes, which is typical of

a stiff system.

806 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

The eigenvalues can be interpreted by recognizing that the general solution for a

system of ODEs can be represented as the sum of exponentials. For example, the solution

for the present case would be of the form

y1 5 c11e 23.9899t

1 c12e 2302.0101t

y2 5 c21e 23.9899t

1 c22e 2302.0101t

where cij 5 the part of the initial condition for yi that is associated with the jth eigenvalue.

It should be noted that the c’s can be evaluated from the initial conditions and the

eigenvectors. Any good book on differential equations, for example, Boyce and DiPrima

(1992), will provide an explanation of how this can be done.

Because, for the present case, all the eigenvalues are positive (and hence negative

in the exponential function), the solution consists of a series of decaying exponentials.

The one with the largest eigenvalue (in this case, 302.0101) would dictate the step size

if an explicit solution technique were used.

27.3.3 Mathcad

Mathcad has a number of different functions that solve differential equations and deter-

mine eigenvalues and eigenvectors. The most basic technique employed by Mathcad to

solve systems of ! rst-order differential equations is a ! xed step-size fourth-order Runge-

Kutta algorithm. This is provided by the rk xed function. Although this is a good all-

purpose integrator, it is not always ef! cient. Therefore, Mathcad supplies Rkadapt,

which is a variable step sized version of rk xed. It is well suited for functions that

change rapidly in some regions and slowly in others. Similarly, if you know your solu-

tion is a smooth function, then you may ! nd that the Mathcad Bulstoer function works

well. This function employs the Bulirsch-Stoer method and is often both ef! cient and

highly accurate for smooth functions.

Stiff differential equations are at the opposite end of the spectrum. Under these

conditions the rk xed function may be very inef! cient or unstable. Therefore, Mathcad

provides two special methods speci! cally designed to handle stiff systems. These func-

tions are called Stiffb and Stiffr and are based on a modi! ed Bulirsch-Stoer method for

stiff systems and the Rosenbrock method.

As an example, let’s use Mathcad to solve the following nonlinear ODEs,

dy1

dt 5 1.2y1 2 0.6y1 y2

dy2

dt 5 20.8y2 1 0.3y1 y2

with the initial conditions, y1 5 2 and y2 5 1. This system, called Lotka-Volterra equa-

tions, are used by environmental engineers and ecologists to evaluate the interactions of

predators (y2) and prey (y1).

As in Fig. 27.13, the de! nition symbol is ! rst used to de! ne the vector D(u, y)

holding the right-hand sides of the ODEs for input to rk xed. Note that y1 and y2 in

the ODEs are changed to y0 and y1 to comply with Mathcad requirements. In addition,

27.3 ODES AND EIGENVALUES WITH SOFTWARE PACKAGES 807

we de! ne the initial conditions (y0), the integration limit (tf) and the number of values

we want to generate (npts). The solutions for rk xed with 200 steps between t 5 0

and tf are stored in the ysol matrix. The solution is displayed graphically in the plot

in Fig. 27.13.

Next, we can illustrate how Mathcad evaluates eigenvalues and eigenvectors. The

function eigenvals(M) returns the eigenvalues of the square matrix M. The function

eigenvecs(M) returns a matrix containing normalized eigenvectors corresponding to the

eigenvectors of M whereas eigenvec(M,e) returns the eigenvector corresponding to the

eigenvalue e. We can illustrate these functions for the system given by [recall Eq. (26.6)]

dy1

dt 5 25y1 1 3y2

dy2

dt 5 100y1 2 301y2

The results are shown in Fig. 27.14. Because the eigenvalues (aa) are of different

magnitudes, the system is stiff. Note that bb holds the speci! c eigenvector associated

with the smaller eigenvalue. The result cc is a matrix containing both eigenvectors as its

columns.

FIGURE 27.13 Mathcad screen to solve a system of ODEs.

808 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

FIGURE 27.14 Mathcad screen to solve for the eigenvalues of a system of ODEs.

PROBLEMS

27.1 A steady-state heat balance for a rod can be represented as

d 2T

dx2 2 0.15T 5 0

Obtain an analytical solution for a 10-m rod with T(0) 5 240 and

T(10) 5 150.

27.2 Use the shooting method to solve Prob. 27.1.

27.3 Use the ! nite-difference approach with Dx 5 1 to solve

Prob. 27.1.

27.4 Use the shooting method to solve

7 d 2y

dx2 2 2

dy

dx 2 y 1 x 5 0

with the boundary conditions y(0) 5 5 and y(20) 5 8.

27.5 Solve Prob. 27.4 with the ! nite-difference approach using

Dx 5 2.

27.6 Use the shooting method to solve

d 2T

dx2 2 1 3 1027(T 1 273)4 1 4(150 2 T) 5 0 (P27.6.1)

Obtain a solution for boundary conditions: T(0) 5 200 and

T(0.5) 5 100.

27.7 Differential equations like the one solved in Prob. 27.6 can

often be simpli! ed by linearizing their nonlinear terms. For example,

a ! rst-order Taylor series expansion can be used to linearize the

quartic term in Eq. (P27.6.1) as

1 3 1027(T 1 273)4 5 1 3 1027(Tb 1 273) 4

1 4

3 1027(Tb 1 273) 3(T 2 Tb)

where Tb is a base temperature about which the term is linearized.

Substitute this relationship into Eq. (P27.6.1), and then solve the

resulting linear equation with the ! nite-difference approach.

Employ Tb 5 150 and Dx 5 0.01 to obtain your solution.

27.8 Repeat Example 27.4 but for three masses. Produce a plot like

Fig. 27.6 to identify the principle modes of vibration. Change all

the k’s to 240.

27.9 Repeat Example 27.6, but for ! ve interior points (h 5 3y6).

PROBLEMS 809

dz

dt 5 2bz 1 xy

where s 5 10, b 5 2.666667, and r 5 28. Employ initial condi-

tions of x 5 y 5 z 5 5 and integrate from t 5 0 to 20.

27.23 Use ! nite differences to solve the boundary-value ordinary

differential equation

d 2u

dx2 1 6

du

dx 2 u 5 2

with boundary conditions u(0) 5 10 and u(2) 5 1. Plot the results

of u versus x. Use Dx 5 0.1.

27.24 Solve the nondimensionalized ODE using ! nite difference

methods that describe the temperature distribution in a circular rod

with internal heat source S

d 2T

dr2 1

1

r dT

dr 1 S 5 0

over the range 0 # r # 1, with the boundary conditions

T(r 5 1) 5 1 dT

dr ` r50

5 0

for S 5 1, 10, and 20 K/m2. Plot the temperature versus radius.

27.25 Derive the set of differential equations for a three mass–four

spring system (Fig. P27.25) that describes their time motion. Write

the three differential equations in matrix form,

[Acceleration vector]1[kym matrix][displacement vector x] 50

Note each equation has been divided by the mass. Solve for the

eigenvalues and natural frequencies for the following values of

mass and spring constants: k1 5 k4 5 15 N/m, k2 5 k3 5 35 N/m,

and m1 5 m2 5 m3 5 1.5 kg.

27.10 Use minors to expand the determinant of

£ 2 2 l 8 108 4 2 l 5 10 5 7 2 l

§ 27.11 Use the power method to determine the highest eigenvalue

and corresponding eigenvector for Prob. 27.10.

27.12 Use the power method to determine the lowest eigenvalue

and corresponding eigenvector for Prob. 27.10.

27.13 Develop a user-friendly computer program to implement the

shooting method for a linear second-order ODE. Test the program

by duplicating Example 27.1.

27.14 Use the program developed in Prob. 27.13 to solve Probs.

27.2 and 27.4.

27.15 Develop a user-friendly computer program to implement the

! nite-difference approach for solving a linear second-order ODE.

Test it by duplicating Example 27.3.

27.16 Use the program developed in Prob. 27.15 to solve Probs.

27.3 and 27.5.

27.17 Develop a user-friendly program to solve for the largest eigen-

value with the power method. Test it by duplicating Example 27.7.

27.18 Develop a user-friendly program to solve for the smallest ei-

genvalue with the power method. Test it by duplicating Example 27.8.

27.19 Use the Excel Solver to directly solve (that is, without lin-

earization) Prob. 27.6 using the ! nite-difference approach. Employ

Dx 5 0.1 to obtain your solution.

27.20 Use MATLAB to integrate the following pair of ODEs from

t 5 0 to 100:

dy1

dt 5 0.35y1 2 1.6y1y2

dy2

dt 5 0.04y1y2 2 0.15y2

where y1 5 1 and y2 5 0.05 at t 5 0. Develop a state-space plot

(y1 versus y2) of your results.

27.21 The following differential equation can be used to analyze

the vibrations of an automobile shock absorber:

1.25 3 106 d 2x

dt2 1 1 3 107

dx

dt 1 1.5 3 109x 5 0

Transform this equation into a pair of ODEs. (a) Use MATLAB to

solve these equations from t 5 0 to 0.4 for the case where x 5 0.5,

and dxydt 5 0 at t 5 0. (b) Use MATLAB to determine the eigen- values and eigenvectors for the system.

27.22 Use MATLAB or Mathcad to integrate

dx

dt 5 2sx 1 sy

dy

dt 5 rx 2 y 2 xz

FIGURE P27.25

k2 k3 k4k1

x1 x2 x3

m1 m2 m3

27.26 Consider the mass-spring system in Fig. P27.26. The fre-

quencies for the mass vibrations can be determined by solving for

the eigenvalues and by applying M x $

1 kx 5 0, which yields

£m1 0 00 m2 0 0 0 m3

§ • x$1x$2 x $

3

¶ 1 £ 2k 2k 2k2k 2k 2k 2k 2k 2k

§ • x1x2 x3

¶ 5 • 00 0

810 BOUNDARY-VALUE AND EIGENVALUE PROBLEMS

(b) Using the fourth-order RK method with a constant step size of

0.03125.

(c) Using the MATLAB function ode45.

(d) Using the MATLAB function ode23s.

(e) Using the MATLAB function ode23tb.

Present your results in graphical form.

27.28 A heated rod with a uniform heat source can be modeled

with the Poisson equation,

d 2T

dx2 5 2f (x)

Given a heat source f(x) 5 25 and the boundary conditions,

T(x 5 0) 5 40 and T(x 5 10) 5 200, solve for the temperature distri-

bution with (a) the shooting method and (b) the ! nite-difference

method ( Dx 5 2).

27.29 Repeat Prob. 27.28, but for the following heat source: f(x) 5

0.12×3 2 2.4×2 1 12x.

27.30 Suppose that the position of a falling object is governed by

the following differential equation,

d 2x

dt2 1

c

m dx

dt 2 g 5 0

where c 5 a ! rst-order drag coef! cient 5 12.5 kg/s, m 5 mass 5

70 kg, and g 5 gravitational acceleration 5 9.81 m/s2. Use the

shooting method to solve this equation for position and velocity

given the boundary conditions, x(0) 5 0 and x(12) 5 500.

27.31 Repeat Example 27.3, but insulate the left end of the rod.

That is, change the boundary condition at the left end of the rod to

T9(0) 5 0.

Applying the guess x 5 x0e ivt as a solution, we get the following

matrix:

£ 2k 2 m1v2 2k 2k2k 2k2m2v2 2k 2k 2k 2k2m3v

2

§ • x01x02 x03

¶ eivt 5 •00 0

¶ Use MATLAB’s command to solve for the eigenvalues of the

k 2 mv2 matrix above. Then use these eigenvalues to solve for the

frequencies (v). Let m1 5 m2 5 m3 5 1 kg, and k 5 2 N/m.

FIGURE P27.26

k

k

k

x1 x2 x3

m1 m2 m3

27.27 The following nonlinear, parasitic ODE was suggested by

Hornbeck (1975):

dy1

dt 5 5(y1 2 t

2)

If the initial condition is y1(0) 5 0.08, obtain a solution from t 5 0

to 5:

(a) Analytically.

28 C H A P T E R 28

811

Case Studies: Ordinary Differential Equations

The purpose of this chapter is to solve some ordinary differential equations using the

numerical methods presented in Part Seven. The equations originate from practical en-

gineering applications. Many of these applications result in nonlinear differential equa-

tions that cannot be solved using analytic techniques. Therefore, numerical methods are

usually required. Thus, the techniques for the numerical solution of ordinary differential

equations are fundamental capabilities that characterize good engineering practice. The

problems in this chapter illustrate some of the trade-offs associated with various methods

developed in Part Seven.

Section 28.1 derives from a chemical engineering problem context. It demonstrates

how the transient behavior of chemical reactors can be simulated. It also illustrates how

optimization can be used to estimate parameters for ODEs.

Sections 28.2 and 28.3, which are taken from civil and electrical engineering, re-

spectively, deal with the solution of systems of equations. In both cases, high accuracy

is demanded, and as a consequence, a fourth-order RK scheme is used. In addition, the

electrical engineering application also deals with determining eigenvalues.

Section 28.4 employs a variety of different approaches to investigate the behavior

of a swinging pendulum. This problem also utilizes two simultaneous equations. An

important aspect of this example is that it illustrates how numerical methods allow

nonlinear effects to be incorporated easily into an engineering analysis.

28.1 USING ODES TO ANALYZE THE TRANSIENT RESPONSE OF A REACTOR (CHEMICAL/BIO ENGINEERING)

Background. In Sec. 12.1, we analyzed the steady state of a series of reactors. In ad- dition to steady-state computations, we might also be interested in the transient response

of a completely mixed reactor. To do this, we have to develop a mathematical expression

for the accumulation term in Eq. (12.1).

Accumulation represents the change in mass in the reactor per change in time. For

a constant-volume system, it can be simply formulated as

Accumulation 5 V dc

dt (28.1)

812 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

where V 5 volume and c 5 concentration. Thus, a mathematical formulation for accu-

mulation is volume times the derivative of c with respect to t.

In this application we will incorporate the accumulation term into the general mass-

balance framework we developed in Sec. 12.1. We will then use it to simulate the dynamics

of a single reactor and a system of reactors. In the latter case, we will show how the system’s

eigenvalues can be determined and provide insight into its dynamics. Finally, we will illustrate

how optimization can be used to estimate the parameters of mass-balance models.

Solution. Equations (28.1) and (12.1) can be used to represent the mass balance for a single reactor such as the one shown in Fig. 28.1:

V dc

dt 5 Qcin 2 Qc (28.2)

Accumulation 5 inputs 2 outputs

Equation (28.2) can be used to determine transient or time-variable solutions for the

reactor. For example, if c 5 c0 at t 5 0, calculus can be employed to analytically solve

Eq. (28.2) for

c 5 cin(1 2 e 2(QyV)t) 1 c0e

2(QyV)t

If cin 5 50 mg/m 3, Q 5 5 m3/min, V 5 100 m3, and c0 5 10 mg/m

3, the equation is

c 5 50(1 2 e20.05t) 1 10e20.05t

Figure 28.2 shows this exact, analytical solution.

Euler’s method provides an alternative approach for solving Eq. (28.2). Figure 28.2

includes two solutions with different step sizes. As the step size is decreased, the nu-

merical solution converges on the analytical solution. Thus, for this case, the numerical

method can be used to check the analytical result.

Besides checking the results of an analytical solution, numerical solutions have

added value in those situations where analytical solutions are impossible or so dif! cult

that they are impractical. For example, aside from a single reactor, numerical methods

have utility when simulating the dynamics of systems of reactors. For example, ODEs

Qc

Qcin

FIGURE 28.1 A single, completely mixed reactor with an infl ow and an outfl ow.

28.1 USING ODES TO ANALYZE THE TRANSIENT RESPONSE OF A REACTOR 813

can be written for the ! ve coupled reactors in Fig. 12.3. The mass balance for the ! rst

reactor can be written as

V1 dc1

dt 5 Q01c01 1 Q31c3 2 Q12c1 2 Q15c1

or, substituting parameters (note that Q01c01 5 50 mg/min, Q03c03 5 160 mg/min, V1 5

50 m3, V2 5 20 m 3, V3 5 40 m

3, V4 5 80 m 3, and V5 5 100 m

3),

dc1

dt 5 20.12c1 1 0.02c3 1 1

Similarly, balances can be developed for the other reactors as

dc2

dt 5 0.15c1 2 0.15c2

dc3

dt 5 0.025c2 2 0.225c3 1 4

dc4

dt 5 0.1c3 2 0.1375c4 1 0.025c5

dc5

dt 5 0.03c1 1 0.01c2 2 0.04c5

Suppose that at t 5 0 all the concentrations in the reactors are at zero. Compute

how their concentrations will increase over the next hour.

The equations can be integrated with the fourth-order RK method for systems of

equations and the results are depicted in Fig. 28.3. Notice that each of the reactors shows

a different transient response to the introduction of chemical. These responses can be

parameterized by a 90 percent response time t90, which measures the time required for

each reactor to reach 90 percent of its ultimate steady-state level. The times range from

FIGURE 28.2 Plot of analytical and numerical solutions of Eq. (28.2). The numerical solutions are obtained with Euler’s method using different step sizes.

c, m

g /m

3

0 10 20

t, min

30 50

10

0

30

50

20

40

40

Euler, step size = 10 step size = 5

Exact

814 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

t90

c–1

0 t

c1

10

t90

c–3

0 t

c3

10

t90

c–4

0 t

c4

10

t90

c–2

0 t

c2

10

t90

c–5

0 500 t

c5

10

FIGURE 28.3 Plots of transient or dynamic response of the network of reactors from Fig. 12.3. Note that all the reactors eventually approach their steady-state concentrations previously computed in Sec. 12.1. In addition, the time to steady state is parameterized by the 90 percent response time t90.

28.1 USING ODES TO ANALYZE THE TRANSIENT RESPONSE OF A REACTOR 815

about 10 min for reactor 3 to about 70 min for reactor 5. The response times of reactors

4 and 5 are of particular concern because the two out” ow streams for the system exit

these tanks. Thus, a chemical engineer designing the system might change the ” ows or

volumes of the reactors to speed up the response of these tanks while still maintaining

the desired outputs. Numerical methods of the sort described in this part of the book can

prove useful in these design calculations.

Further insight into the system’s response characteristics can be developed by

computing its eigenvalues. First, the system of ODEs can be written as an eigenvalue

problem asE0.12 2 l 0 20.02 0 020.15 0.15 2 l 0 0 00 20.025 0.225 2 l 0 0 0 0 20.1 0.1375 2 l 20.025

20.03 20.01 0 0 0.04 2 l

U ee1e2e3 e4

e5

u 5 {0} where l and {e} 5 the eigenvalue and the eigenvector, respectively.

A package like MATLAB software can be used to very conveniently generate the

eigenvalues and eigenvectors,

The eigenvalues can be interpreted by recognizing that the general solution for a

system of ODEs can be represented as the sum of exponentials. For example, for reactor 1,

the general solution would be of the form

c1 5 c11e 2l1t 1 c12e

2l2t 1 c13e 2l3t 1 c14e

2l4t 1 c15e 2l5t

where cij 5 the part of the initial condition for reactor i that is associated with the jth

eigenvalue. Thus, because, for the present case, all the eigenvalues are positive (and

hence negative in the exponential function), the solution consists of a series of decaying

exponentials. The one with the smallest eigenvalue (in our case, 0.04) will be the slowest.

816 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

FIGURE 28.4 A simple experiment to collect rate data for a chemical compound that decays with time (reprinted from Chapra 1997).

c

t

t = 0 t = 2 t = 3t = 1

c0 c2 c3c1

Time

Concentration

0

c0

1

c1

2

c2

3

c3

In some cases, the engineer performing this analysis could be able to relate this eigen-

value back to the system parameters. For example, the ratio of the out” ow from reactor

5 to its volume is (Q55 1 Q54)yV5 5 4y100 5 0.04. Such information can then be used to modify the system’s dynamic performance.

The ! nal topic we would like to review within the present context is parameter

estimation. One area where this occurs frequently is in reaction kinetics, that is, the

quanti! cation of chemical reaction rates.

A simple example is depicted in Fig. 28.4. A series of beakers are set up containing a

chemical compound that decays over time. At time intervals, the concentration in one of the

beakers is measured and recorded. Thus, the result is a table of times and concentrations.

One model that is commonly used to describe such data is

dc

dt 5 2kcn (28.3)

where k 5 a reaction rate and n 5 the order of the reaction. Chemical engineers use

concentration-time data of the sort depicted in Fig. 28.4 to estimate k and n. One way

to do this is to guess values of the parameters and then solve Eq. (28.3) numerically.

The predicted values of concentration can be compared with the measured concentrations

and an assessment of the ! t made. If the ! t is deemed inadequate (for example, by ex-

amining a plot or a statistical measure like the sum of the squares of the residuals), the

guesses are adjusted and the procedure repeated until a decent ! t is attained.

The following data can be ! t in this fashion:

t, d 0 1 3 5 10 15 20

c, mg/L 12 10.7 9 7.1 4.6 2.5 1.8

28.1 USING ODES TO ANALYZE THE TRANSIENT RESPONSE OF A REACTOR 817

A B C D E F G H 1 Fitting of reaction rate 2 data with the integral/least-squares approach 3 k 0.091528 4 n 1.044425 5 dt 1 6 t k1 k2 k3 k4 cp cm (cp-cm)^2 7 0 21.22653 21.16114 21.16462 21.10248 12 12 0 8 1 21.10261 21.04409 21.04719 20.99157 10.83658 10.7 0.018653 9 2 20.99169 20.93929 20.94206 20.89225 9.790448 10 3 20.89235 20.84541 20.84788 20.80325 8.849344 9 0.022697 11 4 20.80334 20.76127 20.76347 20.72346 8.002317 12 5 20.72354 20.68582 20.68779 20.65191 7.239604 7.1 0.019489 13 6 20.65198 20.61814 20.61989 20.5877 6.552494 14 7 20.58776 20.55739 20.55895 20.53005 5.933207 15 8 20.53011 20.50283 20.50424 20.47828 5.374791 16 9 20.47833 20.45383 20.45508 20.43175 4.871037 17 10 20.4318 20.40978 20.4109 20.38993 4.416389 4.6 0.033713 18 11 20.38997 20.37016 20.37117 20.35231 4.005877 19 12 20.35234 20.33453 20.33543 20.31846 3.635053 20 13 20.31849 20.30246 20.30326 20.28798 3.299934 21 14 20.28801 20.27357 20.2743 20.26054 2.996949 22 15 20.26056 20.24756 20.24821 20.23581 2.7229 2.5 0.049684 23 16 20.23583 20.22411 20.22469 20.21352 2.474917 24 17 20.21354 20.20297 20.20349 20.19341 2.250426 25 18 20.19343 20.18389 20.18436 20.17527 2.047117 26 19 20.17529 20.16668 20.16711 20.1589 1.862914 27 20 20.15891 20.15115 20.15153 20.14412 1.695953 1.8 0.010826 28 29 SSR 5 0.155062

FIGURE 28.5 The application of a spreadsheet and numerical methods to determine the order and rate coeffi cient of reaction data. This application was performed with the Excel spreadsheet.

The solution to this problem is shown in Fig. 28.5. The Excel spreadsheet was used to

perform the computation.

Initial guesses for the reaction rate and order are entered into cells B3 and B4, re-

spectively, and the time step for the numerical calculation is typed into cell B5. For this

case, a column of calculation times is entered into column A starting at 0 (cell A7) and

ending at 20 (cell A27). The k1 through k4 coef! cients of the fourth-order RK method

are then calculated in the block B7..E27. These are then used to determine the predicted

concentrations (the cp values) in column F. The measured values (cm) are entered in

column G adjacent to the corresponding predicted values. These are then used in con-

junction with the predicted values to compute the squared residual in column H. These

values are then summed in cell H29.

At this point, the Excel Solver can be used to determine the best parameter values.

Once you have accessed the Solver, you are prompted for a target or solution cell (H29),

queried whether you want to maximize or minimize the target cell (minimize), and

818 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

prompted for the cells that are to be varied (B3..B4). You then activate the algorithm

[s(olve)], and the results are as in Fig. 28.5. As shown, the values in cells B3..B4 (k 5 0.0915

and n 5 1.044) minimize the sum of the squares of the residuals (SSR 5 0.155) between

the predicted and measured data. A plot of the ! t along with the data is shown in Fig. 28.6.

28.2 PREDATOR-PREY MODELS AND CHAOS (CIVIL/ENVIRONMENTAL ENGINEERING)

Background. Environmental engineers deal with a variety of problems involving sys- tems of nonlinear ordinary differential equations. In this section, we will focus on two

of these applications. The ! rst relates to the so-called predator-prey models that are used

to study the cycling of nutrient and toxic pollutants in aquatic food chains and biological

treatment systems. The second are equations derived from ” uid dynamics that are used

to simulate the atmosphere. Aside from their obvious application to weather prediction,

such equations have also been used to study air pollution and global climate change.

Predator-prey models were developed independently in the early part of the twentieth

century by the Italian mathematician Vito Volterra and the American biologist Alfred

J. Lotka. These equations are commonly called Lotka-Volterra equations. The simplest

example is the following pair of ODEs:

dx

dt 5 ax 2 bxy (28.4)

dy

dt 5 2cy 1 dxy (28.5)

where x and y 5 the number of prey and predators, respectively, a 5 the prey growth

rate, c 5 the predator death rate, and b and d 5 the rate characterizing the effect of the

predator-prey interaction on prey death and predator growth, respectively. The multiplica-

tive terms (that is, those involving xy) are what make such equations nonlinear.

FIGURE 28.6 Plot of fi t generated with the integral/least-squares approach.

10

c

5

0 t20100

28.2 PREDATOR-PREY MODELS AND CHAOS 819

An example of a simple model based on atmospheric ” uid dynamics is the Lorenz

equations developed by the American meteorologist Edward Lorenz,

dx

dt 5 2sx 1 sy (28.6)

dy

dt 5 rx 2 y 2 xz (28.7)

dz

dt 5 2bz 1 xy (28.8)

Lorenz developed these equations to relate the intensity of atmospheric ” uid motion, x,

to temperature variations y and z in the horizontal and vertical directions, respectively.

As with the predator-prey model, we see that the nonlinearity is localized in simple

multiplicative terms (xz and xy).

Use numerical methods to obtain solutions for these equations. Plot the results to

visualize how the dependent variables change temporally. In addition, plot the dependent

variables versus each other to see whether any interesting patterns emerge.

Solution. Use the following parameter values for the predator-prey simulation: a 5 1.2, b 5 0.6, c 5 0.8, and d 5 0.3. Employ initial conditions of x 5 2 and y 5 1 and inte-

grate from t 5 0 to 30. We will use the fourth-order RK method with double precision

to obtain solutions.

The results using a step size of 0.1 are shown in Fig. 28.7. Note that a cyclical pat-

tern emerges. Thus, because predator population is initially small, the prey grows expo-

nentially. At a certain point, the prey become so numerous, that the predator population

begins to grow. Eventually, the increased predators cause the prey to decline. This de-

crease, in turn, leads to a decrease of the predators. Eventually, the process repeats.

Notice that, as expected, the predator peak lags the prey. Also, observe that the process

has a ! xed period, that is, it repeats in a set time.

Now, if the parameters used to simulate Fig. 28.7 were changed, although the gen-

eral pattern would remain the same, the magnitudes of the peaks, lags, and period would

change. Thus, there are an in! nite number of cycles that could occur.

A phase-plane representation is useful in discerning the underlying structure of the

model. Rather than plotting x and y versus t, we can plot x versus y. This plot illustrates

FIGURE 28.7 Time-domain representation of numbers of prey and predators for the Lotka-Volterra model.

8

4

0 t30200 10

x, prey

y, predator

820 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

the way that the state variables (x and y) interact, and is referred to as a phase-plane

representation.

Figure 28.8 shows the phase-plane representation for the case we are studying. Thus,

the interaction between the predator and the prey de! nes a closed counterclockwise orbit.

Notice that there is a critical or rest point at the center of the orbit. The exact location of

this point can be determined by setting Eqs. (28.4) and (28.5) to steady state (dyydt 5 dxydt 5 0) and solving for (x, y) 5 (0, 0) and (cyd, ayb). The former is the trivial result that if we start with neither predators nor prey, nothing will happen. The latter is the more

interesting outcome that if the initial conditions are set at x 5 cyd and y 5 ayb, the derivative will be zero and the populations will remain constant.

Now, let us use the same approach to investigate the trajectories of the Lorenz equa-

tions with the following parameter values: s 5 10, b 5 2.666667, and r 5 28. Employ

initial conditions of x 5 y 5 z 5 5 and integrate from t 5 0 to 20. Again, we will use

the fourth-order RK method with double precision to obtain solutions.

The results shown in Fig. 28.9 are quite different from the behavior of the Lotka-

Volterra equations. The variable x seems to be undergoing an almost random pattern of

oscillations, bouncing around from negative values to positive values. However, even

FIGURE 28.8 Phase-plane representation for the Lotka-Volterra model.

4

y

2

0 x62

Critical point

0 4

FIGURE 28.9 Time-domain representation of x versus t for the Lorenz equations. The solid time series is for the initial conditions (5, 5, 5). The dotted line is where the initial condition for x is perturbed slightly (5.001, 5, 5).

20

x

0

10

– 20

– 10

20 t155 10

28.2 PREDATOR-PREY MODELS AND CHAOS 821

though the patterns seem random, the frequency of the oscillation and the amplitudes

seem fairly consistent.

Another interesting feature can be illustrated by changing the initial condition for x

slightly (from 5 to 5.001). The results are superimposed as the dotted line in Fig. 28.9.

Although the solutions track on each other for a time, after about t 5 12.5 they diverge

signi! cantly. Thus, we can see that the Lorenz equations are quite sensitive to their

initial conditions. In his original study, this led Lorenz to the conclusion that long-range

weather forecasts might be impossible!

Finally, let us examine the phase-plane plots. Because we are dealing with three in-

dependent variables, we are limited to projections. Figure 28.10 shows projections in the

xy and the xz planes. Notice how a structure is manifest when perceived from the phase-

plane perspective. The solution forms orbits around what appear to be critical points.

FIGURE 28.10 Phase-plane representation for the Lorenz equations. (a) xy projection and (b) xz projection.

25

y

– 25

x20– 20

(a)

0

50

z

x20– 20

(b)

0

822 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

These points are called strange attractors in the jargon of mathematicians who study such

nonlinear systems.

Solutions such as the type we have explored for the Lorenz equations are referred

to as chaotic solutions. The study of chaos and nonlinear systems presently represents

an exciting area of analysis that has implications to mathematics as well as to science

and engineering.

From a numerical perspective, the primary point is the sensitivity of such solutions

to initial conditions. Thus, different numerical algorithms, computer precision, and inte-

gration time steps can all have an impact on the resulting numerical solution.

28.3 SIMULATING TRANSIENT CURRENT FOR AN ELECTRIC CIRCUIT (ELECTRICAL ENGINEERING)

Background. Electric circuits where the current is time-variable rather than constant are common. A transient current is established in the right-hand loop of the circuit shown

in Fig. 28.11 when the switch is suddenly closed.

Equations that describe the transient behavior of the circuit in Fig. 28.11 are based

on Kirchhoff’s law, which states that the algebraic sum of the voltage drops around a

closed loop is zero (recall Sec. 8.3). Thus,

L di

dt 1 Ri 1

q

C 2 E(t) 5 0 (28.9)

where L(diydt) 5 voltage drop across the inductor, L 5 inductance (H), R 5 resistance (V), q 5 charge on the capacitor (C), C 5 capacitance (F), E(t) 5 time-variable voltage

source (V), and

i 5 dq

dt (28.10)

Equations (28.9) and (28.10) are a pair of ! rst-order linear differential equations that can

be solved analytically. For example, if E(t) 5 E0 sin vt and R 5 0,

q(t) 5 2E0

L( p2 2 v2) v

p sin pt 1

E0

L(p2 2 v2) sin vt (28.11)

FIGURE 28.11 An electric circuit where the current varies with time.

Switch

Resistor

Capacitor –

+ V0

E(t)

+ Battery Inductor

28.3 SIMULATING TRANSIENT CURRENT FOR AN ELECTRIC CIRCUIT 823

where p 5 1y1LC. The values of q and dqydt are zero for t 5 0. Use a numerical ap- proach to solve Eqs. (28.9) and (28.10) and compare the results with Eq. (28.11).

Solution. This problem involves a rather long integration range and demands the use of a highly accurate scheme to solve the differential equation if good results are expected.

Let us assume that L 5 1 H, E0 5 1V, C 5 0.25 C, and v 2 5 3.5 s2. This gives p 5 2,

and Eq. (28.11) becomes

q(t) 5 21.8708 sin (2t) 1 2 sin (1.8708t)

for the analytical solution. This function is plotted in Fig. 28.12. The rapidly chang-

ing nature of the function places a severe requirement on any numerical procedure

to ! nd q(t). Furthermore, because the function exhibits a slowly varying periodic

nature as well as a rapidly varying component, long integration ranges are necessary

to portray the solution. Thus, we expect that a high-order method is preferred for

this problem.

However, we can try both Euler and fourth-order RK methods and compare the

results. Using a step size of 0.1 s gives a value for q at t 5 10 s of 26.638 with Euler’s

method and a value of 21.9897 with the fourth-order RK method. These results compare

to an exact solution of 21.996 C.

Figure 28.13 shows the results of Euler integration every 1.0 s compared to the exact

solution. Note that only every tenth output point is plotted. It is seen that the global error

increases as t increases. This divergent behavior intensi! es as t approaches in! nity.

In addition to directly simulating a network’s transient response, numerical methods

can also be used to determine its eigenvalues. For example, Fig. 28.14 shows an LC

network for which Kirchhoff’s voltage law can be employed to develop the following

FIGURE 28.12 Computer screen showing the plot of the function represented by Eq. (28.11).

– 6.0

6.0

0

4.0

– 4.0

– 2.0

2.0

0 40

Time

C u

rr e n

t

Capacitor

20 8060 100

824 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

system of ODEs:

2L1 di1

dt 2

1

C1 #

t

2q

(i1 2 i2) dt 5 0

2L2 di2

dt 2

1

C2 #

t

2q

(i2 2 i3) dt 1

1

C1 #

t

2q

(i1 2 i2) dt 5 0

2L3 di3

dt 2

1

C3 #

t

2q

i3 dt 1

1

C2 #

t

2q

(i2 2 i3) dt 5 0

Notice that we have represented the voltage drop across the capacitor as

VC 5 1

C # t

2q

i dt

This is an alternative and equivalent expression to the relationship used in Eq. (28.9) and

introduced in Sec. 8.3.

FIGURE 28.13 Results of Euler integration versus exact solution. Note that only every tenth output point is plotted.

0

2

4

Charge

– 6

– 4

– 2

t, s10

Euler’s method

FIGURE 28.14 An LC network.

L1 L2 L3

C1

i1

+

C2 C3

i2 i3

28.3 SIMULATING TRANSIENT CURRENT FOR AN ELECTRIC CIRCUIT 825

The system of ODEs can be differentiated and rearranged to yield

L1 d 2i1

dt 2 1

1

C1 (i1 2 i2) 5 0

L2 d 2i2

dt 2 1

1

C 2 (i2 2 i3) 2

1

C1 (i1 2 i2) 5 0

L3 d 2i3

dt2 1

1

C3 i3 2

1

C2 (i2 2 i3) 5 0

Comparison of this system with the one in Eq. (27.5) indicates an analogy between

a spring-mass system and an LC circuit. As was done with Eq. (27.5), the solution can

be assumed to be of the form

ij 5 Aj sin(vt)

This solution along with its second derivative can be substituted into the simultaneous

ODEs. After simpli! cation, the result is

a 1 C1

2 L1v 2b A1 2 1

C2 A2 5 0

2 1

C1 A1 1 a 1

C1 1

1

C2 2 L2v

2b A2 2 1 C2

A3 5 0

2 1

C2 A2 1 a 1

C2 1

1

C3 2 L3v

2b A3 5 0 Thus, we have formulated an eigenvalue problem. Further simpli! cation results for the

special case where the C’s and L’s are constant. For this situation, the system can be

expressed in matrix form as

£ 1 2 l 21 021 2 2 l 21 0 21 2 2 l

§ •A1A2 A3

¶ 5 {0} (28.12) where

l 5 LCv2 (28.13)

Numerical methods can be employed to determine values for the eigenvalues and

eigenvectors. MATLAB is particularly convenient in this regard. The following MATLAB

session has been developed to do this:

2

826 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

The matrix consists of the system’s three eigenvectors (arranged as columns), and

is a matrix with the corresponding eigenvalues on the diagonal. Thus, the package com-

putes that the eigenvalues are l 5 0.1981, 1.555, and 3.247. These values in turn can be

substituted into Eq. (28.13) to solve for the natural circular frequencies of the system

v 5 f 0.44501LC1.24701LC 1.8019

1LC Aside from providing the natural frequencies, the eigenvalues can be substituted into

Eq. (28.12) to gain further insight into the circuit’s physical behavior. For example,

substituting l 5 0.1981 yields

£ 0.8019 21 021 1.8019 21 0 21 1.8019

§ • i1i2 i3

¶ 5 {0} Although this system does not have a unique solution, it will be satis! ed if the currents

are in ! xed ratios, as in

0.8019i1 5 i2 5 1.8019i3 (28.14)

Thus, as depicted in Fig. 28.15a, they oscillate in the same direction with different mag-

nitudes. Observe that if we assume that i1 5 0.737, we can use Eq. (28.14) to compute

the other currents with the result

{i} 5 •0.7370.591 0.328

¶ which is the ! rst column of the matrix calculated with MATLAB.

28.4 THE SWINGING PENDULUM 827

In a similar fashion, the second eigenvalue of l 5 1.555 can be substituted and the

result evaluated to yield

21.8018i1 5 i2 5 2.247i3

As depicted in Fig. 28.15b, the ! rst loop oscillates in the opposite direction from the

second and third. Finally, the third mode can be determined as

20.445i1 5 i2 5 20.8718i3

Consequently, as in Fig. 28.15c, the ! rst and third loops oscillate in the opposite direction

from the second.

28.4 THE SWINGING PENDULUM (MECHANICAL/AEROSPACE ENGINEERING)

Background. Mechanical engineers (as well as all other engineers) are frequently faced with problems concerning the periodic motion of free bodies. The engineering approach to

such problems ultimately requires that the position and velocity of the body be known as a

function of time. These functions of time invariably are the solution of ordinary differential

equations. The differential equations are usually based on Newton’s laws of motion.

As an example, consider the simple pendulum shown previously in Fig. PT7.1. The

particle of weight W is suspended on a weightless rod of length l. The only forces acting

on the particle are its weight and the tension R in the rod. The position of the particle

at any time is completely speci! ed in terms of the angle u and l.

The free-body diagram in Fig. 28.16 shows the forces on the particle and the

acceleration. It is convenient to apply Newton’s laws of motion in the x direction tangent

to the path of the particle:

gF 5 2W sin u 5 W

g a

where g 5 the gravitational constant (32.2 ft/s2) and a 5 the acceleration in the x direction.

The angular acceleration of the particle (a) becomes

a 5 a

l

(a) v = 0.4451

LC (b) v =

1.2470

LC (c) v =

1.8019

LC

FIGURE 28.15 A visual representation of the natural modes of oscillation of the LC network of Fig. 28.14. Note that the diameters of the circular arrows are proportional to the magnitudes of the currents for each loop.

FIGURE 28.16 A free-body diagram of the swinging pendulum showing the forces on the particle and the acceleration.

u

W y

a

x

R

828 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

Therefore, in polar coordinates (a 5 d2uydt2),

2W sin u 5 Wl

g a 5

Wl

g d 2u

dt 2

or

d 2u

dt2 1

g

l sin u 5 0 (28.15)

This apparently simple equation is a second-order nonlinear differential equation. In

general, such equations are dif! cult or impossible to solve analytically. You have two

choices regarding further progress. First, the differential equation might be reduced to a

form that can be solved analytically (recall Sec. PT7.1.1), or second, a numerical

approximation technique can be used to solve the differential equation directly. We will

examine both of these alternatives in this example.

Solution. Proceeding with the ! rst approach, we note that the series expansion for sin u is given by

sin u 5 u 2 u3

3! 1 u5

5! 2 u7

7! 1 p (28.16)

For small angular displacements, sin u is approximately equal to u when expressed in

radians. Therefore, for small displacements, Eq. (28.15) becomes

d 2u

dt2 1

g

l u 5 0 (28.17)

which is a second-order linear differential equation. This approximation is very important

because Eq. (28.17) is easy to solve analytically. The solution, based on the theory of

differential equations, is given by

u(t) 5 u0 cos B g

l t (28.18)

where u0 5 the displacement at t 5 0 and where it is assumed that the velocity (y 5 duydt) is zero at t 5 0. The time required for the pendulum to complete one cycle of oscillation

is called the period and is given by

T 5 2p B l

g (28.19)

Figure 28.17 shows a plot of the displacement u and velocity duydt as a function of time, as calculated from Eq. (28.18) with u0 5 py4 and l 5 2 ft. The period, as calculated from Eq. (28.19), is 1.5659 s.

The above calculations essentially are a complete solution of the motion of the

pendulum. However, you must also consider the accuracy of the results because of the

28.4 THE SWINGING PENDULUM 829

assumptions inherent in Eq. (28.17). To evaluate the accuracy, it is necessary to obtain

a numerical solution for Eq. (28.15), which is a more complete physical representation

of the motion. Any of the methods discussed in Chaps. 25 and 26 could be used for this

purpose—for example, the Euler and fourth-order RK methods. Equation (28.15) must

be transformed into two ! rst-order equations to be compatible with the above methods.

This is accomplished as follows. The velocity y is de! ned by

du

dt 5 y (28.20)

and, therefore, Eq. (28.15) can be expressed as

dy

dt 5 2

g

l sin u (28.21)

Equations (28.20) and (28.21) are a coupled system of two ordinary differential equa-

tions. The numerical solutions by the Euler method and the fourth-order RK method give

the results shown in Table 28.1, which compares the analytic solution for the linear

equation of motion [Eq. (28.18)] in column (a) with the numerical solutions in columns

(b), (c), and (d).

The Euler and fourth-order RK methods yield different results and both disagree

with the analytic solution, although the fourth-order RK method for the nonlinear

case is closer to the analytic solution than is the Euler method. To properly evaluate

the difference between the linear and nonlinear models, it is important to determine

the accuracy of the numerical results. This is accomplished in three ways. First, the

Euler numerical solution is easily recognized as inadequate because it overshoots

the initial condition at t 5 0.8 s. This clearly violates conservation of energy. Second,

column (c) and (d) in Table 28.1 show the solution of the fourth-order RK method

u

– 0.8

0.8

0 t

– 2

2

0 t

du

dt

FIGURE 28.17 Plot of displacement u and velocity du/dt as a function of time t, as calculated from Eq. (28.18). u0 is p/4 and the length is 2 ft.

830 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

TABLE 28.1 Comparison of a linear analytical solution of the swinging pendulum problem with three nonlinear numerical solutions.

Nonlinear Numerical Solutions

Linear Analytical Euler 4th-Order RK 4th-Order RK Time, Solution (h 5 0.05) (h 5 0.05) (h 5 0.01) s (a) (b) (c) (d)

0.0 0.785398 0.785398 0.785398 0.785398 0.2 0.545784 0.615453 0.566582 0.566579 0.4 20.026852 0.050228 0.021895 0.021882 0.6 20.583104 20.639652 20.535802 20.535820 0.8 20.783562 21.050679 20.784236 20.784242 1.0 20.505912 20.940622 20.595598 20.595583 1.2 0.080431 20.299819 20.065611 20.065575 1.4 0.617698 0.621700 0.503352 0.503392 1.6 0.778062 1.316795 0.780762 0.780777

for step sizes of 0.05 and 0.01. Because these vary in the fourth decimal place, it is

reasonable to assume that the solution with a step size of 0.01 is also accurate with

this degree of certainty. Third, for the 0.01-s step-size case, u obtains a local maxi-

mum value of 0.785385 at t 5 1.63 s (not shown in Table 28.1). This indicates that

the pendulum returns to its original position with four-place accuracy with a period

of 1.63 s. These considerations allow you to safely assume that the difference be-

tween columns (a) and (d) in Table 28.1 truly represents the difference between the

linear and nonlinear model.

Another way to characterize the difference between the linear and the nonlinear model

is on the basis of period. Table 28.2 shows the period of oscillation as calculated by the

linear model and nonlinear model for three different initial displacements. It is seen that

the calculated periods agree closely when u is small because u is a good approximation

for sin u in Eq. (28.16). This approximation deteriorates when u becomes large.

These analyses are typical of cases you will routinely encounter as an engineer. The

utility of the numerical techniques becomes particularly signi! cant in nonlinear prob-

lems, and in many cases real-world problems are nonlinear.

TABLE 28.2 Comparison of the period of an oscillating body calculated from linear and nonlinear models.

Period, s

Initial Linear Model Nonlinear Model Displacement, U0 (T 5 2P1Iyg) [Numerical Solution of Eq. (28.15)] p/16 1.5659 1.57 p/4 1.5659 1.63 p/2 1.5659 1.85

PROBLEMS 831

PROBLEMS

Chemical/Bio Engineering

28.1 Perform the ! rst computation in Sec. 28.1, but for the case

where h 5 10. Use the Heun (without iteration) and the fourth-

order RK method to obtain solutions.

28.2 Perform the second computation in Sec. 28.1, but for the

system described in Prob. 12.4.

28.3 A mass balance for a chemical in a completely mixed reactor

can be written as

V dc

dt 5 F 2 Qc 2 kVc2

where V 5 volume (12 m3), c 5 concentration (g/m3), F 5 feed

rate (175 g/min), Q 5 $ ow rate (1 m3/min), and k 5 a second-order

reaction rate (0.15 m3/g/min). If c(0) 5 0, solve the ODE until the

concentration reaches a stable level. Use the midpoint method

(h 5 0.5) and plot your results.

Challenge question: If one ignores the fact that concentrations

must be positive, ! nd a range of initial conditions such that you

obtain a very different trajectory than was obtained with c(0) 5 0.

Relate your results to the steady-state solutions.

28.4 If cin 5 cb(1 2 e 20.12t), calculate the out$ ow concentration of a

conservative substance (no reaction) for a single, completely mixed

reactor as a function of time. Use Heun’s method (without itera-

tion) to perform the computation. Employ values of cb 5 40 mg/m 3,

Q 5 6 m3/min, V 5 100 m3, and c0 5 20 mg/m 3. Perform the com-

putation from t 5 0 to 100 min using h 5 2. Plot your results along

with the in$ ow concentration versus time.

28.5 Seawater with a concentration of 8000 g/m3 is pumped into a

well-mixed tank at a rate of 0.6 m3/hr. Because of faulty design

work, water is evaporating from the tank at a rate of 0.025 m3/hr.

The salt solution leaves the tank at a rate of 0.6 m3/hr.

(a) If the tank originally contains 1 m3 of the inlet solution, how

long after the outlet pump is turned on will the tank run dry?

(b) Use numerical methods to determine the salt concentration in

the tank as a function of time.

28.6 A spherical ice cube (an “ice sphere”) that is 6 cm in diam-

eter is removed from a 08C freezer and placed on a mesh screen

at room temperature Ta 5 208C. What will be the diameter of the

ice cube as a function of time out of the freezer (assuming that

all the water that has melted immediately drips through the

screen)? The heat transfer coef! cient h for a sphere in a still

room is about 3 W/(m2 ? K). The heat $ ux from the ice sphere to

the air is given by

Flux 5 q

A 5 h(Ta 2 T)

where q 5 heat and A 5 surface area of the sphere. Use a

numerical method to make your calculation. Note that the latent

heat of fusion is 333 kJ/kg and the density of ice is approximately

0.917 kg/m3.

28.7 The following equations de! ne the concentrations of three

reactants:

dca

dt 5 210cacc 1 cb

dcb

dt 5 10cacc 2 cb

dcc

dt 5 210cacc 1 cb 2 2cc

If the initial conditions are ca 5 50, cb 5 0, and cc 5 40, ! nd the

concentrations for the times from 0 to 3 s.

28.8 Compound A diffuses through a 4-cm-long tube and reacts as

it diffuses. The equation governing diffusion with reaction is

D d 2A

dx2 2 kA 5 0

At one end of the tube, there is a large source of A at a concentra-

tion of 0.1 M. At the other end of the tube there is an adsorbent

material that quickly absorbs any A, making the concentration 0 M.

If D 5 1.5 3 1026 cm2/s and k 5 5 3 1026 s21, what is the concen-

tration of A as a function of distance in the tube?

28.9 In the investigation of a homicide or accidental death, it is

often important to estimate the time of death. From the experimen-

tal observations, it is known that the surface temperature of an

object changes at a rate proportional to the difference between the

temperature of the object and that of the surrounding environment

or ambient temperature. This is known as Newton’s law of cooling.

Thus, if T(t) is the temperature of the object at time t, and Ta is the

constant ambient temperature:

dT

dt 5 2K(T 2 Ta)

where K . 0 is a constant of proportionality. Suppose that at time

t 5 0 a corpse is discovered and its temperature is measured to be

To. We assume that at the time of death, the body temperature, Td,

was at the normal value of 378C. Suppose that the temperature of

the corpse when it was discovered was 29.58C, and that two hours

later, it is 23.58C. The ambient temperature is 208C.

(a) Determine K and the time of death.

(b) Solve the ODE numerically and plot the results.

28.10 The reaction AS B takes place in two reactors in series.

The reactors are well mixed but are not at steady state. The

832 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

L (cm), a chemical compound A diffuses into the bio! lm where it is

subject to an irreversible ! rst-order reaction that converts it to a

product B.

Steady-state mass balances can be used to derive the following

ordinary differential equations for compound A:

D d 2ca

dx2 5 0 0 # x , L

Df d 2ca

dx2 2 kca 5 0 L # x , L 1 Lf

where D 5 the diffusion coef! cient in the diffusion layer 5 0.8

cm2/d, Df 5 the diffusion coef! cient in the bio! lm 5 0.64 cm 2/d,

and k 5 the ! rst-order rate for the conversion of A to B 5 0.1/d. The

following boundary conditions hold:

ca 5 ca0 at x 5 0

dca

dx 5 0 at x 5 L 1 Lf

where ca 0 5 the concentration of A in the bulk liquid 5 100 mol/L.

Use the ! nite-difference method to compute the steady-state distri-

bution of A from x 5 0 to L 1 Lf, where L 5 0.008 cm and Lf 5

0.004 cm. Employ centered ! nite differences with Dx 5 0.001 cm.

28.14 The following differential equation describes the steady-

state concentration of a substance that reacts with ! rst-order kinet-

ics in an axially-dispersed plug-$ ow reactor (Fig. P28.14),

D d 2c

dx2 2 U

dc

dx 2 kc 5 0

unsteady-state mass balance for each stirred tank reactor is shown

below:

dCA1

dt 5

1

t (CA0 2 CA1) 2 kCA1

dCB1

dt 5 2

1

t CB1 1 kCA1

dCA2

dt 5

1

t (CA1 2 CA2) 2 kCA2

dCB2

dt 5

1

t (CB1 2 CB2) 1 kCA2

where CA0 5 concentration of A at the inlet of the ! rst reactor, CA1 5

concentration of A at the outlet of the ! rst reactor (and inlet of the

second), CA2 5 concentration of A at the outlet of the second reac-

tor, CB1 5 concentration of B at the outlet of the ! rst reactor (and

inlet of the second), CB2 5 concentration of B in the second reactor,

t 5 residence time for each reactor, and k 5 the rate constant for

reaction of A to produce B. If CA0 is equal to 20, ! nd the concentra-

tions of A and B in both reactors during their ! rst 10 minutes of

operation. Use k 5 0.12/min and t 5 5 min and assume that the

initial conditions of all the dependent variables are zero.

28.11 A nonisothermal batch reactor can be described by the

following equations:

dC

dt 5 2e(210y(T1273))C

dT

dt 5 1000e(210y(T1273))C 2 10(T 2 20)

where C is the concentration of the reactant and T is the tempera-

ture of the reactor. Initially the reactor is at 158C and has a concen-

tration of reactant C of 1.0 gmol/L. Find the concentration and

temperature of the reactor as a function of time.

28.12 The following system is a classic example of stiff ODEs that

can occur in the solution of chemical reaction kinetics:

dc1

dt 5 20.013c1 2 1000c1c3

dc2

dt 5 22500c2c3

dc3

dt 5 20.013c1 2 1000c1c3 2 2500c2c3

Solve these equations from t 5 0 to 50 with initial conditions c1(0) 5

c2(0) 5 1 and c3(0) 5 0. If you have access to MATLAB software,

use both standard (for example, ) and stiff (for example,

) functions to obtain your solutions.

28.13 A bio! lm with a thickness Lf (cm) grows on the surface of a

solid (Fig. P28.13). After traversing a diffusion layer of thickness

Bulk

liquid

0

Diffusion

layer Biofilm

x

Solid

surface

L Lf

FIGURE P28.13 A biofi lm growing on a solid surface.

PROBLEMS 833

Use the ! nite-difference approach to solve for the concentration of

each reactant as a function of distance given: D 5 0.1 m2/min, U 5

1 m/min, k1 5 3/min, k2 5 1/min, L 5 0.5 m, ca,in 5 10 mol/L.

Employ centered ! nite-difference approximations with Dx 5 0.05 m

to obtain your solutions and assume Danckwerts boundary condi-

tions, as described in Prob. 28.14. Also, compute the sum of the

reactants as a function of distance. Do your results make sense?

28.16 Bacteria growing in a batch reactor utilize a soluble food

source (substrate) as depicted in Fig. P28.16. The uptake of the

substrate is represented by a logistic model with Michaelis-Menten

limitation. Death of the bacteria produces detritus which is subse-

quently converted to the substrate by hydrolysis. In addition, the

bacteria also excrete some substrate directly. Death, hydrolysis, and

excretion are all simulated as ! rst-order reactions.

Mass balances can be written as

dX

dt 5 mmax a1 2 X

K b a S

Ks 1 S b X 2 kd X 2 ke X

dC

dt 5 kd X 2 khC

dS

dt 5 ke X 1 khC 2 mmax a1 2 X

K b a S

Ks 1 S b X

where X, C, and S 5 the concentrations (mg/L) of bacteria, detritus,

and substrate, respectively; mmax 5 maximum growth rate (/d), K 5

the logistic carrying capacity (mg/L); Ks 5 the Michaelis-Menten

half-saturation constant (mg/L), kd 5 death rate (/d); ke 5 excretion

rate (/d); and kh 5 hydrolysis rate (/d). Simulate the concentrations

from t 5 0 to 100 d, given the initial conditions X(0) 5 1 mg/L,

S(0) 5 100 mg/L, and C(0) 5 0 mg/L. Employ the following param-

eters in your calculation: mmax 5 10/d, K 5 10 mg/L, Ks 5 10 mg/L,

kd 5 0.1/d, ke 5 0.1/d, and kh 5 0.1/d.

Civil/Environmental Engineering

28.17 Perform the same computation for the Lotka-Volterra sys-

tem in Sec. 28.2, but use (a) Euler’s method, (b) Heun’s method

(without iterating the corrector), (c) the fourth-order RK method,

and (d) the MATLAB function. In all cases use single-

precision variables, a step size of 0.1, and simulate from t 5 0 to 20.

Develop phase-plane plots for all cases.

where D 5 the dispersion coef! cient (m2/hr), c 5 concentration

(mol/L), x 5 distance (m), U 5 the velocity (m/hr), and k 5 the

reaction rate (/hr). The boundary conditions can be formulated as

Ucin 5 Uc(x 5 0) 2 D dc

dx (x 5 0)

dc

dx (x 5 L) 5 0

where cin 5 the concentration in the in$ ow (mol/L), and L 5 the

length of the reactor (m). These are called Danckwerts boundary

conditions. Use the ! nite-difference approach to solve for concen-

tration as a function of distance given the following parameters:

D 5 5000 m2/hr, U 5 100 m/hr, k 5 2/hr, L 5 100 m, and cin 5 100

mol/L. Employ centered ! nite-difference approximations with

Dx 5 10 m to obtain your solutions. Compare your numerical

results with the analytical solution,

c 5 Ucin

(U 2 Dl1)l2e l2L 2 (U 2 Dl2)l1e

l1L

3 (l2e l2Lel1x 2 l1e

l1Lel2x)

where

l1

l2 5

U

2D a1 ; A1 1 4k DU2 b

28.15 A series of ! rst-order, liquid-phase reactions create a desir-

able product (B) and an undesirable byproduct (C)

AS k1

BS k2

C

If the reactions take place in an axially-dispersed plug-$ ow reactor

(Fig. P28.14), steady-state mass balances can be used to develop

the following second-order ODEs,

D d 2ca

dx2 2 U

dca

dx 2 k1ca 5 0

D d 2cb

dx2 2 U

dcb

dx 1 k1ca 2 k2cb 5 0

D d 2cc

dx2 2 U

dcc

dx 1 k2cb 5 0

FIGURE P28.14 An axially-dispersed plug-fl ow reactor.

x 5 0 x 5 L x

hydrolysis

excretion

deathuptakeSubstrate

S

Bacteria

X

Detritus

C

FIGURE P28.16

834 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

Using mass balances, the system can be modeled as the following

simultaneous ODEs:

V1 dc1

dt 5 2Qc1 1 E12(c2 2 c1) 1 E13(c3 2 c1)

V2 dc2

dt 5 E12(c1 2 c2)

V3 dc3

dt 5 E13(c1 2 c3)

where Vi 5 volume of segment i, Q 5 $ ow, and Eij 5 diffusive

mixing rate between segments i and j. Use the data and the differ-

ential equations to estimate the E’s if V1 5 1 3 10 7, V2 5 8 3 10

6,

V3 5 5 3 10 6, and Q 5 4 3 106. Employ Euler’s method with a step

size of 0.1 for your analysis.

28.22 Population-growth dynamics are important in a variety of

planning studies for areas such as transportation and water-resource

engineering. One of the simplest models of such growth incorpo-

rates the assumption that the rate of change of the population p is

proportional to the existing population at any time t:

dp

dt 5 Gp (P28.22.1)

where G 5 a growth rate (per year). This model makes intuitive sense

because the greater the population, the greater the number of poten-

tial parents. At time t 5 0, an island has a population of 6000 people.

If G 5 0.075 per year, employ Heun’s method (without iteration) to

predict the population at t 5 20 years, using a step size of 0.5 year.

Plot p versus t on standard and semilog graph paper. Determine the

slope of the line on the semilog plot. Discuss your results.

28.23 Although the model in Prob. 28.22 works adequately when

population growth is unlimited, it breaks down when factors such as

food shortages, pollution, and lack of space inhibit growth. In such

cases, the growth rate itself can be thought of as being inversely

proportional to population. One model of this relationship is

G 5 G¿(pmax 2 p) (P28.23.1)

where G9 5 a population-dependent growth rate (per people-year)

and pmax 5 the maximum sustainable population. Thus, when popula-

tion is small (p V pmax), the growth rate will be at a high constant

rate of G9 pmax. For such cases, growth is unlimited and Eq. (P28.23.1)

is essentially identical to Eq. (P28.22.1). However, as population

grows (that is, p approaches pmax), G decreases until at p 5 pmax it is

zero. Thus, the model predicts that, when the population reaches the

maximum sustainable level, growth is nonexistent, and the system is

at a steady state. Substituting Eq. (P28.23.1) into Eq. (P28.22.1) yields

dp

dt 5 G¿(pmax 2 p)p

28.18 Perform the same computation for the Lorenz equations in

Sec. 28.2, but use (a) Euler’s method, (b) Heun’s method (without

iterating the corrector), (c) the fourth-order RK method, and (d) the

MATLAB function. In all cases use single-precision vari-

ables and a step size of 0.1 and simulate from t 5 0 to 20. Develop

phase-plane plots for all cases.

28.19 The following equation can be used to model the de$ ection

of a sailboat mast subject to a wind force:

d 2y

dz2 5

f

2EI (L 2 z)2

where f 5 wind force, E 5 modulus of elasticity, L 5 mast length,

and I 5 moment of inertia. Calculate the de$ ection if y 5 0 and

dyydz 5 0 at z 5 0. Use parameter values of f 5 60, L 5 30, E 5 1.25 3 108, and I 5 0.05 for your computation.

28.20 Perform the same computation as in Prob. 28.19, but rather

than using a constant wind force, employ a force that varies with

height according to (recall Sec. 24.2)

f (z) 5 200z

5 1 z e22zy30

28.21 An environmental engineer is interested in estimating the

mixing that occurs between a strati! ed lake and an adjacent em-

bayment (Fig. P28.21). A conservative tracer is instantaneously

mixed with the bay water, and then the tracer concentration is

monitored over the ensuing period in all three segments. The val-

ues are

t 0 2 4 6 8 12 16 20 c1 0 15 11 7 6 3 2 1 c2 0 3 5 7 7 6 4 2 c3 100 48 26 16 10 4 3 2

FIGURE P28.21

Bay (3)

Upper layer (1)

Lower layer (2)

PROBLEMS 835

tension in the cable is a minimum of To. The differential equation

that governs the cable is

d 2y

dx2 5 wo

To c 1 1 sin apx

2lA b d

Solve this equation using a numerical method and plot the shape of

the cable (y versus x). For the numerical solution, the value of To is

unknown, so the solution must use an iterative technique, similar to

the shooting method, to converge on a correct value of hA for vari-

ous values of To.

28.26 The basic differential equation of the elastic curve for a can-

tilever beam (Fig. P28.26) is given as

EI d 2y

dx2 5 2P(L 2 x)

where E 5 the modulus of elasticity and I 5 the moment of inertia.

Solve for the de! ection of the beam using a numerical method. The

following parameter values apply: E 5 30,000 ksi, I 5 800 in4,

For the same island studied in Prob. 28.22, employ Heun’s method

(without iteration) to predict the population at t 5 20 years, using a

step size of 0.5 year. Employ values of G9 5 1025 per people-year

and pmax 5 20,000 people. At time t 5 0, the island has a population

of 6000 people. Plot p versus t and interpret the shape of the curve.

28.24 Isle Royale National Park is a 210-square-mile archipelago

composed of a single large island and many small islands in Lake

Superior. Moose arrived around 1900 and by 1930, their population

approached 3000, ravaging vegetation. In 1949, wolves crossed an

ice bridge from Ontario. Since the late 1950s, the numbers of the

moose and wolves have been tracked. (Dash indicates no data.)

Year Moose Wolves Year Moose Wolves

1960 700 22 1972 836 23 1961 — 22 1973 802 24 1962 — 23 1974 815 30 1963 — 20 1975 778 41 1964 — 25 1976 641 43 1965 — 28 1977 507 33 1966 881 24 1978 543 40 1967 — 22 1979 675 42 1968 1000 22 1980 577 50 1969 1150 17 1981 570 30 1970 966 18 1982 590 13 1971 674 20 1983 811 23

(a) Integrate the Lotka-Volterra equations from 1960 through

2020. Determine the coef” cient values that yield an optimal ” t.

Compare your simulation with these data using a time-series

approach, and comment on the results.

(b) Plot the simulation of (a), but use a phase-plane approach.

(c) After 1993, suppose that the wildlife managers trap one wolf per

year and transport it off the island. Predict how the populations

of both the wolves and moose would evolve to the year 2020.

Present your results as both time-series and phase-plane plots.

For this case, as well as for (d), use the following coef” cients:

a 5 0.3, b 5 0.01111, c 5 0.2106, d 5 0.0002632.

(d) Suppose that in 1993, some poachers snuck onto the island and

killed 50% of the moose. Predict how the populations of both

the wolves and moose would evolve to the year 2020. Present

your results as both time-series and phase-plane plots.

28.25 A cable is hanging from two supports at A and B (Fig. P28.25).

The cable is loaded with a distributed load whose magnitude varies

with x as

w 5 wo c 1 1 sin apx 2lA b d

where wo 5 1000 lb/ft. The slope of the cable (dyydx) 5 0 at x 5 0, which is the lowest point for the cable. It is also the point where the

FIGURE P28.25

w = wo[1 + sin ( x/2la)]

lA = 200 ft

x B

A

y

hA = 50 ft

FIGURE P28.26

L P

y

x

0

836 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

where h 5 depth (m), t 5 time (s), d 5 pipe diameter (m), A(h) 5

pond surface area as a function of depth (m2), g 5 gravitational

constant (5 9.81 m/s2), and e 5 depth of pipe outlet below the pond

bottom (m). Based on the following area-depth table, solve this dif-

ferential equation to determine how long it takes for the pond to

empty given that h(0) 5 6 m, d 5 0.25 m, e 5 1 m.

h, m 6 5 4 3 2 1 0

A(h), 104 m2 1.17 0.97 0.67 0.45 0.32 0.18 0

28.29 Engineers and scientists use mass-spring models to gain in-

sight into the dynamics of structures under the in! uence of distur-

bances such as earthquakes. Figure P28.29 shows such a

representation for a three-story building. For this case, the analysis

is limited to horizontal motion of the structure. Force balances can

be developed for this system as

ak1 1 k2 m1

2 v2b X1 2 k2 m1

X2 5 0

2 k2

m2 X1 1 ak2 1 k3

m2 2 v2b X2 2 k3

m2 X3 5 0

2 k3

m3 X2 1 a k3

m3 2 v2b X3 5 0

Determine the eigenvalues and eigenvectors and graphically repre-

sent the modes of vibration for the structure by displaying the

amplitudes versus height for each of the eigenvectors. Normalize

the amplitudes so that the displacement of the third ! oor is one.

28.30 Under a number of simplifying assumptions, the steady-

state height of the water table in a one-dimensional, uncon” ned

groundwater aquifer (Fig. P28.30) can be modeled with the follow-

ing second-order ODE,

K h d 2h

dx2 1 N 5 0

P 5 1 kip, L 5 10 ft. Compare your numerical results to the

analytical solution,

y 5 2 PLx2

2EI 1

Px3

6EI

28.27 The basic differential equation of the elastic curve for a uni-

formly loaded beam (Fig. P28.27) is given as

EI d 2y

dx2 5 wLx

2 2 wx2

2

where E 5 the modulus of elasticity and I 5 the moment of inertia.

Solve for the de! ection of the beam using (a) the ” nite-difference

approach (Dx 5 2 ft) and (b) the shooting method. The following

parameter values apply: E 5 30,000 ksi, I 5 800 in4, w 5 1 kip/ft,

L 5 10 ft. Compare your numerical results to the analytical solution,

y 5 wLx3

12EI 2 wx4

24EI 2 wL3x

24EI

28.28 A pond drains through a pipe, as shown in Fig. P28.28. Un-

der a number of simplifying assumptions, the following differential

equation describes how depth changes with time:

dh

dt 5 2

pd 2

4A(h) 12g(h 1 e)

L

y

w

x

0

FIGURE P28.27

m3 = 8000 kg

k3 = 1800 kN/m

k2 = 2400 kN/m

k1 = 3000 kN/m

m2 = 10,000 kg

m1 = 12,000 kg

FIGURE P28.29

e

d

h

A(h)

FIGURE P28.28

PROBLEMS 837

dy

dt 5 2cy 1 dxy

where K 5 the carrying capacity. Use the same parameter values

and initial conditions as in Sec. 28.2 to integrate these equations

from t 5 0 to 100 using .

(a) Employ a very large value of K 5 108 to validate that you ob-

tain the same results as in Sec. 28.2.

(b) Compare (a) with the more realistic carrying capacity of K 5

200. Discuss your results.

28.33 The growth of ! oating, unicellular algae below a sewage

treatment plant discharge can be modeled with the following simul-

taneous ODEs:

da

dt 5 [kg(n, p) 2 kd 2 ks] a

dn

dt 5 rnckhc 2 rnakg(n, p)a

dp

dt 5 rpckhc 2 rpakg(n, p)a

dc

dt 5 rcakda 2 khc

where t 5 travel time (d), a 5 algal chlorophyll concentration

(mgA/L), n 5 inorganic nitrogen concentration (mgN/L), p 5 inor-

ganic phosphorus concentration (mgP/L), c 5 detritus concentra-

tion (mgC/L), kd 5 algal death rate (/d), ks 5 algal settling rate (/d),

kh 5 detrital hydrolysis rate (/d), rnc 5 nitrogen-to-carbon ratio

(mgN/mgC), rpc 5 phosphorus-to-carbon ratio (mgP/mgC), rna 5

nitrogen-to-chlorophyll ratio (mgN/mgA), rpa 5 phosphorus-to-

chlorophyll ratio (mgP/mgA), and kg(n, p) 5 algal growth rate (/d),

which can be computed with

kg(n, p) 5 kg min e p ksp 1 p

, n

ksn 1 n f

where kg 5 the algal growth rate at excess nutrient levels (/d), ksp 5

the phosphorus half-saturation constant (mgP/L), and ksn 5 the

nitrogen half-saturation constant (mgN/L). Use the and

functions to solve these equations from t 5 0 to 50 d

given the initial conditions a 5 1, n 5 4000, p 5 800, and c 5 0.

Note that the parameters are kd 5 0.1, ks 5 0.15, kh 5 0.025, rnc 5

0.18, rpc 5 0.025, rna 5 7.2, rpa 5 1, rca 5 40, kg 5 0.5, ksp 5 2, and

ksn 5 15. Develop plots of both solutions and interpret the results.

28.34 The following ODEs have been proposed as a model of an

epidemic:

dS

dt 5 2aSI

dI

dt 5 aSI 2 rI

dR

dt 5 rI

where x 5 distance (m), K 5 hydraulic conductivity (m/d), h 5

height of the water table (m), h 5 the average height of the water

table (m), and N 5 in” ltration rate (m/d).

Solve for the height of the water table for x 5 0 to 1000 m where

h(0) 5 10 m and h(1000) 5 5 m. Use the following parameters for

the calculation: K 5 1 m/d and N 5 0.0001 m/d. Set the average

height of the water table as the average of the boundary conditions.

Obtain your solution with (a) the shooting method and (b) the ” nite-

difference method (Dx 5 100 m).

28.31 In Prob. 28.30, a linearized groundwater model was used

to simulate the height of the water table for an uncon” ned aqui-

fer. A more realistic result can be obtained by using the following

nonlinear ODE:

d

dx aKh dh

dx b 1 N 5 0

where x 5 distance (m), K 5 hydraulic conductivity (m/d), h 5

height of the water table (m), and N 5 in” ltration rate (m/d).

Solve for the height of the water table for the same case as in

Prob. 28.30. That is solve from x 5 0 to 1000 m with h(0) 5 10 m,

h(1000) 5 5 m, K 5 1 m/d, and N 5 0.0001 m/d. Obtain your

solution with (a) the shooting method and (b) the ” nite-difference

method (Dx 5 100 m).

28.32 The Lotka-Volterra equations described in Sec. 28.2 have

been re” ned to include additional factors that impact predator-prey

dynamics. For example, over and above predation, prey population

can be limited by other factors such as space. Space limitation can

be incorporated into the model as a carrying capacity (recall the

logistic model described in Prob. 28.16) as in

dx

dt 5 a a1 2 x

K b x 2 bxy

Ground surface

Water table Infiltrationh

x

Confining bed

Aquifer Groundwater flow

FIGURE P28.30

An unconfi ned or “phreatic” aquifer.

838 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

D 5 2e dV

dx

where D is called the electric ! ux density vector, e 5 permittivity of

the material, and V 5 electrostatic potential. Similarly, a Poisson equa-

tion for electrostatic ” elds can be represented in one dimension as

d 2V

dx2 5 2

ry

e

where ry 5 charge density. Use the ” nite-difference technique with

Dx 5 2 to determine V for a wire where V(0) 5 1000, V(20) 5 0,

e 5 2, L 5 20, and ry 5 30.

Mechanical/Aerospace Engineering

28.41 Perform the same computation as in Sec. 28.4 but for a

1-m-long pendulum.

28.42 The rate of cooling of a body can be expressed as

dT

dt 5 2k(T 2 Ta)

where T 5 temperature of the body (8C), Ta 5 temperature of the sur-

rounding medium (8C), and k 5 the proportionality constant (min21).

Thus, this equation speci” es that the rate of cooling is proportional to

the difference in temperature between the body and the surrounding

medium. If a metal ball heated to 908C is dropped into water that is

held at a constant value of Ta 5 208C, use a numerical method to

compute how long it takes the ball to cool to 408C if k 5 0.25 min21.

28.43 The rate of heat ! ow (conduction) between two points on a

cylinder heated at one end is given by

dQ

dt 5 l A

dT

dx

where l 5 a constant, A 5 the cylinder’s cross-sectional area,

Q 5 heat ! ow, T 5 temperature, t 5 time, and x 5 distance from

the heated end. Because the equation involves two derivatives, we

will simplify this equation by letting

dT

dx 5

100(L 2 x) (20 2 t)

100 2 xt

where L is the length of the rod. Combine the two equations and

compute the heat ! ow for t 5 0 to 25 s. The initial condition is

Q(0) 5 0 and the parameters are l 5 0.5 cal ? cm/s, A 5 12 cm2,

L 5 20 cm, and x 5 2.5 cm. Plot your results.

28.44 Repeat the falling parachutist problem (Example 1.2), but

with the upward force due to drag as a second-order rate:

Fu 5 2cy 2

where c 5 0.225 kg/m. Solve for t 5 0 to 30, plot your results, and

compare with those of Example 1.2.

where S 5 the susceptible individuals, I 5 the infected, R 5 the

recovered, a 5 the infection rate, and r 5 the recovery rate. A city

has 10,000 people, all of whom are susceptible.

(a) If a single infectious individual enters the city at t 5 0, com-

pute the progression of the epidemic until the number of in-

fected individuals falls below 10. Use the following parameters:

a 5 0.002/(person?week) and r 5 0.15yd. Develop time-series plots of all the state variables. Also generate a phaseplane plot

of S versus I versus R.

(b) Suppose that after recovery, there is a loss of immunity that

causes recovered individuals to become susceptible. This rein-

fection mechanism can be computed as rR, where r 5 the

reinfection rate. Modify the model to include this mechanism

and repeat the computations in (a) using r 5 0.015yd.

Electrical Engineering

28.35 Perform the same computation as in the ” rst part of Sec. 28.3,

but with R 5 0.025 V.

28.36 Solve the ODE in the ” rst part of Sec. 8.3 from t 5 0 to 0.5

using numerical techniques if q 5 0.1 and i 5 23.281515 at t 5 0.

Use an R 5 50 along with the other parameters from Sec. 8.3.

28.37 For a simple RL circuit, Kirchhoff’s voltage law requires

that (if Ohm’s law holds)

L di

dt 1 Ri 5 0

where i 5 current, L 5 inductance, and R 5 resistance. Solve for i,

if L 5 1, R 5 1.5, and i(0) 5 0.5. Solve this problem analytically

and with a numerical method. Present your results graphically.

28.38 In contrast to Prob. 28.37, real resistors may not always obey

Ohm’s law. For example, the voltage drop may be nonlinear and the

circuit dynamics is described by a relationship such as

L di

dt 1 R c i

I 2 a i

I b3 d 5 0

where all other parameters are as de” ned in Prob. 28.37 and I is a

known reference current equal to 1. Solve for i as a function of time

under the same conditions as speci” ed in Prob. 28.37.

28.39 Develop an eigenvalue problem for an LC network similar to

the one in Fig. 28.14, but with only two loops. That is, omit the i3

loop. Draw the network, illustrating how the currents oscillate in

their primary modes.

28.40 Just as Fourier’s law and the heat balance can be employed

to characterize temperature distribution, analogous relationships

are available to model ” eld problems in other areas of engineering.

For example, electrical engineers use a similar approach when

modeling electrostatic ” elds. Under a number of simplifying

assumptions, an analog of Fourier’s law can be represented in

one-dimensional form as

PROBLEMS 839

(d) The full nonlinear equation where both the damping and spring

terms are nonlinear

m d 2x

dt2 1 a ` dx

dt ` dx dt

1 bx3 5 0

28.47 A forced damped spring-mass system (Fig. P28.47) has the

following ordinary differential equation of motion:

m d 2x

dt2 1 a ` dx

dt ` dx dt

1 kx 5 Fo sin(vt)

where x 5 displacement from the equilibrium position, t 5 time,

m 5 2 kg mass, a 5 5 N/(m/s)2, and k 5 6 N/m. The damping term is

nonlinear and represents air damping. The forcing function Fo sin(vt)

has values of Fo 5 2.5 N and v 5 0.5 rad/sec. The initial conditions are

Initial velocity dx

dt 5 0 m/s

Initial displacement x 5 1 m

Solve this equation using a numerical method over the time period

0 # t # 15 s. Plot the displacement and velocity versus time, and

plot the forcing function on the same curve. Also, develop a sepa-

rate plot of velocity versus displacement.

28.48 The temperature distribution in a tapered conical cooling ” n

(Fig. P28.48) is described by the following differential equation,

which has been nondimensionalized

d 2u

dx2 1 a2

x b adu

dx 2 pub 5 0

where u 5 temperature (0 # u # 1), x 5 axial distance (0 # x # 1),

and p is a nondimensional parameter that describes the heat transfer

and geometry

p 5 hL

k B1 1

4

2m2

28.45 Suppose that, after falling for 13 s, the parachutist from

Examples 1.1 and 1.2 pulls the rip cord. At this point, assume that

the drag coef” cient is instantaneously increased to a constant

value of 55 kg/s. Compute the parachutist’s velocity from t 5 0 to

30 s with Heun’s method (without iteration of the corrector) using

a step-size of 2 s. Plot y versus t for t 5 0 to 30 s.

28.46 The following ordinary differential equation describes the

motion of a damped spring-mass system (Fig. P28.46):

m d 2x

dt2 1 a ` dx

dt ` dx dt

1 bx3 5 0

where x 5 displacement from the equilibrium position, t 5 time,

m 5 1 kg mass, and a 5 5 N/(m/s)2. The damping term is nonlinear

and represents air damping.

The spring is a cubic spring and is also nonlinear with b 5 5 N/m3.

The initial conditions are

Initial velocity dx

dt 5 0.5 mys

Initial displacement x 5 1 m

Solve this equation using a numerical method over the time period

0 # t # 8 s. Plot the displacement and velocity versus time and plot

the phase-plane portrait (velocity versus displacement) for all the

following cases:

(a) A similar linear equation

m d 2x

dt2 1 2

dx

dt 1 5x 5 0

(b) The nonlinear equation with only a nonlinear spring term

d 2x

dt2 1 2

dx

dt 1 bx3 5 0

(c) The nonlinear equation with only a nonlinear damping term

m d 2x

dt2 1 a ` dx

dt ` dx dt

1 5x 5 0

Cubic spring

Air damping

x

m

FIGURE P28.46

Air damping

k

x

m Fo sin( t)

FIGURE P28.47

840 CASE STUDIES: ORDINARY DIFFERENTIAL EQUATIONS

stretch, the spring and dampening forces of the cord must also be

included. These two conditions can be expressed by the following

equations:

dy

dt 5 g 2 sign(y)

cd

m y2 x # L

dy

dt 5 g 2 sign(y)

cd

m y2 2

k

m (x 2 L) 2

g

m y x . L

where y 5 velocity (m/s), t 5 time (s), g 5 gravitational constant

(5 9.81 m/s2), sign(x) 5 function that returns 21, 0, and 1 for

negative, zero, and positive x, respectively, cd 5 second-order

drag coef! cient (kg/m), m 5 mass (kg), k 5 cord spring constant

(N/m), g 5 cord dampening coef! cient (N ? s/m), and L 5 cord

length (m). Determine the position and velocity of the jumper

given the following parameters: L 5 30 m, m 5 68.1 kg, cd 5

0.25 kg/m, k 5 40 N/m, and g 5 8 kg/s. Perform the computation

from t 5 0 to 50 s and assume that the initial conditions are x(0) 5

y(0) 5 0.

28.51 Two masses are attached to a wall by linear springs (Fig.

P28.51). Force balances based on Newton’s second law can be

written as

d 2×1

dt 2 5 2

k1

m1 (x1 2 L1) 1

k2

m1 (x2 2 x1 2 w1 2 L2)

d 2×2

dt 2 5 2

k2

m2 (x2 2 x1 2 w1 2 L2)

where k 5 the spring constants, m 5 mass, L 5 the length of the

unstretched spring, and w 5 the width of the mass. Compute the

positions of the masses as a function of time using the following pa-

rameter values: k1 5 k2 5 5, m1 5 m2 5 2, w1 5 w2 5 5, and L1 5

L2 5 2. Set the initial conditions as x1 5 L1 and x2 5 L1 1 w1 1

L2 1 6. Perform the simulation from t 5 0 to 20. Construct time-

series plots of both the displacements and the velocities. In addition,

produce a phase-plane plot of x1 versus x2.

where h 5 a heat transfer coef! cient, k 5 thermal conductivity,

L 5 the length or height of the cone, and m 5 the slope of the cone

wall. The equation has the boundary conditions

u(x 5 0) 5 0 u(x 5 1) 5 1

Solve this equation for the temperature distribution using ! nite

difference methods. Use second-order accurate ! nite difference

analogues for the derivatives. Write a computer program to obtain

the solution and plot temperature versus axial distance for various

values of p 5 10, 20, 50, and 100.

28.49 The dynamics of a forced spring-mass-damper system can

be represented by the following second-order ODE:

m d 2x

dt2 1 c

dx

dt 1 k1x 1 k3x

3 5 P cos(vt)

where m 5 1 kg, c 5 0.4 N ? s/m, P 5 0.5 N, and v 5 0.5/s. Use a

numerical method to solve for displacement (x) and velocity (y 5

dxydt) as a function of time with the initial conditions x 5 y 5 0. Express your results graphically as time-series plots (x and y versus t)

and a phase plane plot (y versus x). Perform simulations for both

(a) linear (k1 5 1; k3 5 0) and (b) nonlinear (k1 5 1; k3 5 0.5)

springs.

28.50 The differential equation for the velocity of a bungee jumper

is different depending on whether the jumper has fallen to a dis-

tance where the cord is fully extended and begins to stretch. Thus,

if the distance fallen is less than the cord length, the jumper is only

subject to gravitational and drag forces. Once the cord begins to

x = 1

u(x = 1) = 1

u(x = 0) = 0

x

FIGURE P28.48

x

k1

L1 w1 L2 w2

x10 x2

k2

m1 m2

FIGURE P28.51

841

EPILOGUE: PART SEVEN

PT7.4 TRADE-OFFS

Table PT7.3 contains trade-offs associated with numerical methods for the solution of

initial-value ordinary differential equations. The factors in this table must be evaluated

by the engineer when selecting a method for each particular applied problem.

Simple self-starting techniques such as Euler’s method can be used if the problem

requirements involve a short range of integration. In this case, adequate accuracy may

be obtained using small step sizes to avoid large truncation errors, and the round-off

errors may be acceptable. Euler’s method may also be appropriate for cases where the

mathematical model has an inherently high level of uncertainty or has coef cients or

forcing functions with signi cant errors as might arise during a measurement process.

In this case, the accuracy of the model itself simply does not justify the effort involved

to employ a more complicated numerical method. Finally, the simpler techniques may

be best when the problem or simulation need only be performed a few times. In these

applications, it is probably best to use a simple method that is easy to program and

TABLE PT7.3 Comparison of the characteristics of alternative methods for the numerical solution of ODEs. The comparisons are based on general experience and do not account for the behavior of special functions.

Starting Iterations Global Ease of Changing Programming Method Values Required Error Step Size Effort Comments

One step Euler’s 1 No O(h) Easy Easy Good for quick estimates Heun’s 1 Yes O(h2) Easy Moderate — Midpoint 1 No O(h2) Easy Moderate — Second-order Ralston 1 No O(h2) Easy Moderate The second-order RK

method that minimizes truncation error

Fourth-order RK 1 No O(h4) Easy Moderate Widely used Adaptive fourth-order RK or RK-Fehlberg 1 No O(h5)* Easy Moderate to Error estimate allows diffi cult step-size adjustment Multistep Non-self-starting 2 Yes O(h3)* Diffi cult Moderate to Simple multistep method Heun diffi cult†

Milne’s 4 Yes O(h5)* Diffi cult Moderate to Sometimes unstable diffi cult†

Fourth-order Adams 4 Yes O(h5)* Diffi cult Moderate to diffi cult†

*Provided the error estimate is used to modify the solution. †With variable step size.

842 EPILOGUE: PART SEVEN

understand despite the fact that the method may be computationally inef cient and rela-

tively time-consuming to run on the computer.

If the range of integration of the problem is long enough to involve a large number

of steps, then it may be necessary and appropriate to use a more accurate technique than

Euler’s method. The fourth-order RK method is popular and reliable for many engineer-

ing problems. In these cases, it may also be advisable to estimate the truncation error

for each step as a guide to selecting the best step size. This can be accomplished with

the adaptive RK or fourth-order Adams approaches. If the truncation errors are extremely

small, it may be wise to increase the step size to save computer time. On the other hand,

if the truncation error is large, the step size should be decreased to avoid accumulation

of error. Milne’s method should be avoided if signi cant stability problems are expected.

The Runge-Kutta method is simple to program and convenient to use but may be less

ef cient than the multistep methods. However, the Runge-Kutta method is usually em-

ployed in any event to obtain starting values for the multistep methods.

A large number of engineering problems may fall into an intermediate range of in-

tegration interval and accuracy requirement. In these cases, the second-order RK and the

non-self-starting Heun methods are simple to use and are relatively ef cient and accurate.

Stiff systems involve equations with slowly and rapidly varying components. Special

techniques are usually required for the adequate solution of stiff equations. For example,

implicit approaches are often used. You can consult Enright et al. (1975), Gear (1971),

and Shampine and Gear (1979) for additional information regarding these techniques.

A variety of techniques are available for solving eigenvalue problems. For small systems

or where only a few of the smallest or largest eigenvalues are required, simple approaches

such as the polynomial and the power methods are available. For symmetric systems, Jacobi’s,

Given’s, or Householder’s method can be employed. Finally, the QR method represents a

general approach for  nding all the eigenvalues of symmetric and nonsymmetric matrices.

PT7.5 IMPORTANT RELATIONSHIPS AND FORMULAS

Table PT7.4 summarizes important information that was presented in Part Seven. This

table can be consulted to quickly access important relationships and formulas.

PT7.6 ADVANCED METHODS AND ADDITIONAL REFERENCES

Although we have reviewed a number of techniques for solving ordinary differential

equations there is additional information that is important in engineering practice. The

question of stability was introduced in Sec. 26.2.4. This topic has general relevance to

all methods for solving ODEs. Further discussion of the topic can be pursued in Carnahan,

Luther, and Wilkes (1969), Gear (1971), and Hildebrand (1974).

In Chap. 27, we introduced methods for solving boundary-value problems. Isaacson

and Keller (1966), Keller (1968), Na (1979), and Scott and Watts (1976) can be consulted

for additional information on standard boundary-value problems. Additional material on

eigenvalues can be found in Ralston and Rabinowitz (1978), Wilkinson (1965), Fadeev

and Fadeeva (1963), and Householder (1953, 1964).

In summary, the foregoing is intended to provide you with avenues for deeper explo-

ration of the subject. Additionally, all the above references provide descriptions of the basic

techniques covered in Part Seven. We urge you to consult these alternative sources to

broaden your understanding of numerical methods for the solution of differential equations.

8 4 3

TABLE PT7.4 Summary of important information presented in Part Seven.

Graphic Method Formulation Interpretation Errors

Euler (First- yi11 5 yi 1 hk1 Local error . O (h 2)

order RK) k1 5 f (xi, yi) Global error . O (h)

Ralston’s second- yi11 5 yi 1 h( 1 3k1 1

2 3k2) Local error . O (h

3) order RK k1 5 f (xi, yi) Global error . O (h

2) k2 5 f (xi 1

3 4h, yi 1

3 4hk1)

Classic fourth- yi11 5 yi 1 h( 1 6k1 1

1 3k2 1

1 3k3 1

1 6k4) Local error . O (h

5) order RK k1 5 f (xi, yi) Global error . O (h

4) k2 5 f (xi 1

1 2h, yi 1

1 2hk1)

k3 5 f (xi 1 1 2h, yi 1

1 2hk2)

k4 5 f (xi 1 h, yi 1 hk3)

Non-self-starting Predictor: (midpoint method) Predictor modifi er:

Heun y 0i11 5 y m i21 1 2hf (xi, y

m i ) Ep .

4 5 (y

m i,u 1 y

0 i,u )

Corrector: (trapezoidal rule) Corrector modifi er:

y ji11 5 y m i 1 h

f (xi, y m i ) 1 f (xi11, y

i21 i11)

2 Ec . 2

y mi11,u 2 y 0 i11,u

5

Fourth-order Adams Predictor: (fourth Adams-Bashforth) Predictor modifi er:

y 0i11 5 y m i 1 h(

55 24 f

m i 2

59 24 f

m i21 1

37 24 f

m i22 2

9 24 f

m i23) Ep .

251 270 (y

m i,u 2 y

0 i,u )

Corrector: (fourth Adams-Moulton) Corrector modifi er:

y ji11 5 y m i 1 h(

9 24 f

j21 i11 1

19 24 f

m i 2

5 24 f

m i21 1

1 24 f

m i22) Ec . 2

19 270 (y

m i11,u 2 y

0 i11,u)

y

i – 3 i – 2 i – 1 i i + 1 x

y

i – 3 i – 2 i – 1 i i + 1 x

y

i – 3 i – 2 i – 1 i i + 1 x

y

i – 3 i – 2 i – 1 i i + 1 x

y

i – 3 i – 2 i – 1 i i + 1 x

y

i – 3 i – 2 i – 1 i i + 1 x

y

i – 3 i – 2 i – 1 i i + 1 x

PART EIGHT

845

PT8.1 MOTIVATION

Given a function u that depends on both x and y, the partial derivative of u with respect

to x at an arbitrary point (x, y) is de! ned as

0u

0x 5 lim ¢xS0

u(x 1 ¢x, y) 2 u(x, y)

¢x (PT8.1)

Similarly, the partial derivative with respect to y is de! ned as

0u

0y 5 lim ¢yS0

u(x, y 1 ¢y) 2 u(x, y)

¢y (PT8.2)

An equation involving partial derivatives of an unknown function of two or more inde-

pendent variables is called a partial differential equation, or PDE. For example,

0 2u

0x2 1 2xy

0 2u

0y2 1 u 5 1 (PT8.3)

0 3u

0x20y 1 x 0

2u

0y2 1 8u 5 5y (PT8.4)

a 02u 0x2 b3 1 6 03u

0x0y2 5 x (PT8.5)

0 2u

0x2 1 xu

0u

0y 5 x (PT8.6)

The order of a PDE is that of the highest-order partial derivative appearing in the equa-

tion. For example, Eqs. (PT8.3) and (PT8.4) are second- and third-order, respectively.

A partial differential equation is said to be linear if it is linear in the unknown

function and all its derivatives, with coef! cients depending only on the independent

variables. For example, Eqs. (PT8.3) and (PT8.4) are linear, whereas Eqs. (PT8.5) and

(PT8.6) are not.

Because of their widespread application in engineering, our treatment of PDEs will

focus on linear, second-order equations. For two independent variables, such equations

can be expressed in the following general form:

A 0

2u

0x2 1 B

0 2u

0x0y 1 C 0

2u

0y2 1 D 5 0 (PT8.7)

where A, B, and C are functions of x and y and D is a function of x, y, u, 0uy0x, and 0uy0y.

Depending on the values of the coef! cients of the second-derivative terms—A, B, C—

PARTIAL DIFFERENTIAL EQUATIONS

846 PARTIAL DIFFERENTIAL EQUATIONS

Eq. (PT8.7) can be classi! ed into one of three categories (Table PT8.1). This classi! cation,

which is based on the method of characteristics (for example, see Vichnevetsky, 1981, or

Lapidus and Pinder, 1981), is useful because each category relates to speci! c and distinct

engineering problem contexts that demand special solution techniques. It should be noted

that for cases where A, B, and C depend on x and y, the equation may actually fall into a

different category, depending on the location in the domain for which the equation holds.

For simplicity, we will limit the present discussion to PDEs that remain exclusively in one

of the categories.

PT8.1.1 PDEs and Engineering Practice

Each of the categories of partial differential equations in Table PT8.1 conforms to speci! c

kinds of engineering problems. The initial sections of the following chapters will be

devoted to deriving each type of equation for a particular engineering problem context.

For the time being, we will discuss their general properties and applications and show

how they can be employed in different physical contexts.

Elliptic equations are typically used to characterize steady-state systems. As in the

Laplace equation in Table PT8.1, this is indicated by the absence of a time derivative.

Thus, these equations are typically employed to determine the steady-state distribution

of an unknown in two spatial dimensions.

A simple example is the heated plate in Fig. PT8.1a. For this case, the boundaries

of the plate are held at different temperatures. Because heat ” ows from regions of high

to low temperature, the boundary conditions set up a potential that leads to heat ” ow

from the hot to the cool boundaries. If suf! cient time elapses, such a system will even-

tually reach the stable or steady-state distribution of temperature depicted in Fig. PT8.1a.

The Laplace equation, along with appropriate boundary conditions, provides a means to

determine this distribution. By analogy, the same approach can be employed to tackle

other problems involving potentials, such as seepage of water under a dam (Fig. PT8.1b)

or the distribution of an electric ! eld (Fig. PT8.1c).

TABLE PT8.1 Categories into which linear, second-order partial differential equations in two variables can be classifi ed.

B2 2 4AC Category Example

, 0 Elliptic Laplace equation (steady state with two spatial dimensions)

0

2T

0x2 1 0

2T

0y 2 5 0

5 0 Parabolic Heat conduction equation (time variable with one spatial dimension)

0T

0t 5 k¿

0 2T

0x2

. 0 Hyperbolic Wave equation (time variable with one spatial dimension)

0

2y

0x2 5

1

c2 0

2y

0t 2

PT8.1 MOTIVATION 847

In contrast to the elliptic category, parabolic equations determine how an unknown

varies in both space and time. This is manifested by the presence of both spatial and tem-

poral derivatives in the heat conduction equation from Table PT8.1. Such cases are referred

to as propagation problems because the solution “propagates,’’ or changes, in time.

A simple example is a long, thin rod that is insulated everywhere except at its end

(Fig. PT8.2a). The insulation is employed to avoid complications due to heat loss along

Co nd

uct or

Dam

Flow line

Impermeable rock

Equipotential

line

Hot

Cool

CoolHot

(a) (b) (c)

FIGURE PT8.1

Three steady-state distribution problems that can be characterized by elliptic PDEs. (a) Temperature distribution on a heated plate, (b) seepage of water under a dam, and (c) the electric fi eld near the point of a conductor.

FIGURE PT8.2

(a) A long, thin rod that is insulated everywhere but at its end. The dynamics of the one- dimensional distribution of temperature along the rod’s length can be described by a parabolic PDE. (b) The solution, consisting of distributions corresponding to the state of the rod at various times.

T

x

(a)

(b)

CoolHot

t = 3 t

t = 2 tt = t t = 0

848 PARTIAL DIFFERENTIAL EQUATIONS

the rod’s length. As was the case for the heated plate in Fig. PT8.1a, the ends of the rod

are set at ! xed temperatures. However, in contrast to Fig. PT8.1a, the rod’s thinness

allows us to assume that heat is distributed evenly over its cross section—that is, later-

ally. Consequently, lateral heat ” ow is not an issue, and the problem reduces to studying

the conduction of heat along the rod’s longitudinal axis. Rather than focusing on the

steady-state distribution in two spatial dimensions, the problem shifts to determining how

the one-dimensional spatial distribution changes as a function of time (Fig. PT8.2b).

Thus, the solution consists of a series of spatial distributions corresponding to the state

of the rod at various times. Using an analogy from photography, the elliptic case yields

a portrait of a system’s stable state, whereas the parabolic case provides a motion picture

of how it changes from one state to another. As with the other types of PDEs described

herein, parabolic equations can be used to characterize a wide variety of other engineer-

ing problem contexts by analogy.

The ! nal class of PDEs, the hyperbolic category, also deals with propagation prob-

lems. However, an important distinction manifested by the wave equation in Table PT8.1

is that the unknown is characterized by a second derivative with respect to time. As a

consequence, the solution oscillates.

The vibrating string in Fig. PT8.3 is a simple physical model that can be described

with the wave equation. The solution consists of a number of characteristic states with

which the string oscillates. A variety of engineering systems such as vibrations of rods and

beams, motion of ” uid waves, and transmission of sound and electrical signals can be

characterized by this model.

PT8.1.2 Precomputer Methods for Solving PDEs

Prior to the advent of digital computers, engineers relied on analytical or exact solutions

of partial differential equations. Aside from the simplest cases, these solutions often

required a great deal of effort and mathematical sophistication. In addition, many phys-

ical systems could not be solved directly but had to be simpli! ed using linearizations,

simple geometric representations, and other idealizations. Although these solutions are

elegant and yield insight, they are limited with respect to how faithfully they represent

real systems—especially those that are highly nonlinear and irregularly shaped.

PT8.2 ORIENTATION

Before we proceed to the numerical methods for solving partial differential equations,

some orientation might be helpful. The following material is intended to provide you

with an overview of the material discussed in Part Eight. In addition, we have formulated

objectives to focus your studies in the subject area.

FIGURE PT8.3 A taut string vibrating at a low amplitude is a simple physical system that can be characterized by a hyperbolic PDE.

PT8.2 ORIENTATION 849

PT8.2.1 Scope and Preview

Figure PT8.4 provides an overview of Part Eight. Two broad categories of numerical

methods will be discussed in this part of this book. Finite-difference approaches, which

are covered in Chaps. 29 and 30, are based on approximating the solution at a  nite

number of points. In contrast,  nite-element methods, which are covered in Chap. 31,

CHAPTER 29

Finite Difference:

Elliptic

Equations

PART EIGHT

Partial

Differential

Equations

CHAPTER 30

Finite Difference:

Parabolic

Equations

CHAPTER 31

Finite-Element

Method

CHAPTER 32

Case Studies

EPILOGUE

30.4 Crank-

Nicolson

30.3 Simple implicit

methods

30.2 Explicit

methods

30.1 Heat-conduction

equation

PT 8.5 Advanced methods

PT 8.4 Important formulas

32.4 Mechanical engineering

32.3 Electrical

engineering

32.2 Civil

engineering

32.1 Chemical

engineering

31.4 Software packages

31.1 General

approach

31.3 Two-dimensional

analysis

31.2 One-dimensional

analysis

PT 8.3 Trade-offs

PT 8.2 Orientation

PT 8.1 Motivation

29.2 Finite-difference

solution

29.3 Boundary conditions

29.4 Control-volume

approach

29.5 Computer algorithms

29.1 Laplace equation

30.5 ADI

FIGURE PT8.4 Schematic representation of the organization of material in Part Eight: Partial Differential Equations.

850 PARTIAL DIFFERENTIAL EQUATIONS

approximate the solution in pieces, or “elements.” Various parameters are adjusted until

these approximations conform to the underlying differential equation in an optimal sense.

Chapter 29 is devoted to ! nite-difference solutions of elliptic equations. Before

launching into the methods, we derive the Laplace equation for the physical problem

context of the temperature distribution for a heated plate. Then, a standard solution ap-

proach, the Liebmann method, is described. We will illustrate how this approach is used

to compute the distribution of the primary scalar variable, temperature, as well as a

secondary vector variable, heat ” ux. The ! nal section of the chapter deals with boundary

conditions. This material includes procedures to handle different types of conditions as

well as irregular boundaries.

In Chap. 30, we turn to ! nite-difference solutions of parabolic equations. As with the

discussion of elliptic equations, we ! rst provide an introduction to a physical problem

context, the heat-conduction equation for a one-dimensional rod. Then we introduce both

explicit and implicit algorithms for solving this equation. This is followed by an ef! cient

and reliable implicit method—the Crank-Nicolson technique. Finally, we describe a particu-

larly effective approach for solving two-dimensional parabolic equations—the alternating-

direction implicit, or ADI, method.

Note that, because they are somewhat beyond the scope of this book, we have chosen

to omit hyperbolic equations. The epilogue of this part of the book contains references

related to this type of PDE.

In Chap. 31, we turn to the other major approach for solving PDEs—the ! nite-element

method. Because it is so fundamentally different from the ! nite-difference approach, we

devote the initial section of the chapter to a general overview. Then we show how the ! nite-

element method is used to compute the steady-state temperature distribution of a heated

rod. Finally, we provide an introduction to some of the issues involved in extending such

an analysis to two-dimensional problem contexts.

Chapter 32 is devoted to applications from all ! elds of engineering. Finally, a short

review section is included at the end of Part Eight. This epilogue summarizes important

information related to PDEs. This material includes a discussion of trade-offs that are rel-

evant to their implementation in engineering practice. The epilogue also includes references

for advanced topics.

PT8.2.2 Goals and Objectives

Study Objectives. After completing Part Eight, you should have greatly enhanced your capability to confront and solve partial differential equations. General study goals should

include mastering the techniques, having the capability to assess the reliability of the an-

swers, and being able to choose the “best’’ method (or methods) for any particular problem.

In addition to these general objectives, the speci! c study objectives in Table PT8.2 should

be mastered.

Computer Objectives. Computer algorithms can be developed for many of the methods in Part Eight. For example, you may ! nd it instructive to develop a general program to

simulate the steady-state distribution of temperature on a heated plate. Further, you might

want to develop programs to implement both the simple explicit and the Crank-Nicolson

methods for solving parabolic PDEs in one spatial dimension.

PT8.2 ORIENTATION 851

Finally, one of your most important goals should be to master several of the general-

purpose software packages that are widely available. In particular, you should become

adept at using these tools to implement numerical methods for engineering problem

solving.

TABLE PT8.2 Specifi c study objectives for Part Eight.

1. Recognize the difference between elliptic, parabolic, and hyperbolic PDEs. 2. Understand the fundamental difference between fi nite-difference and fi nite-element approaches. 3. Recognize that the Liebmann method is equivalent to the Gauss-Seidel approach for solving

simultaneous linear algebraic equations. 4. Know how to determine secondary variables for two-dimensional fi eld problems. 5. Recognize the distinction between Dirichlet and derivative boundary conditions. 6. Understand how to use weighting factors to incorporate irregular boundaries into a fi nite-difference

scheme for PDEs. 7. Understand how to implement the control-volume approach for implementing numerical solutions

of PDEs. 8. Know the difference between convergence and stability of parabolic PDEs. 9. Understand the difference between explicit and implicit schemes for solving parabolic PDEs. 10. Recognize how the stability criteria for explicit methods detract from their utility for solving

parabolic PDEs. 11. Know how to interpret computational molecules. 12. Recognize how the ADI approach achieves high effi ciency in solving parabolic equations in two

spatial dimensions. 13. Understand the difference between the direct method and the method of weighted residuals for

deriving element equations. 14. Know how to implement Galerkin’s method. 15. Understand the benefi ts of integration by parts during the derivation of element equations; in

particular, recognize the implications of lowering the highest derivative from a second to a fi rst derivative.

29

852

C H A P T E R 29

Finite Difference: Elliptic Equations

Elliptic equations in engineering are typically used to characterize steady-state, boundary-

value problems. Before demonstrating how they can be solved, we will illustrate how a

simple case—the Laplace equation—is derived from a physical problem context.

29.1 THE LAPLACE EQUATION

As mentioned in the introduction to this part of the book, the Laplace equation can be

used to model a variety of problems involving the potential of an unknown variable.

Because of its simplicity and general relevance to most areas of engineering, we will use

a heated plate as our fundamental context for deriving and solving this elliptic PDE.

Homework problems and engineering applications (Chap. 32) will be employed to illus-

trate the applicability of the model to other engineering problem contexts.

Figure 29.1 shows an element on the face of a thin rectangular plate of thickness Dz.

The plate is insulated everywhere but at its edges, where the temperature can be set at a

prescribed level. The insulation and the thinness of the plate mean that heat transfer is

limited to the x and y dimensions. At steady state, the ! ow of heat into the element over

a unit time period Dt must equal the ! ow out, as in

q(x)¢y ¢z ¢t 1 q(y) ¢x ¢z ¢t 5 q(x 1 ¢x)¢y ¢z ¢t

1 q(y 1 ¢y)¢x ¢z ¢t (29.1)

where q(x) and q(y) 5 the heat ! uxes at x and y, respectively [cal/(cm2 ? s)]. Dividing

by Dz and Dt and collecting terms yields

[q(x) 2 q(x 1 ¢x)]¢y 1 [q(y) 2 q(y 1 ¢y)]¢x 5 0

Multiplying the ” rst term by DxyDx and the second by DyyDy gives

q(x) 2 q(x 1 ¢x)

¢x ¢x ¢y 1

q(y) 2 q(y 1 ¢y)

¢y ¢y ¢x 5 0 (29.2)

Dividing by Dx Dy and taking the limit results in

2 0q

0x 2 0q

0y 5 0 (29.3)

where the partial derivatives result from the de” nitions in Eqs. (PT8.1) and (PT8.2).

29.1 THE LAPLACE EQUATION 853

Equation (29.3) is a partial differential equation that is an expression of the conserva-

tion of energy for the plate. However, unless heat ! uxes are speci” ed at the plate’s edges,

it cannot be solved. Because temperature boundary conditions are given, Eq. (29.3) must

be reformulated in terms of temperature. The link between ! ux and temperature is pro-

vided by Fourier’s law of heat conduction, which can be represented as

qi 5 2krC 0T

0i (29.4)

where qi 5 heat ! ux in the direction of the i dimension [cal/(cm 2 ? s)], k 5 coef” cient

of thermal diffusivity (cm2/s), r 5 density of the material (g/cm3), C 5 heat capacity of

the material [cal/(g ? 8C)], and T 5 temperature (8C), which is de” ned as

T 5 H

rCV

where H 5 heat (cal) and V 5 volume (cm3). Sometimes the term in front of the dif-

ferential in Eq. (29.4) is treated as a single term,

k¿ 5 krC (29.5)

where k9 is referred to as the coef! cient of thermal conductivity [cal/(s ? cm ? 8C)]. In either

case, both k and k9 are parameters that re! ect how well the material conducts heat.

Fourier’s law is sometimes referred to as a constitutive equation. It is given this label

because it provides a mechanism that de” nes the system’s internal interactions. Inspec-

tion of Eq. (29.4) indicates that Fourier’s law speci” es that heat ! ux perpendicular to

FIGURE 29.1 A thin plate of thickness Dz. An element is shown about which a heat balance is taken.

z

x

y

q(y)

q(x) q(x + x)

q(y + y)

y

x

854 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

the i axis is proportional to the gradient or slope of temperature in the i direction. The

negative sign ensures that a positive ! ux in the direction of i results from a negative

slope from high to low temperature (Fig. 29.2). Substituting Eq. (29.4) into Eq. (29.3)

results in

0 2T

0x2 1 0

2T

0y2 5 0 (29.6)

which is the Laplace equation. Note that for the case where there are sources or sinks

of heat within the two-dimensional domain, the equation can be represented as

0 2T

0x2 1 0

2T

0y2 5 f(x, y) (29.7)

where f(x, y) is a function describing the sources or sinks of heat. Equation (29.7) is

referred to as the Poisson equation.

29.2 SOLUTION TECHNIQUE

The numerical solution of elliptic PDEs such as the Laplace equation proceeds in the

reverse manner of the derivation of Eq. (29.6) from the preceding section. Recall that

the derivation of Eq. (29.6) employed a balance around a discrete element to yield an

algebraic difference equation characterizing heat ! ux for a plate. Taking the limit turned

this difference equation into a differential equation [Eq. (29.3)].

For the numerical solution, ” nite-difference representations based on treating the plate

as a grid of discrete points (Fig. 29.3) are substituted for the partial derivatives in Eq.

(29.6). As described next, the PDE is transformed into an algebraic difference equation.

FIGURE 29.2 Graphical depiction of a temperature gradient. Because heat moves ”downhill” from high to low temperature, the fl ow in (a) is from left to right in the positive i direction. However, due to the ori- entation of Cartesian coordinates, the slope is negative for this case. Thus, a negative gradient leads to a positive fl ow. This is the origin of the minus sign in Fourier’s law of heat conduction. The reverse case is depicted in (b), where the positive gradient leads to a negative heat fl ow from right to left.

T

i

(b)(a)

Direction of

heat flow

T

i

Direction of

heat flow

­T

­i ! 0

­T

­i ” 0

29.2 SOLUTION TECHNIQUE 855

29.2.1 The Laplacian Difference Equation

Central differences based on the grid scheme from Fig. 29.3 are (recall Fig. 23.3)

0 2T

0x2 5

Ti11, j 2 2Ti, j 1 Ti21, j

¢x2

and

0 2T

0y2 5

Ti, j11 2 2Ti, j 1 Ti, j21

¢y2

which have errors of O[D(x)2] and O[D(y)2], respectively. Substituting these expressions

into Eq. (29.6) gives

Ti11, j 2 2Ti, j 1 Ti21, j

¢x2 1

Ti, j11 2 2Ti, j 1 Ti, j21

¢y2 5 0

For the square grid in Fig. 29.3, Dx 5 Dy, and by collection of terms, the equation

becomes

Ti11, j 1 Ti21, j 1 Ti, j11 1 Ti, j21 2 4Ti, j 5 0 (29.8)

This relationship, which holds for all interior points on the plate, is referred to as the

Laplacian difference equation.

In addition, boundary conditions along the edges of the plate must be speci” ed to obtain

a unique solution. The simplest case is where the temperature at the boundary is set at a ” xed

value. This is called a Dirichlet boundary condition. Such is the case for Fig. 29.4, where

FIGURE 29.3 A grid used for the fi nite-difference solution of elliptic PDEs in two independent variables such as the Laplace equation.

y

x

i – 1, j i + 1, j

0, n + 1 m + 1, n + 1

m + 1, 0

i, j – 1

i, j + 1

0, 0

i, j

856 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

the edges are held at constant temperatures. For the case illustrated in Fig. 29.4, a balance

for node (1, 1) is, according to Eq. (29.8),

T21 1 T01 1 T12 1 T10 2 4T11 5 0 (29.9)

However, T01 5 75 and T10 5 0, and therefore, Eq. (29.9) can be expressed as

24T11 1 T12 1 T21 5 275

Similar equations can be developed for the other interior points. The result is the

following set of nine simultaneous equations with nine unknowns:

4T11 2T21 2T12 5 75

2T11 14T21 2T31 2T22 5 0

2T21 14T31 2T32 5 50

2T11 14T12 2T22 2T13 5 75

2T21 2T12 14T22 2T32 2T23 5 0

2T31 2T22 14T32 2T33 5 50

2T12 14T13 2T23 5 175

2T22 2T13 14T23 2T33 5 100

2T32 2T23 14T33 5 150

(29.10)

29.2.2 The Liebmann Method

Most numerical solutions of the Laplace equation involve systems that are much larger

than Eq. (29.10). For example, a 10-by-10 grid involves 100 linear algebraic equations.

Solution techniques for these types of equations were discussed in Part Three.

FIGURE 29.4 A heated plate where boundary temperatures are held at constant levels. This case is called a Dirichlet boundary condition.

(1, 3) (2, 3) (3, 3)

(1, 2) (2, 2) (3, 2)

(1, 1) (2, 1) (3, 1)

100#C

0#C

75#C 50#C

29.2 SOLUTION TECHNIQUE 857

Notice that there are a maximum of ” ve unknown terms per line in Eq. (29.10). For

larger-sized grids, this means that a signi” cant number of the terms will be zero. When

applied to such sparse systems, full-matrix elimination methods waste great amounts of

computer memory storing these zeros. For this reason, approximate methods provide a

viable approach for obtaining solutions for elliptical equations. The most commonly

employed approach is Gauss-Seidel, which when applied to PDEs is also referred to as

Liebmann’s method. In this technique, Eq. (29.8) is expressed as

Ti, j 5 Ti11, j 1 Ti21, j 1 Ti, j11 1 Ti, j21

4 (29.11)

and solved iteratively for j 5 1 to n and i 5 1 to m. Because Eq. (29.8) is diagonally

dominant, this procedure will eventually converge on a stable solution (recall Sec. 11.2.1).

Overrelaxation is sometimes employed to accelerate the rate of convergence by applying

the following formula after each iteration:

T newi, j 5 lT new i, j 1 (1 2 l)T

old i, j (29.12)

where T newi, j and T old i, j are the values of Ti, j from the present and the previous iteration,

respectively, and l is a weighting factor that is set between 1 and 2.

As with the conventional Gauss-Seidel method, the iterations are repeated until the

absolute values of all the percent relative errors (ea)i, j fall below a prespeci” ed stopping

criterion es. These percent relative errors are estimated by

Z (ea)i, j Z 5 ` T new i, j 2 T

old i, j

T newi, j ` 100% (29.13)

EXAMPLE 29.1 Temperature of a Heated Plate with Fixed Boundary Conditions

Problem Statement. Use Liebmann’s method (Gauss-Seidel) to solve for the tempera- ture of the heated plate in Fig. 29.4. Employ overrelaxation with a value of 1.5 for the

weighting factor and iterate to es 5 1%.

Solution. Equation (29.11) at i 5 1, j 5 1 is

T11 5 0 1 75 1 0 1 0

4 5 18.75

and applying overrelaxation yields

T11 5 1.5(18.75) 1 (1 2 1.5)0 5 28.125

For i 5 2, j 5 1,

T21 5 0 1 28.125 1 0 1 0

4 5 7.03125

T21 5 1.5(7.03125) 1 (1 2 1.5)0 5 10.54688

For i 5 3, j 5 1,

T31 5 50 1 10.54688 1 0 1 0

4 5 15.13672

858 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

T31 5 1.5(15.13672) 1 (1 2 1.5)0 5 22.70508

The computation is repeated for the other rows to give

T12 5 38.67188 T22 5 18.45703 T32 5 34.18579

T13 5 80.12696 T23 5 74.46900 T33 5 96.99554

Because all the Ti, j’s are initially zero, all ea’s for the ” rst iteration will be 100%.

For the second iteration the results are

T11 5 32.51953 T21 5 22.35718 T31 5 28.60108

T12 5 57.95288 T22 5 61.63333 T32 5 71.86833

T13 5 75.21973 T23 5 87.95872 T32 5 67.68736

The error for T1,1 can be estimated as [Eq. (29.13)]

Z (ea)1, 1 Z 5 ` 32.51953 2 28.12500 32.51953

` 100% 5 13.5% Because this value is above the stopping criterion of 1%, the computation is continued.

The ninth iteration gives the result

T11 5 43.00061 T21 5 33.29755 T31 5 33.88506

T12 5 63.21152 T22 5 56.11238 T32 5 52.33999

T13 5 78.58718 T23 5 76.06402 T33 5 69.71050

where the maximum error is 0.71%.

Figure 29.5 shows the results. As expected, a gradient is established as heat ! ows

from high to low temperatures.

FIGURE 29.5 Temperature distribution for a heated plate subject to fi xed boundary conditions.

78.59 76.06 69.71

63.21 56.11 52.34

43.00 33.30 33.89

100#C

0#C

75#C 50#C

29.2 SOLUTION TECHNIQUE 859

29.2.3 Secondary Variables

Because its distribution is described by the Laplace equation, temperature is considered to

be the primary variable in the heated-plate problem. For this case, as well as for other

problems involving PDEs, secondary variables may also be of interest. As a matter of fact,

in certain engineering contexts, the secondary variable may actually be more important.

For the heated plate, a secondary variable is the rate of heat ! ux across the plate’s

surface. This quantity can be computed from Fourier’s law. Central ” nite-difference ap-

proximations for the ” rst derivatives (recall Fig. 23.3) can be substituted into Eq. (29.4)

to give the following values for heat ! ux in the x and y dimensions:

qx 5 2k¿ Ti11, j 2 Ti21, j

2 ¢x (29.14)

and

qy 5 2k¿ Ti, j11 2 Ti, j21

2 ¢y (29.15)

The resultant heat ! ux can be computed from these two quantities by

qn 5 2q2x 1 q2y (29.16) where the direction of qn is given by

u 5 tan21 aqy qx b (29.17)

for qx . 0 and

u 5 tan21 aqy qx b 1 p (29.18)

for qx , 0. Recall that the angle can be expressed in degrees by multiplying it by 1808/p.

If qx 5 0, u is py2 (908) or 3py2 (2708), depending on whether qy is positive or negative, respectively.

EXAMPLE 29.2 Flux Distribution for a Heated Plate

Problem Statement. Employ the results of Example 29.1 to determine the distribution of heat ! ux for the heated plate from Fig. 29.4. Assume that the plate is 40 3 40 cm

and is made out of aluminum [k9 5 0.49 cal/(s ? cm ? 8C)].

Solution. For i 5 j 5 1, Eq. (29.14) can be used to compute

qx 5 20.49 cal

s # cm # °C (33.29755 2 75)°C

2(10 cm) 5 1.022 cal/ (cm2 # s)

and [Eq. (29.15)]

qy 5 20.49 cal

s # cm # °C (63.21152 2 0)°C

2(10 cm) 5 21.549 cal/ (cm2 # s)

860 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

The resultant ! ux can be computed with Eq. (29.16):

qn 5 2(1.022)2 1 (21.549)2 5 1.856 cal/ (cm2 # s) and the angle of its trajectory by Eq. (29.17)

u 5 tan21 a21.549 1.022

b 5 20.98758 3 180° p

5 256.584°

Thus, at this point, the heat ! ux is directed down and to the right. Values at the other

grid points can be computed; the results are displayed in Fig. 29.6.

29.3 BOUNDARY CONDITIONS

Because it is free of complicating factors, the rectangular plate with ” xed boundary condi-

tions has been an ideal context for showing how elliptic PDEs can be solved numerically.

We will now elaborate on other issues that will expand our capabilities to address more

realistic problems. These involve boundaries at which the derivative is speci” ed and bound-

aries that are irregularly shaped.

29.3.1 Derivative Boundary Conditions

The ” xed or Dirichlet boundary condition discussed to this point is but one of several types

that are used with partial differential equations. A common alternative is the case where

FIGURE 29.6 Heat fl ux for a plate subject to fi xed boundary temperatures. Note that the lengths of the arrows are proportional to the magnitude of the fl ux.

100#C

0#C

75#C 50#C

29.3 BOUNDARY CONDITIONS 861

the derivative is given. This is commonly referred to as a Neumann boundary condition.

For the heated-plate problem, this amounts to specifying the heat ! ux rather than the tem-

perature at the boundary. One example is the situation where the edge is insulated. In this

case, the derivative is zero. This conclusion is drawn directly from Eq. (29.4) because

insulating a boundary means that the heat ! ux (and consequently the gradient) must be

zero. Another example would be where heat is lost across the edge by predictable mecha-

nisms such as radiation or convection.

Figure 29.7 depicts a node (0, j) at the left edge of a heated plate. Applying Eq. (29.8)

at the point gives

T1, j 1 T21, j 1 T0, j11 1 T0, j21 2 4T0, j 5 0 (29.19)

Notice that an imaginary point (21, j) lying outside the plate is required for this equa-

tion. Although this exterior ” ctitious point might seem to represent a problem, it actually

serves as the vehicle for incorporating the derivative boundary condition into the prob-

lem. This is done by representing the ” rst derivative in the x dimension at (0, j) by the

” nite divided difference

0T

0x >

T1, j 2 T21, j

2 ¢x

which can be solved for

T21, j 5 T1, j 2 2 ¢x 0T

0x

Now we have a relationship for T2l, j that actually includes the derivative. It can be sub-

stituted into Eq. (29.19) to give

2T1, j 2 2 ¢x 0T

0x 1 T0, j11 1 T0, j21 2 4T0, j 5 0 (29.20)

Thus, we have incorporated the derivative into the balance.

Similar relationships can be developed for derivative boundary conditions at the

other edges. The following example shows how this is done for the heated plate.

EXAMPLE 29.3 Heated Plate with an Insulated Edge

Problem Statement. Repeat the same problem as in Example 29.1, but with the lower edge insulated.

Solution. The general equation to characterize a derivative at the lower edge (that is, at j 5 0) of a heated plate is

Ti11, 0 1 Ti21, 0 1 2Ti, 1 2 2 ¢y 0T

0y 2 4Ti, 0 5 0

For an insulated edge, the derivative is zero and the equation becomes

Ti11, 0 1 Ti21, 0 1 2Ti, 1 2 4Ti, 0 5 0

T0, j + 1

T0, j – 1

T–1, j T0, j T1, j

FIGURE 29.7 A boundary node (0, j) on the left edge of a heated plate. To approximate the derivative nor- mal to the edge (that is, the x derivative), an imaginary point (21, j) is located a distance Dx beyond the edge.

862 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

The simultaneous equations for temperature distribution on the plate in Fig. 29.4 with

an insulated lower edge can be written in matrix form as

4 21 22

21 4 21 22

21 4 22

21 4 21 21

21 21 4 21 21

21 21 4 21 21

21 4 21 21

21 21 4 21 21

21 21 4 21

21 4 21

21 21 4 21

21 21 4

T10

T20

T30

T11

T21

T31

T12

T22

T32

T13

T23

T33

5

75

0

50

75

0

50

75

0

50

175

100

150

Note that because of the derivative boundary condition, the matrix is increased to 12 3 12

in contrast to the 9 3 9 system in Eq. (29.10) to account for the three unknown

temperatures along the plate’s lower edge. These equations can be solved for

T10 5 71.91 T20 5 67.01 T30 5 59.54

T11 5 72.81 T21 5 68.31 T31 5 60.57

T12 5 76.01 T22 5 72.84 T32 5 64.42

T13 5 83.41 T23 5 82.63 T33 5 74.26

75

75

75

75

50

50

50

50

100 100 100

83.4 82.6 74.3

76.0 72.8 64.4

72.8 68.3 60.6

71.9 67.0 59.5

Insulated

FIGURE 29.8 Temperature and fl ux distribution for a heated plate subject to fi xed boundary conditions except for an insulated lower edge.

29.3 BOUNDARY CONDITIONS 863

These results and computed ! uxes (for the same parameters as in Example 29.2) are

displayed in Fig. 29.8. Note that, because the lower edge is insulated, the plate’s tem-

perature is higher than for Fig. 29.5, where the bottom edge temperature is ” xed at zero.

In addition, the heat ! ow (in contrast to Fig. 29.6) is now de! ected to the right and

moves parallel to the insulated wall.

29.3.2 Irregular Boundaries

Although the rectangular plate from Fig. 29.4 has served well to illustrate the fundamental

aspects of solving elliptic PDEs, many engineering problems do not exhibit such an ideal-

ized geometry. For example, a great many systems have irregular boundaries (Fig. 29.9).

Figure 29.9 is a system that can serve to illustrate how nonrectangular boundaries

can be handled. As depicted, the plate’s lower left boundary is circular. Notice that we

have af” xed parameters—a1, a2, b1, b2—to each of the lengths surrounding the node.

Of course, for the plate depicted in Fig. 29.9, a2 5 b2 5 1. However, we will retain

these parameters throughout the following derivation so that the resulting equation is

generally applicable to any irregular boundary—not just one on the lower left-hand corner

of a heated plate. The ” rst derivatives in the x dimension can be approximated as

a 0T 0x b

i21, i

> Ti, j 2 Ti21, j

a1 ¢x (29.21)

and

a 0T 0x b

i, i11

> Ti11, j 2 Ti, j

a2 ¢x (29.22)

FIGURE 29.9 A grid for a heated plate with an irregularly shaped boundary. Note how weighting coeffi cients are used to account for the nonuniform spacing in the vicinity of the nonrectangular boundary.

b2 y

b1 y

a1 x a2 x

864 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

The second derivatives can be developed from these ” rst derivatives. For the x dimension,

the second derivative is

0 2T

0x2 5 0

0x a 0T 0x b 5 a 0T 0x b

i, i11

2 a 0T 0x b

i21, i

a1 ¢x 1 a2 ¢x

2

(29.23)

Substituting Eqs. (29.21) and (29.22) into (29.23) gives

0 2T

0x2 5 2

Ti21, j 2 Ti, j

a1 ¢x 2

Ti11, j 2 Ti, j

a2 ¢x

a1 ¢x 1 a2 ¢x

Collecting terms yields

0 2T

0x2 5

2

¢x2 c Ti21, j 2 Ti, j a1(a1 1 a2)

1 Ti11, j 2 Ti, j

a2(a1 1 a2) d

A similar equation can be developed in the y dimension:

0 2T

0y2 5

2

¢y2 c Ti, j21 2 Ti, j b1(b1 1 b2)

1 Ti, j11 2 Ti, j

b2(b1 1 b2) d

Substituting these equations in Eq. (29.6) yields

2

¢x2 c Ti21, j 2 Ti, j a1(a1 1 a2)

1 Ti11, j 2 Ti, j

a2(a1 1 a2) d

1 2

¢y2 c Ti, j21 2 Ti, j b1(b1 1 b2)

1 Ti, j11 2 Ti, j

b2(b1 1 b2) d 5 0 (29.24)

As illustrated in the following example, Eq. (29.24) can be applied to any node that lies

adjacent to an irregular, Dirichlet-type boundary.

EXAMPLE 29.4 Heated Plate with an Irregular Boundary

Problem Statement. Repeat the same problem as in Example 29.1, but with the lower edge as depicted in Fig. 29.9.

Solution. For the case in Fig. 29.9, Dx 5 Dy, a1 5 b1 5 0.732, and a2 5 b2 5 1. Substituting these values into Eq. (29.24) yields the following balance for node (1, 1):

0.788675(T01 2 T11) 1 0.57735(T21 2 T11)

1 0.788675(T10 2 T11) 1 0.57735(T12 2 T11) 5 0

Collecting terms, we can express this equation as

24T11 1 0.8453T21 1 0.8453T12 5 21.1547T01 2 1.1547T10

29.3 BOUNDARY CONDITIONS 865

The simultaneous equations for temperature distribution on the plate in Fig. 29.9 with a

lower-edge boundary temperature of 75 can be written in matrix form as

4 20.845 20.845

21 4 21 21

21 4 21

21 4 21 21

21 21 4 21 21

21 21 4 21

21 4 21

21 21 4 21

21 21 24

T11

T21

T31

T12

T22

T32

T13

T23

T33

5

173.2

75

125

75

0

50

175

100

150

These equations can be solved for

T11 5 74.98 T21 5 72.76 T31 5 66.07

T12 5 74.23 T22 5 75.00 T32 5 66.52

T13 5 83.93 T23 5 83.48 T33 5 75.00

These results along with the computed ! uxes are displayed in Fig. 29.10. Note that

the ! uxes are computed in the same fashion as in Sec. 29.2.3, with the exception that

(a1 1 a2) and (b1 1 b2) are substituted for the 2’s in the denominators of Eqs. (29.14)

and (29.15), respectively. Section 32.3 illustrates how this is done.

83.93 83.48 75.00

77.23 75.00 66.52

74.98 72.76 66.07

100#C

75#C

75#C 50#C

FIGURE 29.10 Temperature and fl ux distribution for a heated plate with a circular boundary.

866 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

Derivative conditions for irregularly shaped boundaries are more dif” cult to formu-

late. Figure 29.11 shows a point near an irregular boundary where the normal derivative

is speci” ed.

The normal derivative at node 3 can be approximated by the gradient between nodes

1 and 7,

0T

0h ` 3

5 T1 2 T7

L17 (29.25)

When u is less than 458 as shown, the distance from node 7 to 8 is Dx tan u, and linear

interpolation can be used to estimate

T7 5 T8 1 (T6 2 T8) ¢x tan u

¢y

The length L17 is equal to Dxycos u. This length, along with the approximation for T7, can be substituted into Eq. (29.25) to give

T1 5 a ¢x cos u

b 0T 0h ` 3

1 T6 ¢x tan u

¢y 1 T8 a1 2 ¢x tan u

¢y b (29.26)

Such an equation provides a means for incorporating the normal gradient into the

” nite-difference approach. For cases where u is greater than 458, a different equation

would be used. The determination of this formula will be left as a homework exercise.

29.4 THE CONTROL-VOLUME APPROACH

To summarize, the  nite-difference or Taylor series approach divides the continuum into

nodes (Fig. 29.12a). The underlying partial differential equation is written for each of

these nodes. Finite-difference approximations are then substituted for the derivatives to

convert the equations to an algebraic form.

x

y

u

8

7

6 5

1 4

3

2

FIGURE 29.11 A curved boundary where the normal gradient is specifi ed.

29.4 THE CONTROL-VOLUME APPROACH 867

Such an approach is quite simple and straightforward for orthogonal (that is, rect-

angular) grids and constant coef cients. However, the approach becomes a more dif cult

endeavor for derivative conditions on irregularly shaped boundaries.

Figure 29.13 is an example of a system where additional dif culties arise. This plate

is made of two different materials and has unequal grid spacing. In addition, half of its

top edge is subject to convective heat transfer, whereas half is insulated. Developing

equations for node (4, 2) would require some additional derivation beyond the approaches

developed to this point.

FIGURE 29.12 Two different perspectives for developing approximate solutions of PDEs: (a) fi nite-difference and (b) control-volume.

(a) Pointwise, finite-difference approach

(b) Control-volume approach

FIGURE 29.13 A heated plate with unequal grid spacing, two materials, and mixed boundary conditions.

Convection Insulated

In s u

la te

d

(4, 2)

h h/2

h

(1, 1)

Material A Material B

z

868 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

The control-volume approach (also called the volume-integral approach) offers an

alternative way to numerically approximate PDEs that is especially useful for cases such

as Fig. 29.13. As in Fig. 29.12b, the approach resembles the pointwise approach in that

points are determined across the domain. However, rather than approximating the PDE

at a point, the approximation is applied to a volume surrounding the point. For an or-

thogonal grid, the volume is formed by the perpendicular lines through the midpoint of

each line joining adjacent nodes. A heat balance can then be developed for each volume

in a fashion similar to Eq. (29.1).

As an example, we will apply the control-volume approach to node (4, 2). First,

the volume is de ned by bisecting the lines joining the nodes. As in Fig. 29.14, the

volume has conductive heat transfer through its left, right, and lower boundaries and

convective heat transfer through half of its upper boundary. Notice that the transfer

through the lower boundary involves both materials.

A steady-state heat balance for the volume can be written in qualitative terms as

0 5 a left-side conduction

b 2 a right-side conduction

b 1 alower conduction material “a”

b

1 alower conduction material “b”

b 2 a upper convection

b (29.27) Now the conduction ! ux rate can be represented by the  nite-difference version of

Fourier’s law. For example, for the left-side conduction gain, it would be

q 5 2k¿a T42 2 T41

h

where q has units of cal/cm2/s. This ! ux rate must be then multiplied by the area across

which it enters (Dz 3 hy2) to give the rate of heat entering the volume per unit time,

Q 5 2k¿a T42 2 T41

h h

2 ¢z

where Q has units of cal/s.

h/2

h/2 h/4

4, 1 4, 2 4, 3

3, 2

FIGURE 29.14 A control volume for node (4, 2) with arrows indicating heat transfer through the boundaries.

29.5 SOFTWARE TO SOLVE ELLIPTIC EQUATIONS 869

The heat ! ux due to convection can be formulated as

q 5 hc (Ta 2 T42)

where hc 5 a heat convection coef cient [cal/(s ? cm 2 ? 8C)] and Ta 5 the air temperature

(8C). Again, multiplication by the proper area yields the rate of heat ! ow per time,

Q 5 hc(Ta 2 T42) h

4 ¢z

The other transfers can be developed in a similar fashion and substituted into Eq. (29.27)

to yield

0 5 2k¿a T42 2 T41

h h

2 ¢z 1 k¿b

T43 2 T42

hy2 h

2 ¢z

(left-side conduction)(right-side conduction)

2k¿a T42 2 T32

h h

2 ¢z 2 k¿b

T42 2 T32

h h

4 ¢z 1 hc(Ta 2 T42)

h

4 ¢z

alower conductionb alower conductionb (upper convection) material “a” material “b”

Parameter values can then be substituted to yield the  nal heat balance equation. For ex-

ample, if Dz 5 0.5 cm, h 5 10 cm, k9a 5 0.3 cal/(s ? cm ? 8C), k9b 5 0.5 cal/(s ? cm ? 8C),

and hc 5 0.1 cal/(s ? cm 2 ? 8C), the equation becomes

0.5875T42 2 0.075T41 2 0.25T43 2 0.1375T32 5 2.5

To make the equation comparable to the standard Laplacian, this equation can be mul-

tiplied by 4y0.5875 so that the coef cient of the base node has a coef cient of 4,

4T42 2 0.510638T41 2 1.702128T43 2 0.93617T32 5 17.02128

For the standard cases covered to this point, the control-volume and pointwise  nite-

difference approaches yield identical results. For example, for node (1, 1) in Fig. 29.13,

the balance would be

0 52k¿a T11 2 T01

h h ¢z 1 k¿a

T21 2 T11

h h ¢z 2 k¿a

T11 2 T10

h h ¢z 1 k¿a

T12 2 T11

h h ¢z

which simpli es to the standard Laplacian,

0 5 4T11 2 T01 2 T21 2 T12 2 T10

We will look at other standard cases (for example, the derivative boundary condition)

and explore the control-volume approach in additional detail in the problems at the end

of this chapter.

29.5 SOFTWARE TO SOLVE ELLIPTIC EQUATIONS

Modifying a computer program to include derivative boundary conditions for rectangular

systems is a relatively straightforward task. It merely involves ensuring that additional

equations are generated to characterize the boundary nodes at which the derivatives are

speci ed. In addition, the code must be modi ed so that these equations incorporate the

derivative as seen in Eq. (29.20).

870 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

Developing general software to characterize systems with irregular boundaries is a

much more dif cult proposition. For example, a fairly involved algorithm would be re-

quired to model the simple gasket depicted in Fig. 29.15. This would involve two major

modi cations. First, a scheme would have to be developed to conveniently input the con-

 guration of the nodes and to identify which were at the boundary. Second, an algorithm

would be required to generate the proper simultaneous equations on the basis of the input

information. The net result is that general software for solving elliptic (and for that matter,

all) PDEs is relatively complicated.

One method used to simplify such efforts is to require a very  ne grid. For such cases,

it is often assumed that the closest node serves as the boundary point. In this way, the

analysis does not have to consider the weighting parameters from Sec. 29.3.2. Although

this introduces some error, the use of a suf ciently  ne mesh can make the resulting dis-

crepancy negligible. However, this involves a trade-off due to the computational burden

introduced by the increased number of simultaneous equations.

As a consequence of these considerations, numerical analysts have developed alterna-

tive approaches that differ radically from  nite-difference methods. Although these  nite-

element methods are more conceptually dif cult, they can much more easily accommodate

irregular boundaries. We will turn to these methods in Chap. 31. Before doing this, how-

ever, we will  rst describe  nite-difference approaches for another category of PDEs—

parabolic equations.

FIGURE 29.15 A fi nite-difference grid superimposed on an irregularly shaped gasket.

PROBLEMS

29.1 Use Liebmann’s method to solve for the temperature of the

square heated plate in Fig. 29.4, but with the upper boundary condi-

tion increased to 1508C and the left boundary insulated. Use a re-

laxation factor of 1.2 and iterate to es 5 1%.

29.2 Use Liebmann’s method to solve for the temperature of the

square heated plate in Fig. 29.4, but with the upper boundary condi-

tion increased to 1208C and the left boundary decreased to 608C.

Use a relaxation factor of 1.2 and iterate to es 5 1%.

29.3 Compute the ! uxes for Prob. 29.2 using the parameters from

Example 29.3.

29.4 Repeat Example 29.1, but use 49 interior nodes (that is, Dx 5

Dy 5 5 cm).

PROBLEMS 871

29.5 Repeat Prob. 29.4, but for the case where the lower edge is

insulated.

29.6 Repeat Examples 29.1 and 29.3, but for the case where the ! ux

at the lower edge is directed downward with a value of 2 cal/cm2 ? s.

29.7 Repeat Example 29.4 for the case where both the lower left

and the upper right corners are rounded in the same fashion as the

lower left corner of Fig. 29.9. Note that all boundary temperatures

on the upper and right sides are  xed at 1008C and all on the lower

and left sides are  xed at 508C.

29.8 With the exception of the boundary conditions, the plate in

Fig. P29.8 has the exact same characteristics as the plate used in

Examples 29.1 through 29.3. Simulate both the temperatures and

! uxes for the plate.

29.9 Write equations for the darkened nodes in the grid in Fig.

P29.9. Note that all units are cgs. The coef cient of thermal con-

ductivity for the plate is 0.75 cal/(s ? cm ? 8C), the convection coef-

 cient is hc 5 0.015 cal/(cm 2 ? C ? s), and the thickness of the plate

is 0.5 cm.

29.10 Write equations for the darkened nodes in the grid in

Fig. P29.10. Note that all units are cgs. The convection coeffi-

cient is hc 5 0.01 cal/(cm 2 ? C ? s) and the thickness of the plate

is 2 cm.

29.11 Apply the control-volume approach to develop the equation

for node (0, j) in Fig. 29.7.

29.12 Derive an equation like Eq. (29.26) for the case where u is

greater than 458 for Fig. 29.11.

29.13 Develop a user-friendly computer program to implement

Liebmann’s method for a rectangular plate with Dirichlet bound-

ary conditions. Design the program so that it can compute both

temperature and ! ux. Test the program by duplicating the results

of Examples 29.1 and 29.2.

29.14 Employ the program from Prob. 29.13 to solve Probs. 29.2

and 29.3.

29.15 Employ the program from Prob 29.13 to solve Prob. 29.4.

29.16 Use the control-volume approach and derive the node equa-

tion for node (2, 2) in Fig. 29.13 and include a heat source at this

point. Use the following values for the constants: Dz 5 0.25 cm,

h 5 10 cm, kA 5 0.25 W/cm ? C, and kB 5 0.45 W/cm ? C. The heat

source comes only from material A at the rate of 5 6 W/cm3.

29.17 Calculate heat ! ux (W/cm2) for node (2, 2) in Fig. 29.13 us-

ing  nite-difference approximations for the temperature gradients

0 25 50 75 100

75

50

25

0 Insulated

In s u

la te

d

FIGURE P29.8

i = 0 1 2 3 4 5

Dirichlet, T = 100!C

0

1

2

j = 3

D ir

ic h

le t,

T =

5 0 !C

y = 30 x = 40

x = 20

y = 15

Convection, qy = –hc(Ta – T); Ta = 10!C

In s u

la te

d

Heat source, qz = 10 cal/cm 2/s

FIGURE P29.9

i = 0 1 2 3 4 0

1

j = 2

y

= 3

0 x = 40

x = 20

y

= 1

5

Insulated

k’ = 0.7 k’ = 0.5

qz = 10 cal/cm 2/s

C o

n v e c ti

o n

q x

= h

c( T

a –

T );

T a =

2 0 !C

FIGURE P29.10

872 FINITE DIFFERENCE: ELLIPTIC EQUATIONS

at this node. Calculate the ! ux in the horizontal direction in materi-

als A and B, and determine if these two ! uxes should be equal.

Also, calculate the vertical ! ux in materials A and B. Should these

two ! uxes be equal? Use the following values for the constants:

Dz 5 0.5 cm, h 5 10 cm, kA 5 0.25 W/cm ? C, kB 5 0.45 W/cm ? C,

and nodal temperatures: T22 5 51.68C, T21 5 74.28C, T23 5 45.38C,

T32 5 38.68C, and T12 5 87.48C.

29.18 Compute the temperature distribution for the L-shaped plate

in Fig. P29.18.

29.19 The Poisson equation can be written in three dimensions as

0 2T

0x2 1 0

2T

0y2 1 0

2T

0z2 5 f (x, y, z)

Solve for the distribution of temperature within a unit (1 3 1) cube

with zero boundary conditions and f 5 210. Employ Dx 5 Dy 5

Dz 5 1y6.

0

0

0

20

40

60

80

100

120

Insulated

Insulated

Insulated

FIGURE P29.18

30

873

C H A P T E R 30

Finite Difference: Parabolic Equations

Chapter 29 dealt with steady-state PDEs. We now turn to the parabolic equations that

are employed to characterize time-variable problems. In the latter part of this chapter,

we will illustrate how this is done in two spatial dimensions for the heated plate. Before

doing this, we will  rst show how the simpler one-dimensional case is approached.

30.1 THE HEAT-CONDUCTION EQUATION

In a fashion similar to the derivation of the Laplace equation [Eq. (29.6)], conservation

of heat can be used to develop a heat balance for the differential element in the long,

thin insulated rod shown in Fig. 30.1. However, rather than examine the steady-state case,

the present balance also considers the amount of heat stored in the element over a unit

time period Dt. Thus, the balance is in the form, inputs 2 outputs 5 storage, or

q(x) ¢y ¢z ¢t 2 q(x 1 ¢x) ¢y ¢z ¢t 5 ¢x ¢y ¢zrC ¢T

Dividing by the volume of the element (5 Dx Dy Dz) and Dt gives

q(x) 2 q(x 1 ¢x)

¢x 5 rC

¢T

¢t

Taking the limit yields

2 0q

0x 5 rC

0T

0t

FIGURE 30.1 A thin rod, insulated at all points except at its ends.

CoolHot

874 FINITE DIFFERENCE: PARABOLIC EQUATIONS

Substituting Fourier’s law of heat conduction [Eq. (29.4)] results in

k 0

2T

0x2 5 0T

0t (30.1)

which is the heat-conduction equation.

Just as with elliptic PDEs, parabolic equations can be solved by substituting  nite

divided differences for the partial derivatives. However, in contrast to elliptic PDEs, we

must now consider changes in time as well as in space. Whereas elliptic equations were

bounded in all relevant dimensions, parabolic PDEs are temporally open-ended (Fig. 30.2).

Because of their time-variable nature, solutions to these equations involve a number of

new issues, notably stability. This, as well as other aspects of parabolic PDEs, will be

examined in the following sections as we present two fundamental solution approaches—

explicit and implicit schemes.

30.2 EXPLICIT METHODS

The heat-conduction equation requires approximations for the second derivative in space

and the  rst derivative in time. The former is represented in the same fashion as for the

Laplace equation by a centered  nite-divided difference:

0 2T

0x2 5

T li11 2 2T l i 1 T

l i21

¢x2 (30.2)

FIGURE 30.2 A grid used for the fi nite-difference solution of parabolic PDEs in two independent variables such as the heat-conduction equation. Note how, in contrast to Fig. 29.3, this grid is open-ended in the temporal dimension.

t

x

i – 1, l i + 1, l

m + 1, 0

i, l – 1

i, l + 1

0, 0

i, l

30.2 EXPLICIT METHODS 875

which has an error (recall Fig. 23.3) of O[(Dx)2]. Notice the slight change in notation of

the superscripts is used to denote time. This is done so that a second subscript can be

used to designate a second spatial dimension when the approach is expanded to two

spatial dimensions.

A forward  nite-divided difference is used to approximate the time derivative

0T

0t 5

T l11i 2 T l i

¢t (30.3)

which has an error (recall Fig. 23.1) of O(Dt).

Substituting Eqs. (30.2) and (30.3) into Eq. (30.1) yields

k T li11 2 2T

l i 1 T

l i21

(¢x)2 5

T l11i 2 T l i

¢t (30.4)

which can be solved for

T l11i 5 T l i 1 l(T

l i11 2 2T

l i 1 T

l i21) (30.5)

where l 5 k Dty(Dx)2.

This equation can be written for all the interior nodes on the rod. It then provides

an explicit means to compute values at each node for a future time based on the present

values at the node and its neighbors. Notice that this approach is actually a manifestation

of Euler’s method for solving systems of ODEs. That is, if we know the temperature

distribution as a function of position at an initial time, we can compute the distribution

at a future time based on Eq. (30.5).

A computational molecule for the explicit method is depicted in Fig. 30.3, show-

ing the nodes that constitute the spatial and temporal approximations. This molecule

can be contrasted with others in this chapter to illustrate the differences between

approaches.

FIGURE 30.3 A computational molecule for the explicit form.

Grid point involved in time difference

Grid point involved in space difference

xi – 1 xi xi + 1

t l

t l + 1

876 FINITE DIFFERENCE: PARABOLIC EQUATIONS

EXAMPLE 30.1 Explicit Solution of the One-Dimensional Heat-Conduction Equation

Problem Statement. Use the explicit method to solve for the temperature distribution of a long, thin rod with a length of 10 cm and the following values: k9 5 0.49 cal/(s ? cm ? 8C),

Dx 5 2 cm, and Dt 5 0.1 s. At t 5 0, the temperature of the rod is zero and the bound-

ary conditions are  xed for all times at T(0) 5 1008C and T(10) 5 508C. Note that the

rod is aluminum with C 5 0.2174 cal/(g ? 8C) and r 5 2.7 g/cm3. Therefore, k 5 0.49/

(2.7 ? 0.2174) 5 0.835 cm2/s and l 5 0.835(0.1)y(2)2 5 0.020875.

Solution. Applying Eq. (30.5) gives the following value at t 5 0.1 s for the node at x 5 2 cm:

T 11 5 0 1 0.020875[0 2 2(0) 1 100] 5 2.0875

At the other interior points, x 5 4, 6, and 8 cm, the results are

T 12 5 0 1 0.020875[0 2 2(0) 1 0] 5 0

T 13 5 0 1 0.020875[0 2 2(0) 1 0] 5 0

T 14 5 0 1 0.020875[50 2 2(0) 1 0] 5 1.0438

At t 5 0.2 s, the values at the four interior nodes are computed as

T 21 5 2.0875 1 0.020875[0 2 2(2.0875) 1 100] 5 4.0878

T 22 5 0 1 0.020875[0 2 2(0) 1 2.0875] 5 0.043577

T 23 5 0 1 0.020875[1.0438 2 2(0) 1 0] 5 0.021788

T 24 5 1.0438 1 0.020875[50 2 2(1.0438) 1 0] 5 2.0439

The computation is continued, and the results at 3-s intervals are depicted in Fig. 30.4.

The general rise in temperature with time indicates that the computation captures the

diffusion of heat from the boundaries into the bar.

FIGURE 30.4 Temperature distribution in a long, thin rod as computed with the explicit method described in Sec. 30.2.

T

40

80

0 4 8 x

! t = 0.1

!x = 2

k = 0.835

t = 12

t = 9

t = 6t = 3

30.2 EXPLICIT METHODS 877

30.2.1 Convergence and Stability

Convergence means that as Dx and Dt approach zero, the results of the  nite-difference

technique approach the true solution. Stability means that errors at any stage of the

computation are not ampli ed but are attenuated as the computation progresses. It can

be shown (Carnahan et al., 1969) that the explicit method is both convergent and stable

if l # 1y2, or

¢t # 1

2 ¢x2

k (30.6)

In addition, it should be noted that setting l # 1y2 could result in a solution in which errors

do not grow, but oscillate. Setting l # 1y4 ensures that the solution will not oscillate. It is

also known that setting l 5 1y6 tends to minimize truncation error (Carnahan et al., 1969).

Figure 30.5 is an example of instability caused by violating Eq. (30.6). This plot is

for the same case as in Example 30.1 but with l 5 0.735, which is considerably greater

than 0.5. As in Fig. 30.5, the solution undergoes progressively increasing oscillations.

This situation will continue to deteriorate as the computation continues.

Although satisfaction of Eq. (30.6) will alleviate the instabilities of the sort mani-

fested in Fig. 30.5, it also places a strong limitation on the explicit method. For example,

suppose that Dx is halved to improve the approximation of the spatial second derivative.

According to Eq. (30.6), the time step must be quartered to maintain convergence and

stability. Thus, to perform comparable computations, the time steps must be increased

by a factor of 4. Furthermore, the computation for each of these time steps will take

twice as long because halving Dx doubles the total number of nodes for which equations

must be written. Consequently, for the one-dimensional case, halving Dx results in an

eightfold increase in the number of calculations. Thus, the computational burden may be

large to attain acceptable accuracy. As will be described shortly, other techniques are

available that do not suffer from such severe limitations.

30.2.2 Derivative Boundary Conditions

As was the case for elliptic PDEs (recall Sec. 29.3.1), derivative boundary conditions

can be readily incorporated into parabolic equations. For a one-dimensional rod, this

necessitates adding two equations to characterize the heat balance at the end nodes. For

example, the node at the left end (i 5 0) would be represented by

T l110 5 T l 0 1 l(T

l 1 2 2T

l 0 1 T

l 21)

Thus, an imaginary point is introduced at i 5 21 (recall Fig. 29.7). However, as with the

elliptic case, this point provides a vehicle for incorporating the derivative boundary condi-

tion into the analysis. Problem 30.2 at the end of the chapter deals with this exercise.

30.2.3 Higher-Order Temporal Approximations

The general idea of reexpressing the PDE as a system of ODEs is sometimes called the

method of lines. Obviously, one way to improve on the Euler approach used above would

be to employ a more accurate integration scheme for solving the ODEs. For example, the

Heun method can be employed to obtain second-order temporal accuracy. An example of

878 FINITE DIFFERENCE: PARABOLIC EQUATIONS

this approach is called MacCormack’s method. This and other improved explicit methods

are discussed elsewhere (for example, Hoffman, 1992).

30.3 A SIMPLE IMPLICIT METHOD

As noted previously, explicit  nite-difference formulations have problems related to stabil-

ity. In addition, as depicted in Fig. 30.6, they exclude information that has a bearing on

the solution. Implicit methods overcome both these dif culties at the expense of somewhat

more complicated algorithms.

FIGURE 30.5 An illustration of instability. Solution of Example 30.1 but with l 5 0.735.

T

100

0 x

t = 6

T

100

0 x

t = 12

T

100

0 x

t = 18

T

100

0 x

t = 24

T

100

0 0 4 8 x

t = 30

30.3 A SIMPLE IMPLICIT METHOD 879

The fundamental difference between explicit and implicit approximations is depicted

in Fig. 30.7. For the explicit form, we approximate the spatial derivative at time level l

(Fig. 30.7a). Recall that when we substituted this approximation into the partial differ-

ential equation, we obtained a difference equation (30.4) with a single unknown T l11i .

Thus, we can solve “explicitly” for this unknown as in Eq. (30.5).

In implicit methods, the spatial derivative is approximated at an advanced time level

l 1 1. For example, the second derivative would be approximated by (Fig. 30.7b)

0 2T

0x2 >

T l11i11 2 2T l11 i 1 T

l11 i21

(¢x)2 (30.7)

which is second-order accurate. When this relationship is substituted into the original

PDE, the resulting difference equation contains several unknowns. Thus, it cannot be

solved explicitly by simple algebraic rearrangement as was done in going from Eq. (30.4)

FIGURE 30.6 Representation of the effect of other nodes on the fi nite- difference approximation at node (i, I) using an explicit fi nite-difference scheme. The shaded nodes have an infl uence on (i, I), whereas the unshaded nodes, which in reality affect (i, I), are excluded.

t

x Initial condition

Boundary condition

(i, l)

FIGURE 30.7 Computational molecules demonstrating the fundamental differences between (a) explicit and (b) implicit methods.

Grid point involved in time difference

Grid point involved in space difference

i – 1 i i + 1

l

l + 1

(a) Explicit

i – 1 i i + 1

l

l + 1

(b) Implicit

880 FINITE DIFFERENCE: PARABOLIC EQUATIONS

to (30.5). Instead, the entire system of equations must be solved simultaneously. This is

possible because, along with the boundary conditions, the implicit formulations result in

a set of linear algebraic equations with the same number of unknowns. Thus, the method

reduces to the solution of a set of simultaneous equations at each point in time.

To illustrate how this is done, substitute Eqs. (30.3) and (30.7) into Eq. (30.1)

to give

k T l11i11 2 2T

l11 i 1 T

l11 i21

(¢x)2 5

T l11i 2 T l i

¢t

which can be expressed as

2lT l11i21 1 (1 1 2l)T l11 i 2 lT

l11 i11 5 T

l i (30.8)

where l 5 k Dty(Dx)2. This equation applies to all but the  rst and the last interior nodes,

which must be modi ed to re! ect the boundary conditions. For the case where the tem-

perature levels at the ends of the rod are given, the boundary condition at the left end

of the rod (i 5 0) can be expressed as

T l110 5 f0(t l11) (30.9)

where f0(t l11) 5 a function describing how the boundary temperature changes with time.

Substituting Eq. (30.9) into Eq. (30.8) gives the difference equation for the  rst interior

node (i 5 1):

(1 1 2l)T l111 2 lT l11 2 5 T

l 1 1 l f0(t

l11) (30.10)

Similarly, for the last interior node (i 5 m),

2lT l11m21 1 (1 1 2l)T l11 m 5 T

l m 1 l fm11(t

l11) (30.11)

where fm11(t l11) describes the speci ed temperature changes at the right end of the rod

(i 5 m 1 1).

When Eqs. (30.8), (30.10), and (30.11) are written for all the interior nodes, the

resulting set of m linear algebraic equations has m unknowns. In addition, the method

has the added bonus that the system is tridiagonal. Thus, we can utilize the extremely

ef cient solution algorithms (recall Sec. 11.1.1) that are available for tridiagonal

systems.

EXAMPLE 30.2 Simple Implicit Solution of the Heat-Conduction Equation

Problem Statement. Use the simple implicit  nite-difference approximation to solve the same problem as in Example 30.1.

Solution. For the rod from Example 30.1, l 5 0.020875. Therefore, at t 5 0, Eq. (30.10) can be written for the  rst interior node as

1.04175T 11 2 0.020875T 1 2 5 0 1 0.020875(100)

or

1.04175T 11 2 0.020875T 1 2 5 2.0875

30.3 A SIMPLE IMPLICIT METHOD 881

In a similar fashion, Eqs. (30.8) and (30.11) can be applied to the other interior nodes.

This leads to the following set of simultaneous equations:

≥ 1.04175 20.02087520.020875 1.04175 20.020875 20.020875 1.04175 20.020875

20.020875 1.04175

¥ µ T 1 1

T 2 1

T 3 1

T 4 1

∂5 µ 2.08750 0

1.04375

∂ which can be solved for the temperature at t 5 0.1 s:

T 11 5 2.0047

T 12 5 0.0406

T 13 5 0.0209

T 14 5 1.0023

Notice how in contrast to Example 30.1, all the points have changed from the initial con-

dition during the  rst time step.

To solve for the temperatures at t 5 0.2, the right-hand-side vector must be modi ed

to account for the results of the  rst step, as in

µ 4.092150.04059 0.02090

2.04069

∂ The simultaneous equations can then be solved for the temperatures at t 5 0.2 s:

T 21 5 3.9305

T 22 5 0.1190

T 23 5 0.0618

T 24 5 1.9653

Whereas the implicit method described is stable and convergent, it has the defect

that the temporal difference approximation is  rst-order accurate, whereas the spatial

difference approximation is second-order accurate (Fig. 30.8). In the next section we

present an alternative implicit method that remedies the situation.

Before proceeding, it should be mentioned that, although the simple implicit method

is unconditionally stable, there is an accuracy limit to the use of large time steps. Con-

sequently, it is not that much more ef cient than the explicit approaches for most time-

variable problems.

Where it does shine is for steady-state problems. Recall from Chap. 29 that a form

of Gauss-Seidel (Liebmann’s method) can be used to obtain steady-state solutions for

elliptic equations. An alternative approach would be to run a time-variable solution until

it reached a steady state. In such cases, because inaccurate intermediate results are not an

issue, implicit methods allow you to employ larger time steps, and hence, can generate

steady-state results in an ef cient manner.

882 FINITE DIFFERENCE: PARABOLIC EQUATIONS

30.4 THE CRANK-NICOLSON METHOD

The Crank-Nicolson method provides an alternative implicit scheme that is second-order

accurate in both space and time. To provide this accuracy, difference approximations are

developed at the midpoint of the time increment (Fig. 30.9). To do this, the temporal  rst

derivative can be approximated at tl11y2 by

0T

0t >

T l11i 2 T l i

¢t (30.12)

The second derivative in space can be determined at the midpoint by averaging the dif-

ference approximations at the beginning (t l) and at the end (t l11) of the time increment

0 2T

0x2 >

1

2 c T li11 2 2T li 1 T li11

(¢x)2 1

T l11i11 2 2T l11 i 1 T

l11 i21

(¢x)2 d (30.13)

FIGURE 30.8 A computational molecule for the simple implicit method.

Grid point involved in time difference

Grid point involved in space difference

xi – 1 xi xi + 1

t l

t l + 1

FIGURE 30.9 A computational molecule for the Crank-Nicolson method.

Grid point involved in time difference

Grid point involved in space difference

xi – 1 xi xi + 1

t l

t l + 1

t l + 1/2

30.4 THE CRANK-NICOLSON METHOD 883

Substituting Eqs. (30.12) and (30.13) into Eq. (30.1) and collecting terms gives

2lT l11i21 1 2(1 1 l)T l11 i 2 lT

l11 i11 5 lT

l i21 1 2(1 2 l)T

l i 1 lT

l i11 (30.14)

where l 5 k Dty(Dx)2. As was the case with the simple implicit approach, boundary

conditions of T l110 5 f0(t l11) and T l11m11 5 fm11(t

l11) can be prescribed to derive versions of Eq. (30.14) for the  rst and the last interior nodes. For the  rst interior node

2(1 1 l)T l111 2 lT l11 2 5 l f0(t

l) 1 2(1 2 l)T l1 1 lT l 2 1 l f0(t

l11) (30.15)

and for the last interior node,

2lT l11m21 1 2(1 1 l)T l11 m 5 l fm11(t

l) 1 2(1 2 l)T lm 1 lT l m21 1 l fm11(t

l11) (30.16)

Although Eqs. (30.14) through (30.16) are slightly more complicated than Eqs. (30.8),

(30.10), and (30.11), they are also tridiagonal and, therefore, ef cient to solve.

EXAMPLE 30.3 Crank-Nicolson Solution to the Heat-Conduction Equation

Problem Statement. Use the Crank-Nicolson method to solve the same problem as in Examples 30.1 and 30.2.

Solution. Equations (30.14) through (30.16) can be employed to generate the following tridiagonal set of equations:

≥ 2.04175 20.02087520.020875 2.04175 20.020875 20.020875 2.04175 20.020875

20.020875 2.04175

¥ µ T 1 1

T 2 1

T 3 1

T 4 1

∂5 µ 4.1750 0

2.0875

∂ which can be solved for the temperatures at t 5 0.1 s:

T 11 5 2.0450

T 12 5 0.0210

T 13 5 0.0107

T 14 5 1.0225

To solve for the temperatures at t 5 0.2 s, the right-hand-side vector must be changed to

µ 8.18010.0841 0.0427

4.0901

∂ The simultaneous equations can then be solved for

T 21 5 4.0073

T 22 5 0.0826

T 23 5 0.0422

T 24 5 2.0036

884 FINITE DIFFERENCE: PARABOLIC EQUATIONS

30.4.1 Comparison of One-Dimensional Methods

Equation (30.1) can be solved analytically. For example, a solution is available for the case

where the rod’s temperature is initially at zero. At t 5 0, the boundary condition at x 5 L

is instantaneously increased to a constant level of T while T(0) is held at zero. For this case,

the temperature can be computed by

T 5 T c x L

1 a q

n50

2

np (21)n sin anx

L b exp a2n2p2kt

L2 b d (30.17)

where L 5 total length of the rod. This equation can be employed to compute the evolu-

tion of the temperature distribution for each boundary condition. Then, the total solution

can be determined by superposition.

EXAMPLE 30.4 Comparison of Analytical and Numerical Solutions

Problem Statement. Compare the analytical solution from Eq. (30.17) with numerical results obtained with the explicit, simple implicit, and Crank-Nicolson techniques. Per-

form the comparison for the rod employed in Examples 30.1, 30.2, and 30.3.

Solution. Recall from the previous examples that k 5 0.835 cm2/s, L 5 10 cm, and Dx 5 2 cm. For this case, Eq. (30.17) can be used to predict that the temperature at

x 5 2 cm, and t 5 10 s would equal 64.8018. Table 30.1 presents numerical predictions

of T(2, 10). Notice that a range of time steps are employed. These results indicate a

number of properties of the numerical methods. First, it can be seen that the explicit

method is unstable for high values of l. This instability is not manifested by either implicit

approach. Second, the Crank-Nicolson method converges more rapidly as l is decreased

and provides moderately accurate results even when l is relatively high. These outcomes

are as expected because Crank-Nicolson is second-order accurate with respect to both

independent variables. Finally, notice that as l decreases, the methods seem to be converg-

ing on a value of 64.73 that is different than the analytical result of 64.80. This should not

be surprising because a ! xed value of Dx 5 2 is used to characterize the x dimension. If

both Dx and Dt were decreased as l was decreased (that is, more spatial segments were

used), the numerical solution would more closely approach the analytical result.

TABLE 30.1 Comparison of three methods of solving a parabolic PDE: the heated rod. The results shown are for temperature at t 5 10 s at x 5 2 cm for the rod from Examples 30.1 through 30.3. Note that the analytical solution is T (2, 10) 5 64.8018.

Dt L Explicit Implicit Crank-Nicolson

10 2.0875 208.75 53.01 79.77 5 1.04375 29.13 58.49 64.79 2 0.4175 67.12 62.22 64.87 1 0.20875 65.91 63.49 64.77 0.5 0.104375 65.33 64.12 64.74 0.2 0.04175 64.97 64.49 64.73

30.5 PARABOLIC EQUATIONS IN TWO SPATIAL DIMENSIONS 885

The Crank-Nicolson method is often used for solving linear parabolic PDEs in one

spatial dimension. Its advantages become even more pronounced for more complicated

applications such as those involving unequally spaced meshes. Such nonuniform spacing

is often advantageous where we have foreknowledge that the solution varies rapidly in local

portions of the system. Further discussion of such applications and the Crank-Nicolson

method in general can be found elsewhere (Ferziger, 1981; Lapidus and Pinder, 1981;

Hoffman, 1992).

30.5 PARABOLIC EQUATIONS IN TWO SPATIAL DIMENSIONS

The heat-conduction equation can be applied to more than one spatial dimension. For

two dimensions, its form is

0T

0t 5 k a 02T

0x2 1 0

2T

0y2 b (30.18)

One application of this equation is to model the temperature distribution on the face of

a heated plate. However, rather than characterizing its steady-state distribution, as was

done in Chap. 29, Eq. (30.18) provides a means to compute the plate’s temperature

distribution as it changes in time.

30.5.1 Standard Explicit and Implicit Schemes

An explicit solution can be obtained by substituting ! nite-difference approximations of

the form of Eqs. (30.2) and (30.3) into Eq. (30.18). However, as with the one-dimensional

case, this approach is limited by a stringent stability criterion. For the two-dimensional

case, the criterion is

¢t # 1

8 (¢x)2 1 (¢y)2

k

Thus, for a uniform grid (Dx 5 Dy), l 5 kDty(Dx)2 must be less than or equal to 1y4.

Consequently, halving the step size results in a fourfold increase in the number of nodes

and a 16-fold increase in computational effort.

As was the case with one-dimensional systems, implicit techniques offer alternatives

that guarantee stability. However, the direct application of implicit methods such as the

Crank-Nicolson technique leads to the solution of m 3 n simultaneous equations. Addi-

tionally, when written for two or three spatial dimensions, these equations lose the valu-

able property of being tridiagonal. Thus, matrix storage and computation time can become

exorbitantly large. The method described in the next section offers one way around this

dilemma.

30.5.2 The ADI Scheme

The alternating-direction implicit, or ADI, scheme provides a means for solving parabolic

equations in two spatial dimensions using tridiagonal matrices. To do this, each time

886 FINITE DIFFERENCE: PARABOLIC EQUATIONS

increment is executed in two steps (Fig. 30.10). For the ! rst step, Eq. (30.18) is ap-

proximated by

T l11y2i, j 2 T l i, j

¢ty2 5 k c T li11, j 2 2T li, j 1 T li21, j

(¢x)2 1

T l11y2i, j11 2 2T l11y2 i, j 1 T

l11y2 i, j21

(¢y)2 d (30.19)

Thus, the approximation of 02Ty0x2 is written explicitly—that is, at the base point tl where

values of temperature are known. Consequently, only the three temperature terms in the

approximation of 02Ty0y2 are unknown. For the case of a square grid (Dy 5 Dx), this

equation can be expressed as

2lT l11y2i, j21 1 2(1 1 l)T l11y2 i, j 2 lT

l11y2 i, j11 5 lT

l i21, j 1 2(1 2 l)T

l i, j 1 lT

l i11, j

(30.20)

which, when written for the system, results in a tridiagonal set of simultaneous equations.

For the second step from t l11y2 to t l11, Eq. (30.18) is approximated by

T l11i, j 2 T l11y2 i, j

¢ty2 5 k c T l11i11, j 2 2T l11i, j 1 T l11i21, j

(¢x)2 1

T l11y2i, j11 2 2T l11y2 i, j 1 T

l11y2 i, j21

(¢y)2 d

(30.21)

In contrast to Eq. (30.19), the approximation of 02Ty0x2 is now implicit. Thus, the bias

introduced by Eq. (30.19) will be partially corrected. For a square grid, Eq. (30.21) can

be written as

2lT l11i21, j 1 2(1 1 l)T l11 i, j 2 lT

l11 i11, j 5 lT

l11y2 i, j21 1 2(1 2 l)T

l11y2 i, j 1 lT

l11y2 i, j11

(30.22)

Again, when written for a two-dimensional grid, the equation results in a tridiagonal

system (Fig. 30.11). As in the following example, this leads to an ef! cient numerical

solution.

FIGURE 30.10 The two half-steps used in implementing the alternating- direction implicit scheme for solving parabolic equations in two spatial dimensions.

yj + 1

yj – 1 xi – 1 xi xi + 1

t l + 1

t l + 1/2

t l

xi – 1 xi xi + 1

yj

yj + 1

yj – 1

yj

Explicit

Implicit

(a) First half-step (b) Second half-step

30.5 PARABOLIC EQUATIONS IN TWO SPATIAL DIMENSIONS 887

FIGURE 30.11 The ADI method only results in tridiagonal equations if it is applied along the dimension that is implicit. Thus, on the fi rst step (a), it is applied along the y dimension and, on the second step (b), along the x dimension. These “alternating directions” are the root of the method’s name.

(a) First direction (b) Second direction

i = 1 i = 1i = 2 i = 2

j = 3

j = 2

j = 1

i = 3 i = 3

y

x

EXAMPLE 30.5 ADI Method

Problem Statement. Use the ADI method to solve for the temperature of the plate in Examples 29.1 and 29.2. At t 5 0, assume that the temperature of the plate is zero and

the boundary temperatures are instantaneously brought to the levels shown in Fig. 29.4.

Employ a time step of 10 s. Recall from Example 30.1 that the coef! cient of thermal dif-

fusivity for aluminum is k 5 0.835 cm2/s.

Solution. A value of Dx 5 10 cm was employed to characterize the 40 3 40-cm plate from Examples 29.1 and 29.2. Therefore, l 5 0.835(10)y(10)2 5 0.0835. For the ! rst

step to t 5 5 (Fig. 30.11a), Eq. (30.20) is applied to nodes (1, 1), (1, 2), and (1, 3) to

yield the following tridiagonal equations:

£ 2.167 20.083520.0835 2.167 20.0835 20.0835 2.167

§ •T1,1T1,2 T1,3

¶ 5 • 6.26256.2625 14.6125

¶ which can be solved for

T1,1 5 3.01597 T1, 2 5 3.2708 T1, 3 5 6.8692

In a similar fashion, tridiagonal equations can be developed and solved for

T2,1 5 0.1274 T2, 2 5 0.2900 T2, 3 5 4.1291

and

T3,1 5 2.0181 T3, 2 5 2.2477 T3, 3 5 6.0256

For the second step to t 5 10 (Fig. 30.11b), Eq. (30.22) is applied to nodes (1, 1), (2, 1),

and (3, 1) to yield

£ 2.167 20.083520.0835 2.167 20.0835 20.0835 2.167

§ •T1,1T2,1 T3,1

¶ 5 •12.06390.2577 8.0619

888 FINITE DIFFERENCE: PARABOLIC EQUATIONS

which can be solved for

T1,1 5 5.5855 T2,1 5 0.4782 T3,1 5 3.7388

Tridiagonal equations for the other rows can be developed and solved for

T1, 2 5 6.1683 T2, 2 5 0.8238 T3, 2 5 4.2359

and

T1, 3 5 13.1120 T2, 3 5 8.3207 T3, 3 5 11.3606

The computation can be repeated, and the results for t 5 100, 200, and 300 s are

depicted in Fig. 30.12a through c, respectively. As expected, the temperature of the plate

rises. After a suf! cient time elapses, the temperature will approach the steady-state dis-

tribution of Fig. 29.5.

The ADI method is but one of a group of techniques called splitting methods. Some

of these represent efforts to circumvent shortcomings of ADI. Discussion of other splitting

methods as well as more information on ADI can be found elsewhere (Ferziger, 1981;

Lapidus and Pinder, 1981).

FIGURE 30.12 Solution for the heated plate from Example 30.5 at (a) t 5 100 s, (b) t 5 200 s, and (c) t 5 300 s.

28.56 14.57 20.73

41.09 27.20 31.94

60.76 52.57 53.02

(a) t = 100 s

37.40 25.72 28.69

55.26 45.32 44.86

72.82 68.17 64.12

(b) t = 200 s

40.82 30.43 31.96

60.30 52.25 49.67

76.54 73.29 67.68

(c) t = 300 s

PROBLEMS

30.1 Repeat Example 30.1, but use the midpoint method to gener-

ate your solution.

30.2 Repeat Example 30.1, but for the case where the rod is ini-

tially at 508C and the derivative at x 5 0 is equal to 1 and at x 5 10

is equal to 0. Interpret your results.

30.3 (a) Repeat Example 30.1, but for a time step of Dt 5 0.05 s.

Compute results to t 5 0.2. (b) In addition, perform the same com-

putation with the Heun method (without iteration of the corrector)

with a much smaller step size of Dt 5 0.001 s. Assuming that the

results of (b) are a valid approximation of the true solution, deter-

mine percent relative errors for the results obtained in Example

30.1 as well as for part (a).

30.4 Repeat Example 30.2, but for the case where the derivative at

x 5 10 is equal to zero.

30.5 Repeat Example 30.3, but for Dx 5 1 cm.

30.6 Repeat Example 30.5, but for the plate described in Prob. 29.2.

PROBLEMS 889

program to obtain the solution. Increase the value of ¢t by 10% for

each time step to more quickly obtain the steady-state solution, and

select values of ¢x and ¢t for good accuracy. Plot the nondimen-

sional temperature versus nondimensional length for various values

of nondimensional times.

30.14 The problem of transient radial heat # ow in a circular rod in

nondimensional form is described by

0 2u

0r 2 1

1

r 0u

0r 5 0u

t

Boundary conditions u(1, t ) 5 1 0u

0t (0, t) 5 0

Initial conditions u(x, 0) 5 0 0 # x # 1

Solve the nondimensional transient radial heat-conduction equa-

tion in a circular rod for the temperature distribution at various

times as the rod temperature approaches steady state. Use second-

order accurate ! nite-difference analogues for the derivatives with a

Crank-Nicolson formulation. Write a computer program for the

solution. Select values of ¢r and ¢t for good accuracy. Plot the

temperature u versus radius r for various times t.

30.15 Solve the following PDE:

0 2u

0x2 1 b 0u

0x 5 0u

0t

Boundary conditions u (0, t) 5 0 u (1, t ) 5 0 Initial conditions u (x, 0) 5 0 0 # x # 1

Use second-order accurate ! nite-difference analogues for the deriva-

tives with a Crank-Nicolson formulation to integrate in time. Write a

computer program for the solution. Increase the value of Dt by 10%

for each time step to more quickly obtain the steady-state solution,

and select values of Dx and Dt for good accuracy. Plot u versus x for

various values of t. Solve for values of b 5 4, 2, 0, 22, 24.

30.16 Determine the temperatures along a 1-m horizontal rod de-

scribed by the heat-conduction equation (Eq. 30.1). Assume that the

right boundary is insulated and that the left boundary (x 5 0) is

represented by

2k¿ 0T

0x ` x50

5 h(Ta 2 T0)

where k9 5 coef! cient of thermal conductivity (W/m ? 8C), h 5

convective heat transfer coef! cient (W/m2 ? 8C), Ta 5 ambient

temperature (8C), and T0 5 temperature of the rod at x 5 0 (8C).

Solve for temperature as a function of time using a spatial step of

Dx 5 1 cm and the following parameter values: k 5 2 3 1025 m2/s,

k9 5 10 W/m ? 8C, h 5 25 W/m2 ? 8C, and Ta 5 50 8C. Assume that

the initial temperature of the rod is zero.

30.7 The advection-diffusion equation is used to compute the dis-

tribution of concentration along the length of a rectangular chemi-

cal reactor (see Sec. 32.1),

0c

0t 5 D

0 2c

0x2 2 U

0c

0x 2 kc

where c 5 concentration (mg/m3), t 5 time (min), D 5 a diffusion

coef! cient (m2/min), x 5 distance along the tank’s longitudinal axis

(m) where x 5 0 at the tank’s inlet, U 5 velocity in the x direction

(m/min), and k 5 a reaction rate (min21) whereby the chemical de-

cays to another form. Develop an explicit scheme to solve this equa-

tion numerically. Test it for k 5 0.15, D 5 100, and U 5 1 for a tank

of length 10 m. Use a Dx 5 1 m, and a step size Dt 5 0.005. Assume

that the in# ow concentration is 100 and that the initial concentration

in the tank is zero. Perform the simulation from t 5 0 to 100 and plot

the ! nal resulting concentrations versus x.

30.8 Develop a user-friendly computer program for the simple ex-

plicit method from Sec. 30.2. Test it by duplicating Example 30.1.

30.9 Modify the program in Prob. 30.8 so that it employs either

Dirichlet or derivative boundary conditions. Test it by solving

Prob. 30.2.

30.10 Develop a user-friendly computer program to implement

the simple implicit scheme from Sec. 30.3. Test it by duplicating

Example 30.2.

30.11 Develop a user-friendly computer program to implement

the Crank-Nicolson method from Sec. 30.4. Test it by duplicating

Example 30.3.

30.12 Develop a user-friendly computer program for the ADI

method described in Sec. 30.5. Test it by duplicating Example 30.5.

30.13 The nondimensional form for the transient heat conduction

in an insulated rod (Eq. 30.1) can be written as

0 2u

0x 2 5 0u

0t

where nondimensional space, time, and temperature are de! ned as

x 5 x

L t 5

T

(rCL2yk) u 5

T 2 To

TL 2 To

where L 5 the rod length, k 5 thermal conductivity of the rod ma-

terial, r 5 density, C 5 speci! c heat, To 5 temperature at x 5 0,

and TL 5 temperature at x 5 L. This makes for the following

boundary and initial conditions:

Boundary conditions u(0, t ) 5 0 u(1, t ) 5 0 Initial conditions u(x,0) 5 0 0 # x # 1

Solve this nondimensional equation for the temperature distribu-

tion using ! nite-difference methods and a second-order accurate

Crank-Nicolson formulation to integrate in time. Write a computer

31 C H A P T E R 31

890

Finite-Element Method

To this juncture, we have employed  nite-difference methods to solve partial differential

equations. In these methods, the solution domain is divided into a grid of discrete points or

nodes (Fig. 31.1b). The PDE is then written for each node and its derivatives replaced by

! nite-divided differences. Although such “pointwise” approximation is conceptually easy to

understand, it has a number of shortcomings. In particular, it becomes harder to apply for

systems with irregular geometry, unusual boundary conditions, or heterogenous composition.

The  nite-element method provides an alternative that is better suited for such systems.

In contrast to ! nite-difference techniques, the ! nite-element method divides the solution

domain into simply shaped regions, or “elements” (Fig. 31.1c). An approximate solution for

FIGURE 31.1 (a) A gasket with irregular geometry and nonhomogeneous composition. (b) Such a system is very diffi cult to model with a fi nite-difference approach. This is due to the fact that complicated approx- imations are required at the boundaries of the system and at the boundaries between regions of differing composition. (c) A fi nite-element discretization is much better suited for such systems.

Material A

Material B

Material C

(a) (b) (c)

31.1 THE GENERAL APPROACH 891

the PDE can be developed for each of these elements. The total solution is then generated

by linking together, or “assembling,” the individual solutions taking care to ensure continu-

ity at the interelement boundaries. Thus, the PDE is satis! ed in a piecewise fashion.

As in Fig. 31.1c, the use of elements, rather than a rectangular grid, provides a much

better approximation for irregularly shaped systems. Further, values of the unknown can

be generated continuously across the entire solution domain rather than at isolated points.

Because a comprehensive description is beyond the scope of this book, this chapter

provides a general introduction to the ! nite-element method. Our primary objective is to

make you comfortable with the approach and cognizant of its capabilities. In this spirit,

the following section is devoted to a general overview of the steps involved in a typical

! nite-element solution of a problem. This is followed by a simple example: a steady-state,

one-dimensional heated rod. Although this example does not involve PDEs, it allows us

to develop and demonstrate major aspects of the ! nite-element approach unencumbered

by complicating factors. We can then discuss some issues involved in employing the ! nite-

element method for PDEs.

31.1 THE GENERAL APPROACH

Although the particulars will vary, the implementation of the ! nite-element approach

usually follows a standard step-by-step procedure. The following provides a brief over-

view of each of these steps. The application of these steps to engineering problem con-

texts will be developed in subsequent sections.

31.1.1 Discretization

This step involves dividing the solution domain into ! nite elements. Figure 31.2 provides

examples of elements employed in one, two, and three dimensions. The points of inter-

section of the lines that make up the sides of the elements are referred to as nodes and

the sides themselves are called nodal lines or planes.

31.1.2 Element Equations

The next step is to develop equations to approximate the solution for each element. This

involves two steps. First, we must choose an appropriate function with unknown coef-

! cients that will be used to approximate the solution. Second, we evaluate the coef! cients

so that the function approximates the solution in an optimal fashion.

Choice of Approximation Functions. Because they are easy to manipulate mathemat- ically, polynomials are often employed for this purpose. For the one-dimensional case,

the simplest alternative is a ! rst-order polynomial or straight line,

u(x) 5 a0 1 a1x (31.1)

where u(x) 5 the dependent variable, a0 and a1 5 constants, and x 5 the independent

variable. This function must pass through the values of u(x) at the end points of the

element at x1 and x2. Therefore,

u1 5 a0 1 a1x1

u2 5 a0 1 a1x2

892 FINITE-ELEMENT METHOD

where u1 5 u(x1) and u2 5 u(x2). These equations can be solved using Cramer’s rule for

a0 5 u1 x2 2 u2 x1

x2 2 x1 a1 5

u2 2 u1

x2 2 x1

These results can then be substituted into Eq. (31.1) which, after collection of terms, can

be written as

u 5 N1 u1 1 N2 u2 (31.2)

where

N1 5 x2 2 x

x2 2 x1 (31.3)

and

N2 5 x 2 x1

x2 2 x1 (31.4)

Equation (31.2) is called an approximation, or shape, function, and N1 and N2 are called

interpolation functions. Close inspection reveals that Eq. (31.2) is, in fact, the Lagrange

FIGURE 31.2 Examples of elements employed in (a) one, (b) two, and (c) three dimensions.

Line element

(a) One-dimensional

Nodal line

Node

Triangular

element

Quadrilateral

element

(b) Two-dimensional

Hexahedron

element

Nodal plane

(c) Three-dimensional

31.1 THE GENERAL APPROACH 893

! rst-order interpolating polynomial. It provides a means to predict intermediate values

(that is, to interpolate) between given values u1 and u2 at the nodes.

Figure 31.3 shows the shape function along with the corresponding interpolation

functions. Notice that the sum of the interpolation functions is equal to one.

In addition, the fact that we are dealing with linear equations facilitates operations

such as differentiation and integration. Such manipulations will be important in later

sections. The derivative of Eq. (31.2) is

du

dx 5

dN1

dx u1 1

dN2

dx u2 (31.5)

According to Eqs. (31.3) and (31.4), the derivatives of the N’s can be calculated as

dN1

dx 5 2

1

x2 2 x1

dN2

dx 5

1

x2 2 x1 (31.6)

and, therefore, the derivative of u is

du

dx 5

1

x2 2 x1 (2u1 1 u2) (31.7)

In other words, it is a divided difference representing the slope of the straight line con-

necting the nodes.

The integral can be expressed as

# x2

x1

u dx 5 # x2

x1

N1 u1 1 N2 u2 dx

Each term on the right-hand side is merely the integral of a right triangle with base x2 2 x1

and height u. That is,

# x2

x1

Nu dx 5

1

2 (x2 2 x1)u

Thus, the entire integral is

# x2

x1

u dx 5 u1 1 u2

2 (x2 2 x1) (31.8)

In other words, it is simply the trapezoidal rule.

Obtaining an Optimal Fit of the Function to the Solution. Once the interpolation function is chosen, the equation governing the behavior of the element must be devel-

oped. This equation represents a ! t of the function to the solution of the underlying

differential equation. Several methods are available for this purpose. Among the most

common are the direct approach, the method of weighted residuals, and the variational

approach. The outcome of all of these methods is analogous to curve ! tting. However,

instead of ! tting functions to data, these methods specify relationships between the un-

knowns in Eq. (31.2) that satisfy the underlying PDE in an optimal fashion.

FIGURE 31.3 (b) A linear approximation or shape function for (a) a line element. The corresponding interpolation functions are shown in (c ) and (d ).

Node 1 Node 2

u1

u2

x1 x2

N1

N2

u

1

1

(a)

(b)

(c)

(d)

894 FINITE-ELEMENT METHOD

Mathematically, the resulting element equations will often consist of a set of linear

algebraic equations that can be expressed in matrix form,

[k]{u} 5 {F} (31.9)

where [k] 5 an element property or stiffness matrix, {u} 5 a column vector of un-

knowns at the nodes, and {F} 5 a column vector re# ecting the effect of any external

in# uences applied at the nodes. Note that, in some cases, the equations can be nonlin-

ear. However, for the elementary examples described herein, and for many practical

problems, the systems are linear.

31.1.3 Assembly

After the individual element equations are derived, they must be linked together or as-

sembled to characterize the uni! ed behavior of the entire system. The assembly process

is governed by the concept of continuity. That is, the solutions for contiguous elements

are matched so that the unknown values (and sometimes the derivatives) at their common

nodes are equivalent. Thus, the total solution will be continuous.

When all the individual versions of Eq. (31.9) are ! nally assembled, the entire sys-

tem is expressed in matrix form as

[k]{u¿} 5 {F¿} (31.10)

where [K] 5 the assemblage property matrix and {u9} and {F9} column vectors for un-

knowns and external forces that are marked with primes to denote that they are an as-

semblage of the vectors {u} and {F} from the individual elements.

31.1.4 Boundary Conditions

Before Eq. (31.10) can be solved, it must be modi! ed to account for the system’s bound-

ary conditions. These adjustments result in

[k]{u¿} 5 {F ¿} (31.11)

where the overbars signify that the boundary conditions have been incorporated.

31.1.5 Solution

Solutions of Eq. (31.11) can be obtained with techniques described previously in Part

Three, such as LU decomposition. In many cases, the elements can be con! gured so that

the resulting equations are banded. Thus, the highly ef! cient solution schemes available

for such systems can be employed.

31.1.6 Postprocessing

Upon obtaining a solution, it can be displayed in tabular form or graphically. In addition,

secondary variables can be determined and displayed.

Although the preceding steps are very general, they are common to most imple-

mentations of the ! nite-element approach. In the following section, we illustrate how

they can be applied to obtain numerical results for a simple physical system—a

heated rod.

31.2 FINITE-ELEMENT APPLICATION IN ONE DIMENSION 895

31.2 FINITE-ELEMENT APPLICATION IN ONE DIMENSION

Figure 31.4 shows a system that can be modeled by a one-dimensional form of Poisson’s

equation

d2 T

dx2 5 2f (x) (31.12)

where f(x) 5 a function de! ning a heat source along the rod and where the ends of the

rod are held at ! xed temperatures,

T(0, t) 5 T1

and

T(L, t) 5 T2

Notice that this is not a partial differential equation but rather is a boundary-value

ODE. This simple model is used because it will allow us to introduce the ! nite-element

approach without some of the complications involved in, for example, a two-dimensional

PDE.

EXAMPLE 31.1 Analytical Solution for a Heated Rod

Problem Statement. Solve Eq. (31.12) for a 10-cm rod with boundary conditions of T(0, t) 5 40 and T(10, t) 5 200 and a uniform heat source of f(x) 5 10.

Solution. The equation to be solved is

d 2 T

dx2 5 210

1 2 3 4

1 2 3 4 5

x = 0 x = L

T(0, t) T(L, t)

f (x)

x

(a)

(b)

FIGURE 31.4 (a) A long, thin rod subject to fi xed boundary conditions and a continuous heat source along its axis. (b) The fi nite-element representation consisting of four equal-length elements and fi ve nodes.

896 FINITE-ELEMENT METHOD

Assume a solution of the form

T 5 ax2 1 bx 1 c

which can be differentiated twice to give T 0 5 2a. Substituting this result into the dif-

ferential equation gives a 5 25. The boundary conditions can be used to evaluate the

remaining coef! cients. For the ! rst condition at x 5 0,

40 5 25(0)2 1 b(0) 1 c

or c 5 40. Similarly, for the second condition,

200 5 25(10)2 1 b(10) 1 40

which can be solved for b 5 66. Therefore, the ! nal solution is

T 5 25×2 1 66x 1 40

The results are plotted in Fig. 31.5.

FIGURE 31.5 The temperature distribution along a heated rod subject to a uniform heat source and held at fi xed end temperatures.

T

100

0

200

5 10 x

31.2.1 Discretization

A simple con! guration to model the system is a series of equal-length elements (Fig. 31.4b).

Thus, the system is treated as four equal-length elements and ! ve nodes.

31.2 FINITE-ELEMENT APPLICATION IN ONE DIMENSION 897

31.2.2 Element Equations

An individual element is shown in Fig. 31.6a. The distribution of temperature for the

element can be represented by the approximation function

T̃ 5 N1T1 1 N2T2 (31.13)

where N1 and N2 5 linear interpolation functions speci! ed by Eqs. (31.3) and (31.4),

respectively. Thus, as depicted in Fig. 31.6b, the approximation function amounts to a

linear interpolation between the two nodal temperatures.

As noted in Sec. 31.1, there are a variety of approaches for developing the element

equation. In this section, we employ two of these. First, a direct approach will be used

for the simple case where f(x) 5 0. Then, because of its general applicability in engi-

neering, we will devote most of the section to the method of weighted residuals.

The Direct Approach. For the case where f(x) 5 0, a direct method can be employed to generate the element equations. The relationship between heat ! ux and temperature

gradient can be represented by Fourier’s law:

q 5 2k¿ d T

dx

where q 5 flux [cal/(cm2 ? s)] and k9 5 the coefficient of thermal conductivity

[cal/(s ? cm ? 8C)]. If a linear approximation function is used to characterize the element’s

temperature, the heat ! ow into the element through node 1 can be represented by

q1 5 k¿ T1 2 T2

x2 2 x1

where q1 is heat ! ux at node 1. Similarly, for node 2,

q2 5 k¿ T2 2 T1

x2 2 x1

These two equations express the relationship of the element’s internal temperature dis-

tribution (as re! ected by the nodal temperatures) to the heat ! ux at its ends. As such,

they constitute our desired element equations. They can be simpli” ed further by recog-

nizing that Fourier’s law can be used to couch the end ! uxes themselves in terms of the

temperature gradients at the boundaries. That is,

q1 5 2k¿ dT(x1)

dx q2 5 k¿

dT(x2)

dx

which can be substituted into the element equations to give

1

x2 2 x1 c 1 21

21 1 d eT1

T2 f 5 µ2dT(x1)dx

dT(x2)

dx

∂ (31.14) Notice that Eq. (31.14) has been cast in the format of Eq. (31.9). Thus, we have

succeeded in generating a matrix equation that describes the behavior of a typical element

in our system.

FIGURE 31.6 (a) An individual element. (b) The approximation function used to characterize the temperature distribution along the element.

Node 1 Node 2

T1

T2

x1 x2

T

(a)

(b)

~

898 FINITE-ELEMENT METHOD

The direct approach has great intuitive appeal. Additionally, in areas such as mechan-

ics, it can be employed to solve meaningful problems. However, in other contexts, it is

often dif” cult or impossible to derive ” nite-element equations directly. Consequently, as

described next, more general mathematical techniques are available.

The Method of Weighted Residuals. The differential equation (31.12) can be reex- pressed as

0 5 d2T

dx2 1 f(x)

The approximate solution [Eq. (31.13)] can be substituted into this equation. Because

Eq. (31.13) is not the exact solution, the left side of the resulting equation will not be

zero but will equal a residual,

R 5 d2T̃

dx2 1 f(x) (31.15)

The method of weighted residuals (MWR) consists of ” nding a minimum for the

residual according to the general formula

# D

RWi dD 5 0 i 5 1, 2, p , m (31.16)

where D 5 the solution domain and the Wi 5 linearly independent weighting functions.

At this point, there are a variety of choices that could be made for the weighting

function (Box 31.1). The most common approach for the ” nite-element method is to

employ the interpolation functions Ni as the weighting functions. When these are substi-

tuted into Eq. (31.16), the result is referred to as Galerkin’s method,

# D

RNi dD 5 0 i 5 1, 2, p , m

For our one-dimensional rod, Eq. (31.15) can be substituted into this formulation to give

# x2

x1

c d2T̃ dx2

1 f(x)d Ni dx i 5 1, 2 which can be reexpressed as

# x2

x1

d2T̃

dx2 Ni(x) dx 5 2#

x2

x1

f (x)Ni(x) dx i 5 1, 2 (31.17)

At this point, a number of mathematical manipulations will be applied to simplify

and evaluate Eq. (31.17). Among the most important is the simpli” cation of the left-hand

side using integration by parts. Recall from calculus that this operation can be expressed

generally as

# b

a u dy 5 uyZ ba 2 #

b

a y du

31.2 FINITE-ELEMENT APPLICATION IN ONE DIMENSION 899

If u and y are chosen properly, the new integral on the right-hand side will be

easier to evaluate than the original one on the left-hand side. This can be done for

the term on the left-hand side of Eq. (31.17) by choosing Ni(x) as u and (d 2Tydx2)

dx as dy to yield

# x2

x1

Ni(x)

d2T̃

dx2 dx 5 Ni(x)

dT̃

dx ` x2 x1

2 # x2

x1

dT̃

dx dNi

dx dx i 5 1, 2 (31.18)

Thus, we have taken the signi” cant step of lowering the highest-order term in the for-

mulation from a second to a ” rst derivative.

Next, we can evaluate the individual terms that we have created in Eq. (31.18). For

i 5 1, the ” rst term on the right-hand side of Eq. (31.18) can be evaluated as

N1(x) dT̃

dx ` x2 x1

5 N1(x2) dT̃(x2)

dx 2 N1(x1)

dT̃(x1)

dx

However, recall from Fig. 31.3 that N1(x2) 5 0 and N1(x1) 5 1, and therefore,

N1(x) dT̃

dx ` x2 x1

5 2 dT̃(x1)

dx (31.19)

Box 31.1 Alternative Residual Schemes for the MWR

Several choices can be made for the weighting functions of Eq. (31.16).

Each represents an alternative approach for the MWR.

In the collocation approach, we choose as many locations as

there are unknown coef” cients. Then, the coef” cients are adjusted

until the residual vanishes at each of these locations. Consequently,

the approximating function will yield perfect results at the chosen

locations but will have a nonzero residual elsewhere. Thus, it is

akin to the interpolation methods in Chap. 18. Note that collocation

amounts to using the weighting function

W 5 d(x 2 xi) for i 5 1, 2, p , n

where n 5 the number of unknown coef” cients and d(x 2 xi) 5 the

Dirac delta function that vanishes everywhere but at x 5 xi, where

it equals 1.

In the subdomain method, the interval is divided into as many

segments, or “subdomains,” as there are unknown coef” cients.

Then, the coef” cients are adjusted until the average value of the

residual is zero in each subdomain. Thus, for each subdomain, the

weighting function is equal to 1 and Eq. (31.16) is

# xi

xi21

R dx 5 0 for i 5 1, 2, p , n

where xi21 and xi are the bounds of the subdomain.

For the least-squares case, the coef” cients are adjusted so as to

minimize the integral of the square of the residual. Thus, the

weighting functions are

Wi 5 0R

0ai

which can be substituted into Eq. (31.16) to give

# D

R 0R

0ai dD 5 0 i 5 1, 2, p , n

or

0

0ai # D

R2 dD 5 0 i 5 1, 2, p , n

Comparison of the formulation with those of Chap. 17 shows that

this is the continuous form of regression.

Galerkin’s method employs the interpolation functions Ni as

weighting functions. Recall that these functions always sum to 1 at

any position in an element. For many problem contexts, Galerkin’s

method yields the same results as are obtained by variational meth-

ods. Consequently, it is the most commonly employed version of

MWR used in ” nite-element analysis.

900 FINITE-ELEMENT METHOD

Similarly, for i 5 2,

N2(x) dT̃

dx ` x2 x1

5 dT̃(x2)

dx (31.20)

Thus, the ” rst term on the right-hand side of Eq. (31.18) represents the natural boundary

conditions at the ends of the elements.

Now, before proceeding let us regroup by substituting our results back into the

original equation. Substituting Eqs. (31.18) through (31.20) into Eq. (31.17) and rear-

ranging gives for i 5 1,

# x2

x1

dT̃

dx dN1

dx dx 5 2

dT̃(x1)

dx 1 #

x2

x1

f(x)N1(x) dx (31.21)

and for i 5 2,

# x2

x1

dT̃

dx dN2

dx dx 5

dT̃(x2)

dx 1 #

x2

x1

f(x)N2(x) dx (31.22)

Notice that the integration by parts has led to two important outcomes. First, it has

incorporated the boundary conditions directly into the element equations. Second, it has

lowered the highest-order evaluation from a second to a ” rst derivative. This latter out-

come yields the signi” cant result that the approximation functions need to preserve con-

tinuity of value but not slope at the nodes.

Also notice that we can now begin to ascribe some physical signi” cance to the in-

dividual terms we have derived. On the right-hand side of each equation, the ” rst term

represents one of the element’s boundary conditions and the second is the effect of the

system’s forcing function—in the present case, the heat source f(x). As will now become

evident, the left-hand side embodies the internal mechanisms that govern the element’s

temperature distribution. That is, in terms of the ” nite-element method, the left-hand side

will become the element property matrix.

To see this, let us concentrate on the terms on the left-hand side. For i 5 1, the term is

# x2

x1

dT̃

dx dN1

dx dx (31.23)

Recall from Sec. 31.1.2 that the linear nature of the shape function makes differentiation

and integration simple. Substituting Eqs. (31.6) and (31.7) into Eq. (31.23) gives

# x2

x1

T1 2 T2

(x2 2 x1) 2

dx 5 1

x2 2 x1 (T1 2 T2) (31.24)

Similar substitutions for i 5 2 [Eq. (31.22)] yield

# x2

x1

2T1 1 T2

(x2 2 x1) 2 dx 5

1

x2 2 x1 (2T1 1 T2) (31.25)

Comparison with Eq. (31.14) shows that these are similar to the relationships that

were developed with the direct method using Fourier’s law. This can be made even clearer

31.2 FINITE-ELEMENT APPLICATION IN ONE DIMENSION 901

by reexpressing Eqs. (31.24) and (31.25) in matrix form as

1

x2 2 x1 c 1 21

21 1 d eT1

T2 f

Substituting this result into Eqs. (31.21) and (31.22) and expressing the result in

matrix form gives the ” nal version of the element equations

1

x2 2 x1 c 1 21

21 1 d {T} 5 µ2dT(x1)dx

dT(x2)

ds

∂ 1 µ # x2

x1 f(x)N1(x) dx

# x2

x1 f(x)N2(x) dx

∂ (31.26) Note that aside from the direct and the weighted residual methods, the element equa-

tions can also be derived using variational calculus (for example, see Allaire, 1985). For the

present case, this approach yields equations that are identical to those derived above.

EXAMPLE 31.2 Element Equation for a Heated Rod

Problem Statement. Employ Eq. (31.26) to develop the element equations for a 10-cm rod with boundary conditions of T(0, t) 5 40 and T(10, t) 5 200 and a uniform heat

source of f(x) 5 10. Employ four equal-size elements of length 5 2.5 cm.

Solution. The heat source term in the ” rst row of Eq. (31.26) can be evaluated by substituting Eq. (31.3) and integrating to give

# 2.5

0 10

2.5 2 x

2.5 dx 5 12.5

Similarly, Eq. (31.4) can be substituted into the heat source term of the second row of

Eq. (31.26), which can also be integrated to yield

# 2.5

0 10

x 2 0

2.5 dx 5 12.5

These results along with the other parameter values can be substituted into Eq. (31.26)

to give

0.4T1 2 0.4T2 5 2 dT

dx (x1) 1 12.5

and

20.4T1 1 0.4T2 5 dT

dx (x2) 1 12.5

31.2.3 Assembly

Before the element equations are assembled, a global numbering scheme must be estab-

lished to specify the system’s topology or spatial layout. As in Table 31.1, this de” nes the

External effects

sf fElement stiffness matrix Boundary condition

902 FINITE-ELEMENT METHOD

TABLE 31.1 The system topology for the fi nite-element segmentation scheme from Fig. 31.4b.

Node Numbers

Element Local Global

1 1 1 2 2 2 1 2 2 3 3 1 3 2 4 4 1 4 2 5

FIGURE 31.7 The assembly of the equations for the total system.

(a)

0.4 20.4 0 0 0

20.4 0.4 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

T1

T2

0

0

0

5

2dT(x1)ydx 1 12.5 dT(x2)ydx 1 12.5

0

0

0

(b)

0.4

20.4

0

0

0

20.4

0.4

0

0

10.4

20.4

0

20.4

0.4

0

0

0

0

0

0

0

0

0

0

0

0

T1 T2 T3 0

0

5

2dT(x1)ydx 1 12.5 12.5 1 12.5

dT(x3)ydx 1 12.5 0

0

(c)

0.4

20.4

0

0

0

20.4

0.8

20.4

0

0

0

20.4

0.4

0

10.4

20.4

0

0

20.4

0.4

0

0

0

0

0

0

T1 T2 T3 T4 0

5

2dT(x1)ydx 1 12.5 25

12.5 1 12.5

dT(x4)ydx 1 12.5 0

(d)

0.4

20.4

0

0

0

20.4

0.8

20.4

0

0

0

20.4

0.8

20.4

0

0

0

20.4

0.4

10.4

20.4

0

0

0

20.4

0.4

T1 T2 T3 T4 T5

5

2dT(x1)ydx 1 12.5 25

25

12.5 1 12.5

dT(x5)ydx 1 12.5

(e)

0.4

20.4

0

0

0

20.4

0.8

20.4

0

0

0

20.4

0.8

20.4

0

0

0

20.4

0.8

20.4

0

0

0

20.4

0.4

T1 T2 T3 T4 T5

5

2dT(x1)ydx 1 12.5 25

25

25

dT(x5)ydx 1 12.5

E E E E E

E E E E E

e e e e e

e e e e e

e e e e e

e e e e e

31.2 FINITE-ELEMENT APPLICATION IN ONE DIMENSION 903

connectivity of the element mesh. Because the present case is one-dimensional, the numbering

scheme might seem so predictable that it is trivial. However, for two- and three-dimensional

problems it offers the only means to specify which nodes belong to which elements.

Once the topology is speci” ed, the element equation (31.26) can be written for each

element using the global coordinates. Then they can be added one at a time to assemble

the total system matrix (note that this process is explored further in Sec. 32.4). The

process is depicted in Fig. 31.7.

31.2.4 Boundary Conditions

Notice that, as the equations are assembled, the internal boundary conditions cancel.

Thus, the ” nal result for {F} in Fig. 31.7e has boundary conditions for only the ” rst and

the last nodes. Because T1 and T5 are given, these natural boundary conditions at the

ends of the bar, dT(x1)ydx and dT(x5)ydx, represent unknowns. Therefore, the equations can be re-expressed as

dT

dx (x1) 20.4T2 5 23.5

0.8T2 20.4T3 5 41

20.4T2 10.8T3 20.4T4 5 25

20.4T3 10.8T4 5 105

20.4T4 2 dT

dx (x5) 5 267.5

(31.27)

FIGURE 31.8 Results of applying the fi nite-element approach to a heated bar. The exact solution is also shown.

T

100

0

200

5 10 x

Finite-element

Analytical

904 FINITE-ELEMENT METHOD

31.2.5 Solution

Equation (31.27) can be solved for

dT

dx (x1) 5 66 T2 5 173.75 T3 5 245

T4 5 253.75 dT

dx (x5) 5 234

31.2.6 Postprocessing

The results can be displayed graphically. Figure 31.8 shows the ” nite-element results

along with the exact solution. Notice that the ” nite-element calculation captures the

overall trend of the exact solution and, in fact, provides an exact match at the nodes.

However, a discrepancy exists in the interior of each element due to the linear nature of

the shape functions.

31.3 TWO-DIMENSIONAL PROBLEMS

Although the mathematical “bookkeeping” increases markedly, the extension of the ” nite-

element approach to two dimensions is conceptually similar to the one-dimensional applica-

tions discussed to this point. It thus follows the same steps as were outlined in Sec. 31.1.

31.3.1 Discretization

A variety of simple elements such as triangles or quadrilaterals are usually employed for

the ” nite-element mesh in two dimensions. In the present discussion, we will limit our-

selves to triangular elements of the type depicted in Fig. 31.9.

31.3.2 Element Equations

Just as for the one-dimensional case, the next step is to develop an equation to ap-

proximate the solution for the element. For a triangular element, the simplest approach

is the linear polynomial [compare with Eq. (31.1)]

u(x, y) 5 a0 1 a1,1x 1 a1,2y (31.28)

FIGURE 31.9 A triangular element.

y

x

3

2

1

31.3 TWO-DIMENSIONAL PROBLEMS 905

where u(x, y) 5 the dependent variable, the a’s 5 coef” cients, and x and y 5 independent

variables. This function must pass through the values of u(x, y) at the triangle’s nodes

(x1, y1), (x2, y2), and (x3, y3). Therefore,

u1(x, y) 5 a0 1 a1,1×1 1 a1, 2y1

u2(x, y) 5 a0 1 a1,1×2 1 a1, 2y2

u3(x, y) 5 a0 1 a1,1×3 1 a1, 2y3

or in matrix form,

£ 1 x1 y11 x2 y2 1 x3 y3

§ • a0a1,1 a1, 2

¶ 5 •u1u2 u3

¶ which can be solved for

a0 5 1

2Ae [u1(x2y3 2 x3y2) 1 u2(x3y1 2 x1y3) 1 u3(x1y2 2 x2y1)] (31.29)

a1,1 5 1

2Ae [u1(y2 2 y3) 1 u2(y3 2 y1) 1 u3(y1 2 y2)] (31.30)

a1, 2 5 1

2Ae [u1(x3 2 x2) 1 u2(x1 2 x3) 1 u3(x2 2 x1)] (31.31)

where Ae is the area of the triangular element,

Ae 5 1

2 [(x2y3 2 x3y2) 1 (x3y1 2 x1y3) 1 (x1y2 2 x2y1)]

Equations (31.29) through (31.31) can be substituted into Eq. (31.28). After a col-

lection of terms, the result can be expressed as

u 5 N1u1 1 N2u2 1 N3u3 (31.32)

where

N1 5 1

2Ae [(x2y3 2 x3y2) 1 (y2 2 y3)x 1 (x3 2 x2)y]

N2 5 1

2Ae [(x3y1 2 x1y3) 1 (y3 2 y1)x 1 (x1 2 x3)y]

N3 5 1

2Ae [(x1y2 2 x2y1) 1 (y1 2 y2)x 1 (x2 2 x1)y]

Equation (31.32) provides a means to predict intermediate values for the element on

the basis of the values at its nodes. Figure 31.10 shows the shape function along with

the corresponding interpolation functions. Notice that the sum of the interpolation func-

tions is always equal to 1.

As with the one-dimensional case, various methods are available for developing ele-

ment equations based on the underlying PDE and the approximating functions. The result-

ing equations are considerably more complicated than Eq. (31.26). However, because the

906 FINITE-ELEMENT METHOD

approximating functions are usually lower-order polynomials like Eq. (31.28), the terms

of the ” nal element matrix will consist of lower-order polynomials and constants.

31.3.3 Boundary Conditions and Assembly

The incorporation of boundary conditions and the assembly of the system matrix also

become more complicated when the ” nite-element technique is applied to two- and three-

dimensional problems. However, as with the derivation of the element matrix, the dif” culty

FIGURE 31.10 (a) A linear approximation function for a triangular element. The corresponding interpolation func- tions are shown in (b) through (d ).

u

x

y

u3 u2

u1

x

y

N1

1

0

0

x

y

N2

1 0

0

x

y

N3

1

0

0

(a)

(b)

(c)

(d)

31.3 TWO-DIMENSIONAL PROBLEMS 907

FIGURE 31.11 A numbering scheme for the nodes and elements of a fi nite-element approximation of the heated plate that was previously characterized by fi nite differences in Chap. 29.

26

25

28

27

30

29

32

31

18

17

20

19

22

21

24

23

10

9

12

11

14

13

16

15

2

1

4

3

6

5

8

7

1 2 3 4 5

10

15

20

2524232221

16 17 18 19

11 12 13 14

6 7 8 9

100 100 100 100 100

50

50

50

00000

75

75

75

FIGURE 31.12 The temperature distribution of a heated plate as calculated with a fi nite-element method.

908 FINITE-ELEMENT METHOD

relates to the mechanics of the process rather than to conceptual complexity. For example,

the establishment of the system topology, which was trivial for the one-dimensional case,

becomes a matter of great importance in two and three dimensions. In particular, the choice

of a numbering scheme will dictate the bandedness of the resulting system matrix and

hence the ef” ciency with which it can be solved. Figure 31.11 shows a scheme that was

developed for the heated plate formerly solved by ” nite-difference methods in Chap. 29.

31.3.4 Solution and Postprocessing

Although the mechanics are complicated, the system matrix is merely a set of n simul-

taneous equations that can be used to solve for the values of the dependent variable at

the n nodes. Figure 31.12 shows a solution that corresponds to the ” nite-difference solu-

tion from Fig. 29.5.

31.4 SOLVING PDES WITH SOFTWARE PACKAGES

Software packages have some capabilities for directly solving PDEs. However, as de-

scribed in the following sections, many of the solutions are limited to simple problems.

This is particularly true of two- and three-dimensional cases. For these situations, generic

packages (that is, ones not expressly developed to solve PDEs such as ” nite-element

packages) are often limited to simple rectangular domains.

Although this might seem limiting, simple applications can be of great utility in a

pedagogical sense. This is particularly true when the packages’ visualization tools are

used to display calculation results.

31.4.1 Excel

Although Excel does not have the direct capability to solve PDEs, it is a nice environ-

ment to develop simple solutions of elliptic PDEs. For example, the orthogonal layout

of the spreadsheet cells (Fig. 31.13b) is directly analogous to the grid used in Chap. 29

to model the heated plate (Fig. 31.13a).

FIGURE 31.13 The analogy between (a) a rect- angular grid and (b) the cells of a spreadsheet.

78.57

100

B

42.86

0

63.17

75

87.5

A

75

37.5

75

69.64

100

D

33.93

0

52.46

50

75

E

50

25

50

76.12

100

C

33.26

0

56.25

1

2

3

4

5

87.5 100 100

75

75

T13 = 100 + T23 + T12 + 75

4 4 B2 =

B1 + C2 + B3 + A2

(a) Grid (b) Spreadsheet

31.4 SOLVING PDES WITH SOFTWARE PACKAGES 909

As in Fig. 31.13b, the Dirichlet boundary conditions can ” rst be entered along the

periphery of the cell block. The formula for the Liebmann method can be implemented

by entering Eq. (29.11) in one of the cells in the interior (like cell B2 in Fig. 31.13b).

Thus, the value for the cell can be computed as a function of its adjacent cells. Then the

cell can be copied to the other interior cells. Because of the relative nature of the Excel

copy command, all the other cells will properly be dependent on their adjacent cells.

Once you have copied the formula, you will probably get an error message: Cannot

resolve circular references. You can rectify this by selecting File, Options and clicking

on the Formulas category. Then, go to the Calculation options section and enable the

Iterative calculation check box. This will allow the spreadsheet to recalculate (the default

is 100 iterations) and solve Liebmann’s method iteratively. After this occurs, strike the F9 key

to manually recalculate the sheet until the answers do not vary. This means that the solution

has converged.

Once the problem has been solved, Excel’s graphics tools can be used to visualize

the results. An example is shown in Fig. 31.14a. For this case, we have

Used a finer grid.

Made the lower boundary insulated.

Added a heat source of 150 to the middle of the plate (cell E5).

FIGURE 31.14 (a) Excel solution of the Poisson equation for a plate with an insulated lower edge and a heat source. (b) A “topographic map” and (c) a 3-D display of the temperatures.

89.2

100.0

B

85.7

85.5

86.2

75.0

87.5

A

75.0

75.0

75.0

99.1

100.0

D

106.7

114.3

100.9

99.7

100.0

E

115.3

150.0

103.1

95.8

100.0

C

96.1

97.4

94.7

96.6

100.0

F

101.4

108.6

96.7

77.6

100.0

H

68.2

67.3

70.3

50.0

75.0

I

50.0

50.0

50.0

89.9

100.0

G

85.2

85.6

85.5

1

2

3

4

5

84.0

80.9

80.4

82.2

75.0

75.0

75.0

75.0

103.4

88.9

87.3

94.2

111.6

88.4

86.3

95.6

93.4

85.9

84.9

88.9

97.4

82.8

81.1

88.1

65.6

62.2

61.7

63.6

50.0

50.0

50.0

50.0

81.3

73.5

72.4

76.6

6

7

8

9

(b)

(a)

(c)

S9

S8

S7

S6

S5

S4

S3

S2

S1 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9

160

140

120

100

80

60

40

S1

S3

S5

S7

S9

910 FINITE-ELEMENT METHOD

The numerical results from Fig. 31.14a can then be displayed with Excel’s Chart

Wizard. Figure 31.14b and c show 3-D surface plots. The y orientation of these are

normally the reverse of the spreadsheet. Thus, the top high-temperature edge (100) would

normally be displayed at the bottom of the plot. We reversed the y values on our sheet

prior to plotting so that the graphs would be consistent with the spreadsheet.

Notice how the graphs help you visualize what is going on. Heat ! ows down from

the source toward the boundaries, forming a mountainlike shape. Heat also ! ows from

the high-temperature boundary down to the two side edges. Notice how the heat ! ows

preferentially toward the lower-temperature edge (50). Finally, notice how the tempera-

ture gradient in the y dimension goes to zero at the lower insulated edge (0Ty0yS 0).

31.4.2 MATLAB

Although the standard MATLAB software package does not presently have great capabilities

for solving PDEs, M-” les and functions can certainly be developed for this purpose. In

addition, its display capabilities are very nice, particularly for visualization of 2-D spatial

problems.

To illustrate this capability, we ” rst set up the Excel spreadsheet in Fig. 31.14a.

These results can be saved as a text (Tab delimited) ” le with a name like plate.txt. This

” le can then be moved to the MATLAB directory.

Once in MATLAB, the ” le can be loaded by typing

Next, the gradients can be simply calculated as

Note that this is the simplest method to compute gradients using default values of dx 5

dy 5 1. Therefore, the directions and relative magnitudes will be correct.

Finally, a series of commands can be used to develop the plot. The command

develops a contour plot of the data. The command adds contour labels to the plot.

Finally, takes the gradient data and adds it to the plot as arrows,

Note that the minus signs are added because of the minus sign in Fourier’s law

[Eq. (29.4)]. As seen in Fig. 31.15, the resulting plot provides an excellent representation

of the solution.

Note that any ” le in the proper format can be entered into MATLAB and displayed

in this way. This sharing of ” les between tools is becoming commonplace. In addition,

” les can be created in one location on one tool, transmitted over the Internet to another

location, where the ” le might be displayed with another tool. This is one of the exciting

aspects of modern numerical applications.

31.4 SOLVING PDES WITH SOFTWARE PACKAGES 911

FIGURE 31.15 MATLAB-generated contour plots for the heated plate calculated with Excel (Fig. 31.14).

++

+

+

+ +

+

+

+

+ +

9

8

7

6

5

4

3

2

1

1 2 3 4 5 6 7 8 9

6090

70

80

100

140 110

120 80

100

31.4.3 Mathcad

Mathcad has two functions that can solve Poisson’s equation. You can use the relax

function when you know the value of the unknown on all four sides of a square region.

This function solves a system of linear algebraic equations using Gauss-Seidel iteration

with overrelaxation to speed the rate of convergence. For the special case where there

are internal sources or sinks, and the unknown function is zero on all four sides of the

square, then you can use the multigrid function, which is usually faster than relax. Both

of these functions return a square matrix where the location of the element in the matrix

corresponds to its location within the square region. The value of the element approxi-

mates the value of the solution of Poisson’s equation at this point.

Figure 31.16 shows an example where a square plate contains heat sources while the

boundary is maintained at zero. The ” rst step is to establish dimensions for the temperature

grid and the heat source matrix. The temperature grid has dimensions (R 1 1) 3 (R 1 1)

while the heat source matrix is R 3 R. For example, a 3 3 3 temperature grid has 4 (2 3 2)

possible heat sources. In this case, we establish a 33 3 33 temperature grid and a 32 3 32

heat source matrix. The Mathcad command MRR:5 0 (with R 5 32) establishes the

dimensions of the source matrix and sets all the elements to zero. Next, the location and

strength of two heat sources are established. Finally, S is the resulting temperature

912 FINITE-ELEMENT METHOD

distribution as calculated by the multigrid function. The second argument of multigrid is a

parameter that controls the numerical accuracy. As suggested by Mathcad help, a value of

2 generally gives a good approximation of the solution.

The temperature distribution can be displayed with surface, contour, or vector-” eld

plots. These plots can be placed anywhere on the worksheet by clicking to the desired

location. This places a red crosshair at that location. Then, use the Insert/Graph pull-down

menu to place an empty plot on the worksheet with placeholders for the expressions to

be graphed and for the ranges of variables. Simply type S in the placeholder on the

z axis. Mathcad does the rest to produce the graphs shown in Fig. 31.16. Once the graph

has been created, you can use the Format/Surface Plot and Format/Contour Plot pull-

down menus to change the color or add titles, labels, and other features.

FIGURE 31.16 Mathcad screen to determine the solution of an elliptic PDE.

PROBLEMS

31.1 Repeat Example 31.1, but for T(0, t) 5 75 and T(10, t) 5 150

and a uniform heat source of 15.

31.2 Repeat Example 31.2, but for boundary conditions of T(0, t)

5 75 and T(10, t) 5 150 and a heat source of 15.

31.3 Apply the results of Prob. 31.2 to compute the temperature

distribution for the entire rod using the ” nite-element approach.

31.4 Use Galerkin’s method to develop an element equation for a

steady-state version of the advection-diffusion equation described

in Prob. 30.7. Express the ” nal result in the format of Eq. (31.26) so

that each term has a physical interpretation.

31.5 A version of the Poisson equation that occurs in mechanics is

the following model for the vertical de! ection of a bar with a dis-

tributed load P(x):

AcE 0

2u

0x2 5 P(x)

PROBLEMS 913

where Ac 5 cross-sectional area, E 5 Young’s modulus, u 5 de! ec-

tion, and x 5 distance measured along the bar’s length. If the bar is

rigidly ” xed (u 5 0) at both ends, use the ” nite-element method to

model its de! ections for Ac 5 0.1 m 2, E 5 200 3 109 N/m2, L 5 10 m,

and P(x) 5 1000 N/m. Employ a value of Dx 5 2 m.

31.6 Develop a user-friendly program to model the steady-state

distribution of temperature in a rod with a constant heat source us-

ing the ” nite-element method. Set up the program so that unequally

spaced nodes may be used.

31.7 Use Excel to perform the same computation as in Fig. 31.14, but

insulate the right-hand edge and add a heat sink of 2150 at cell C7.

31.8 Use MATLAB or Mathcad to develop a contour plot with ! ux

arrows for the Excel solution from Prob. 31.7.

31.9 Use Excel to model the temperature distribution of the slab

shown in Fig. P31.9. The slab is 0.02 m thick and has a thermal

conductivity of 3 W/(m ? 8C).

of the rod has a ” xed temperature gradient and the temperature is a

variable. The right end has a ” xed temperature and the gradient is a

variable. The heat source f(x) has a constant value. Thus, the condi-

tions are

dT

0x ` x50

5 0.25°C/m T Z x550 5 100°C f (x) 5 30 W/cm

Develop the nodal equations that must be solved for the tempera-

tures and temperature gradients at each of the six nodes. Assemble

the equations, insert the boundary conditions, and solve the result-

ing set for the unknowns.

31.12 Find the temperature distribution in a rod (Fig. P31.12) with

internal heat generation using the ” nite-element method. Derive the

element nodal equations using Fourier heat conduction.

qk 5 2kA dT

0x

and heat conservation relationships

a [qk 1 f (x) ] 5 0

100 C

50 C

75 C 25 C

2 m

0.6 m

1 m 0.4 m

–100 W/m2

FIGURE P31.9

31.10 Use MATLAB or Mathcad to develop a contour plot with

! ux arrows for the Excel solution from Prob. 31.9.

31.11 Find the temperature distribution in a rod (Fig. P31.11) with

internal heat generation using the ” nite-element method. Derive the

element nodal equations using Fourier heat conduction

qk 5 2kA dT

0x

and heat conservation relationships

a [qk 1 f (x) ] 5 0

where qk 5 heat ! ow (W), k 5 thermal conductivity (W/(m ? 8C)),

A 5 cross-sectional area (m2), and f(x) 5 heat source (W/cm). The

rod has a value of kA 5 100 W m/8C. The rod is 50 cm long, the

x-coordinate is zero at the left end, and positive to the right. Divide

the rod into ” ve elements (six nodes, each 10 cm long). The left end

FIGURE P31.11

kA = 100 W/m · C

f(x) = 30 W/cm

50 cm

dT –– dx x=0

= 0.25 C/m

T x=50 = 100 Cx

FIGURE P31.12

kA = 50 W·m/ C

kA = 100 W·m/ C f(x) = 30 W/cm

50 cm

Tx=0 = 100 C

x

Tx=50 = 50 C

914 FINITE-ELEMENT METHOD

where qk 5 heat ! ow (W), k 5 thermal conductivity [W/(m ? 8C)],

A 5 cross-sectional area (m2), and f(x) 5 heat source (W/cm). The

rod is 50 cm long, the x-coordinate is zero at the left end, and posi-

tive to the right. The rod is also linearly tapered with a value of

kA 5 100 and 50 W m/8C at x 5 0 and at x 5 50, respectively. Divide

the rod into ” ve elements (six nodes, each 10 cm long). Both ends of

the rod have ” xed temperatures. The heat source f(x) has a constant

value. Thus, the conditions are

T Z x50 5 100°C T Z x550 5 50°C f (x) 5 30 W/cm

The tapered areas must be treated as if they were constant over the

length of an element. Therefore, average the kA values at each end

of the node and take that average as a constant over the node.

Develop the nodal equations that must be solved for the temperatures

and temperature gradients at each of the six nodes. Assemble the

equations, insert the boundary conditions, and solve the resulting

set for the unknowns.

31.13 Use a software package to solve for the temperature distribu-

tion of the L-shaped plate in Fig. P29.18. Display your results as a

contour plot with ! ux arrows.

915

32 C H A P T E R 32

Case Studies: Partial Differential Equations

The purpose of this chapter is to apply the methods from Part Eight to practical engineer-

ing problems. In Sec. 32.1, a parabolic PDE is used to compute the time-variable distri-

bution of a chemical along the longitudinal axes of a rectangular reactor. This example

illustrates how the instability of a solution can be due to the nature of the PDE rather

than to properties of the numerical method.

Sections 32.2 and 32.3 involve applications of the Poisson and Laplace equations to

civil and electrical engineering problems, respectively. Among other things, this will

allow you to see similarities as well as differences between ! eld problems in these areas

of engineering. In addition, they can be contrasted with the heated-plate problem that

has served as our prototype system in this part of the book. Section 32.2 deals with the

de” ection of a square plate, whereas Sec. 32.3 is devoted to computing the voltage dis-

tribution and charge ” ux for a two-dimensional surface with a curved edge.

Section 32.4 presents a ! nite-element analysis as applied to a series of springs. This

application is closer in spirit to ! nite-element applications in mechanics and structures

than was the temperature ! eld problem used to illustrate the approach in Chap. 31.

32.1 ONE-DIMENSIONAL MASS BALANCE OF A REACTOR (CHEMICAL/BIO ENGINEERING)

Background. Chemical engineers make extensive use of idealized reactors in their design work. In Secs. 12.1 and 28.1, we focused on single or coupled well-mixed reactors. These

are examples of lumped-parameter systems (recall Sec. PT3.1.2).

FIGURE 32.1 An elongated reactor with a single entry and exit point. A mass balance is developed around a fi nite segment along the tank’s longitudinal axis in order to derive a differential equation for the concentration. x

x = 0 x = L

916 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

Figure 32.1 depicts an elongated reactor with a single entry and exit point. This reac-

tor can be characterized as a distributed-parameter system. If it is assumed that the chem-

ical being modeled is subject to ! rst-order decay1 and the tank is well-mixed vertically

and laterally, a mass balance can be performed on a ! nite segment of length Dx, as in

V ¢c

¢t 5 Qc(x)

Flow in

2 Q c c(x) 1 0c(x) 0x

¢x d Flow out

2 DAc 0c(x)

0x

Dispersion in

1DA c c 0c(x) 0x

1 0

0x 0c(x)

0x ¢x d

Dispersion out

2 kVc

Decay reaction

(32.1)

where V 5 volume (m3), Q 5 ! ow rate (m3/h), c is concentration (moles/m3), D is a

dispersion coef” cient (m2/h), Ac is the tank’s cross-sectional area (m 2), and k is the ” rst-

order decay coef” cient (h21). Note that the dispersion terms are based on Fick’s ! rst law,

Flux 5 2D 0c

0x (32.2)

which is directly analogous to Fourier’s law for heat conduction [recall Eq. (29.4)]. It

speci” es that turbulent mixing tends to move mass from regions of high to low concen-

tration. The parameter D, therefore, re! ects the magnitude of turbulent mixing.

If Dx and Dt are allowed to approach zero, Eq. (32.1) becomes

0c

0t 5 D

0 2c

0x2 2 U

0c

0x 2 kc (32.3)

where U 5 QyAc is the velocity of the water ! owing through the tank. The mass balance

for Fig. 32.1 is, therefore, now expressed as a parabolic partial differential equation.

Equation (32.3) is sometimes referred to as the advection-dispersion equation with ” rst-

order reaction. At steady state, it is reduced to a second-order ODE,

0 5 D d2c

dx2 2 U

d 2c

dx 2 kc (32.4)

Prior to t 5 0, the tank is ” lled with water that is devoid of the chemical. At t 5 0,

the chemical is injected into the reactor’s in! ow at a constant level of cin. Thus, the fol-

lowing boundary conditions hold:

Qcin 5 Qc0 2 DAc 0c0

0x

and

c¿(L, t) 5 0

The second condition speci” es that the chemical leaves the reactor purely as a function

of ! ow through the outlet pipe. That is, it is assumed that dispersion in the reactor does

1That is, the chemical decays at a rate that is linearly proportional to how much chemical is present.

⎧ ⎨ ⎩

⎧ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎩ ⎧ ⎪ ⎨ ⎪ ⎩

⎧ ⎪ ⎪ ⎪ ⎪ ⎪ ⎨ ⎪ ⎪ ⎪ ⎪ ⎪ ⎩

32.1 ONE-DIMENSIONAL MASS BALANCE OF A REACTOR 917

not affect the exit rate. Under these conditions, use numerical methods to solve Eq. (32.4)

for the steady-state levels in the reactor. Note that this is an ODE boundary-value

problem. Then solve Eq. (32.3) to characterize the transient response—that is, how the

levels change in time as the system approaches the steady state. This application in-

volves a PDE.

Solution. A steady-state solution can be developed by substituting centered ” nite dif- ferences for the ” rst and the second derivatives in Eq. (32.4) to give

0 5 D ci11 2 2ci 1 ci21

¢x2 2 U

ci11 2 ci21

2¢x 2 kci

Collecting terms gives

2a D U¢x

1 1

2 b ci21 1 a 2D

U¢x 1

k ¢x

U b c0 2 a D

U¢x 2

1

2 b ci11 5 0 (32.5)

This equation can be written for each of the system’s nodes. At the reactor’s ends, this

process introduces nodes that lie outside the system. For example, at the inlet node (i 5 0),

2a D U¢x

1 1

2 b c21 1 a 2D

U¢x 1

k ¢x

U b c0 2 a D

U¢x 2

1

2 b c1 5 0 (32.6)

The c21 can be removed by invoking the ” rst boundary condition. At the inlet, the

following mass balance must hold:

Qcin 5 Qc0 2 DAc 0c0

0x

where c0 5 concentration at x 5 0. Thus, this boundary condition speci” es that the

amount of chemical carried into the tank by advection through the pipe must be equal

to the amount carried away from the inlet by both advection and turbulent dispersion in

the tank. A ” nite divided difference can be substituted for the derivative

Qcin 5 Qc0 2 DAc c1 2 c21

2 ¢x

which can be solved for

c21 5 c1 1 2 ¢xU

D cin 2

2 ¢xU

D c0

which can be substituted into Eq. (32.6) to give

a 2 D U ¢x

1 k ¢x

U 1 2 1

¢x U

D b c0 2 a 2D

U¢x b c1 5 a2 1 ¢xU

D b cin (32.7)

A similar exercise can be performed for the outlet, where the original difference

equation is

2a D U¢x

1 1

2 b cn21 1 a 2 D

U¢x 1

k ¢x

U b cn 2 a D

U¢x 2

1

2 b cn11 5 0 (32.8)

918 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

The boundary condition at the outlet is

Q cn 2 DAc dcn

dx 5 Qcn

As with the inlet, a divided difference can be used to approximate the derivative.

Qcn 2 DAc cn11 2 cn21

2 ¢x 5 Qcn (32.9)

Inspection of this equation leads us to conclude that cn11 5 cn21. In other words, the slope

at the outlet must be zero for Eq. (32.9) to hold. Substituting this result into Eq. (32.8)

and simplifying gives

2a 2D U¢x

b cn21 1 a 2D U¢x

1 k ¢x

U b cn 5 0 (32.10)

Equations (32.5), (32.7), and (32.10) now form a system of n tridiagonal equations

with n unknowns. For example, if D 5 2, U 5 1, Dx 5 2.5, k 5 0.2, and cin 5 100,

the system isE 5.35 21.621.3 2.1 20.321.3 2.1 20.3 21.3 2.1 20.3

21.6 2.1

U ec0c1c2 c3

c4

u 5 e32500 0

0

u which can be solved for

c0 5 76.44 c1 5 52.47 c2 5 36.06

c3 5 25.05 c4 5 19.09

These results are plotted in Fig. 32.2. As expected, the concentration decreases due to

the decay reaction as the chemical ! ows through the tank. In addition to the above

computation, Fig. 32.2 shows another case with D 5 4. Notice how increasing the tur-

bulent mixing tends to ! atten the curve.

FIGURE 32.2 Concentration versus distance along the longitudinal axis of a rectangular reactor for a chemical that decays with fi rst- order kinetics.

c

20

40

60

80

100

0 2.5 5 7.5 10 x

D = 2

D = 4

32.2 DEFLECTIONS OF A PLATE 919

In contrast, if dispersion is decreased, the curve would become steeper as mixing became

less important relative to advection and decay. It should be noted that if dispersion is decreased

too much, the computation will become subject to numerical errors. This type of error is

referred to as static instability to contrast it with the dynamic instability due to too large a

time step during a dynamic computation. The criterion to avoid this static instability is

¢x # 2D

U

Thus, the criterion becomes more stringent (lower Dx) for cases where advection domi-

nates over dispersion.

Aside from steady-state computations, numerical methods can be used to generate time-

variable solutions of Eq. (32.3). Figure 32.3 shows results for D 5 2, U 5 1, Dx 5 2.5,

k 5 0.2, and cin 5 100, where the concentration in the tank is 0 at time zero. As expected,

the immediate impact is near the inlet. With time, the solution eventually approaches the

steady-state level.

It should be noted that in such dynamic calculations, the time step is constrained by

a stability criterion expressed as (Chapra, 1997)

¢t # (¢x)2

2D 1 k(¢x)2

Thus, the reaction term acts to make the time step smaller.

32.2 DEFLECTIONS OF A PLATE (CIVIL/ENVIRONMENTAL ENGINEERING)

Background. A square plate with simply supported edges is subject to an areal load q (Fig. 32.4). The de! ection in the z dimension can be determined by solving the elliptic

PDE (see Carnahan, Luther, and Wilkes, 1969)

0 4z

0x4 1 2

0 4z

0x20y2 1 0

4z

0y4 5

q

D (32.11)

FIGURE 32.3 Concentration versus distance at different times during the buildup of chemical in a reactor.

c

100

100 x

Steady state t = 0.4

t = 0.8 t = 1.6 t = 3.2 t = 0.2

920 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

subject to the boundary conditions that, at the edges, the de! ection and slope normal to

the boundary are zero. The parameter D is the ! exural rigidity,

D 5 E ¢z3

12(1 2 s2) (32.12)

where E 5 the modulus of elasticity, Dz 5 the plate’s thickness, and s 5 Poisson’s ratio.

If a new variable is de” ned as

u 5 0

2z

0x2 1 0

2z

0y2

Eq. (32.11) can be reexpressed as

0 2u

0x2 1 0

2u

0y2 5

q

D (32.13)

Therefore, the problem reduces to successively solving two Poisson equations. First,

Eq. (32.13) can be solved for u subject to the boundary condition that u 5 0 at the edges.

Then, the results can be employed in conjunction with

0 2z

0x2 1 0

2z

0y2 5 u (32.14)

to solve for z subject to the condition that z 5 0 at the edges.

Develop a computer program to determine the de! ections for a square plate subject to

a constant areal load. Test the program for a plate with 2-m-long edges, q 5 33.6 kN/m2,

s 5 0.3, Dz 5 1022 m, and E 5 2 3 1011 Pa. Employ Dx 5 Dy 5 0.5 m for your test run.

Solution. Finite-divided differences can be substituted into Eq. (32.13) to give

ui11, j 2 2ui, j 1 ui21, j

¢x2 1

ui, j11 2 2ui, j 1 ui, j21

¢y2 5

q

D (32.15)

Equation (32.12) can be used to compute D 5 1.832 3 104 N/m. This result, along with

the other system parameters, can be substituted into Eq. (32.15) to give

ui11, j 1 ui21, j 1 ui, j11 1 ui, j21 2 4ui, j 5 0.458

FIGURE 32.4 A simply supported square plate subject to an areal load.

y

z

x

z

32.3 TWO-DIMENSIONAL ELECTROSTATIC FIELD PROBLEMS 921

This equation can be written for all the nodes with the boundaries set at u 5 0. The

resulting equations are

I24 1 11 24 1 11 24 11 24 1 11 1 24 1 1 1 1 24 1

1 24 1

1 1 24 1

1 1 24

Y iu1, 1u2, 1u3, 1u1, 2u2, 2 u3, 2

u1, 3

u2, 3

u3, 3

y 5 i0.4580.4580.4580.4580.458 0.458

0.458

0.458

0.458

y which can be solved for

u1, 1 5 20.315 u1, 2 5 20.401 u1, 3 5 20.315

u2, 1 5 20.401 u2, 2 5 20.515 u2, 3 5 20.401

u3, 1 5 20.315 u3, 2 5 20.401 u3, 3 5 20.315

These results in turn can be substituted into Eq. (32.14), which can be written in ” nite-

difference form and solved for

z1, 1 5 0.063 z1, 2 5 0.086 z1, 3 5 0.063

z2, 1 5 0.086 z2, 2 5 0.118 z2, 3 5 0.086

z3, 1 5 0.063 z3, 2 5 0.086 z3, 3 5 0.063

32.3 TWO-DIMENSIONAL ELECTROSTATIC FIELD PROBLEMS (ELECTRICAL ENGINEERING)

Background. Just as Fourier’s law and the heat balance can be employed to character- ize temperature distribution, analogous relationships are available to model ” eld prob-

lems in other areas of engineering. For example, electrical engineers use a similar

approach when modeling electrostatic ” elds.

Under a number of simplifying assumptions, an analog of Fourier’s law can be

represented in one-dimensional form as

D 5 2e dV

dx

where D is called the electric ! ux density vector, e 5 permittivity of the material, and

V 5 electrostatic potential.

Similarly, a Poisson equation for electrostatic ” elds can be represented in two dimen-

sions as

0 2V

0x2 1 0

2V

0y2 5 2

ry

e (32.16)

where ry 5 volumetric charge density.

922 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

Finally, for regions containing no free charge (that is ry 5 0), Eq. (32.16) reduces

to a Laplace equation,

0 2V

0x2 1 0

2V

0y2 5 0 (32.17)

Employ numerical methods to solve Eq. (32.17) for the situation depicted in Fig. 32.5.

Compute both the values for V and for D if e 5 2.

Solution. Using the approach outlined in Sec. 29.3.2, Eq. (29.24) can be written for node (1, 1) as

2

¢x2 c V1,1 2 V0,1 a1(a1 1 a2)

1 V1,1 2 V2,1

a2(a1 1 a2) d 1 2 ¢y2

c V1,1 2 V0,1 b1(b1 1 b2)

1 V1,1 2 V2,1

b2(b1 1 b2) d 5 0

According to the geometry depicted in Fig. 32.5, Dx 5 3, Dy 5 2, b1 5 b2 5 a2 5 1,

and a1 5 0.94281. Substituting these values yields

0.12132 V1, 1 2 121.32 1 0.11438 V1, 1 2 0.11438 V2, 1 1 0.25 V1, 1

10.25 V1, 1 2 0.25 V1, 2 5 0

Collecting terms gives

0.73570 V1,1 2 0.11438 V2,1 2 0.25 V1, 2 5 121.32

FIGURE 32.5 (a) A two-dimensional system with a voltage of 1000 along the circular boundary and a voltage of 0 along the base. (b) The nodal numbering scheme.

(a)

(b)

6

1000

1000

3

2

0 0

2,3

1,3

0,2

0,1

3,3

4,2

4,1

1,0 2,0 3,0

1,1 2,1 3,1

3,22,21,2

32.3 TWO-DIMENSIONAL ELECTROSTATIC FIELD PROBLEMS 923

A similar approach can be applied to the remaining interior nodes. The resulting

simultaneous equations can be expressed in matrix form asF 0.73570 20.11438 20.2500020.11111 0.72222 20.11111 20.2500020.11438 0.73570 20.25000 20.31288 1.28888 20.14907

20.25000 20.11111 0.72222 20.11111

20.31288 20.14907 1.28888

V 3 fV1, 1V2, 1V3, 1

V1, 2

V2, 2

V3, 2

v 5 f121.320121.32 826.92

250

826.92

v which can be solved for

V1, 1 5 521.19 V2, 1 5 421.85 V3, 1 5 521.19

V1, 2 5 855.47 V2, 2 5 755.40 V3, 2 5 855.47

These results are depicted in Fig. 32.6a.

To compute the ! ux (recall Sec. 29.2.3), Eqs. (29.14) and (29.15) must be modi-

” ed to account for the irregular boundaries. For the present example, the modi” cations

FIGURE 32.6 The results of solving the Laplace equation with correc- tion factors for the irregular boundaries. (a) Potential and (b) fl ux.

(a)

(b)

1000

1000

10001000

1000

1000

1000

0 00

855 755 855

521 422 521

924 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

result in

Dx 5 2e Vi11, j 2 Vi21, j

(a1 1 a2) ¢x

and

Dy 5 2e Vi, j11 2 Vi, j21

(b1 1 b2)¢y

For node (1, 1), these formulas can be used to compute the x and y components of the ! ux

Dx 5 22 421.85 2 1000

(0.94281 1 1)3 5 198.4

and

Dy 5 22 855.47 2 0

(1 1 1)2 5 2427.7

which in turn can be used to calculate the electric ! ux density vector

D 5 2198.42 1 (2427.7)2 5 471.5 with a direction of

u 5 tan21 a2427.7 198.4

b 5 265.1° The results for the other nodes are

Node Dx Dy D U

2, 1 0.0 2377.7 377.7 290 3, 1 2198.4 2427.7 471.5 245.1 1, 2 109.4 2299.6 281.9 269.1 2, 2 0.0 2289.1 289.1 290.1 3, 2 2109.4 2299.6 318.6 249.9

The ! uxes are displayed in Fig. 32.6b.

32.4 FINITE-ELEMENT SOLUTION OF A SERIES OF SPRINGS (MECHANICAL/AEROSPACE ENGINEERING)

Background. Figure 32.7 shows a series of interconnected springs. One end is ” xed to a wall, whereas the other is subject to a constant force F. Using the step-by-step

procedure outlined in Chap. 31, a ” nite-element approach can be employed to determine

the displacements of the springs.

Solution.

Discretization. The way to partition this system is obviously to treat each spring as an

element. Thus, the system consists of four elements and ” ve nodes (Fig. 32.7b).

32.4 FINITE-ELEMENT SOLUTION OF A SERIES OF SPRINGS 925

Element equations. Because this system is so simple, its element equations can be

written directly without recourse to mathematical approximations. This is an example of

the direct approach for deriving elements.

Figure 32.8 shows an individual element. The relationship between force F and

displacement x can be represented mathematically by Hooke’s law:

F 5 kx

where k 5 the spring constant, which can be interpreted as the force required to cause a

unit displacement. If a force F1 is applied at node 1, the following force balance must hold:

F 5 k(x1 2 x2)

where x1 5 displacement of node 1 from its equilibrium position and x2 5 displacement

of node 2 from its equilibrium position. Thus, x2 2 x1 represents how much the spring

is elongated or compressed relative to equilibrium (Fig. 32.8).

This equation can also be written as

F1 5 kx1 2 kx2

For a stationary system, a force balance also necessitates that F1 5 2F2 and, therefore,

F2 5 2kx1 1 kx2

FIGURE 32.7 (a) A series of interconnected springs. One end is fi xed to a wall, whereas the other is sub- ject to a constant force F. (b) The fi nite-element representa- tion. Each spring represents an element. Therefore, the system consists of four elements and fi ve nodes.

1 2 3 4 5

1 2 3 4

Force

(a)

(b)

Node

Element

FIGURE 32.8 A free-body diagram of a spring system.

Node 1 Node 2

F1 F2

0 x1 x2 x

926 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

These two simultaneous equations specify the behavior of the element in response to

prescribed forces. They can be written in matrix form as

c k 2k 2k k

d e x1 x2 f 5 eF1

F2 f

or

[k]{x} 5 {F} (32.18)

where the matrix [k] is the element property matrix. For this case, it is also referred to

as the element stiffness matrix. Notice that Eq. (32.18) has been cast in the format of

Eq. (31.9). Thus, we have succeeded in generating a matrix equation that describes the

behavior of a typical element in our system.

Before proceeding to the next step—the assembly of the total solution—we will

introduce some notation. The elements of [k] and {F} are conventionally superscripted

and subscripted, as in

c k(e)11 2k(e)12 2k

(e)

21 k (e)

22

d e x1 x2 f 5 eF(e)1

F (e)2 f

where the superscript (e) designates that these are the element equations. The k’s are also

subscripted as kij to denote their location in the ith row and jth column of the matrix.

For the present case, they can also be physically interpreted as representing the force

required at node i to induce a unit displacement at node j.

Assembly. Before the element equations are assembled, all the elements and nodes must

be numbered. This global numbering scheme speci” es a system con” guration or topology

(note that the present case uses a scheme identical to Table 31.1). That is, it documents

which nodes belong to which element. Once the topology is speci” ed, the equations for

each element can be written with reference to the global coordinates.

The element equations can then be added one at a time to assemble the total system.

The ” nal result can be expressed in matrix form as [recall Eq. (31.10)]

[k]{x¿} 5 {F¿}

where

[k] 5 E k(1)11 2k(1)122k(1)21 k(1)22 1 k(2)11 2k(2)122k(2)21 k(2)22 1 k(3)11 2k(3)12 2k(3)21 k

(3) 22 1 k

(4) 11 2k

(4) 12

2k(4)21 k (4) 22

U (32.19) and

{F¿} 5 eF (1)100 0

F (4) 2

u

32.4 FINITE-ELEMENT SOLUTION OF A SERIES OF SPRINGS 927

and {x9} and {F9} are the expanded displacement and force vectors, respectively. Notice

that, as the equations were assembled, the internal forces cancel. Thus, the ” nal result

for {F9} has zeros for all but the ” rst and last nodes.

Before proceeding to the next step, we must comment on the structure of the assem-

blage property matrix [Eq. (32.19)]. Notice that the matrix is tridiagonal. This is a direct

result of the particular global numbering scheme that was chosen (Table 31.1) prior to

assemblage. Although it is not very important in the present context, the attainment of

such a banded, sparse system can be a decided advantage for more complicated problem

settings. This is due to the ef” cient schemes that are available for solving such systems.

Boundary Conditions. The present system is subject to a single boundary condition,

x1 5 0. Introduction of this condition and applying the global renumbering scheme re-

duces the system to (k9s 5 1)D 2 2121 2 21 21 2 21

21 1

T dx2x3 x4

x5

t 5 d00 0

F

t The system is now in the form of Eq. (31.11) and is ready to be solved.

Although reduction of the equations is certainly a valid approach for incorporating

boundary conditions, it is usually preferable to leave the number of equations intact when

performing the solution on the computer. Whatever the method, once the boundary con-

ditions are incorporated, we can proceed to the next step—the solution.

Generating Solution. Using one of the approaches from Part Three, such as the ef” –

cient tridiagonal solution technique delineated in Chap. 11, the system can be solved for

(with all k9s 5 1 and F 5 1)

x2 5 1 x3 5 2 x4 5 3 x5 5 4

Postprocessing. The results can now be displayed graphically. As in Fig. 32.9, the

results are as expected. Each spring is elongated a unit displacement.

FIGURE 32.9 (a) The original spring system. (b) The system after the application of a constant force. The dis- placements are indicated in the space between the two systems.

F x = 1

x = 2

x = 3

x = 4

(a)

(b)

928 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

PROBLEMS

Chemical/Bio Engineering

32.1 Perform the same computation as in Sec. 32.1, but use

Dx 5 1.25.

32.2 Develop a ” nite-element solution for the steady-state system

of Sec. 32.1.

32.3 Compute mass ! uxes for the steady-state solution of Sec. 32.1

using Fick’s ” rst law.

32.4 Compute the steady-state distribution of concentration for the

tank shown in Fig. P32.4. The PDE governing this system is

D a 02c 0x2

1 0

2c

0y2 b 2 kc 5 0

and the boundary conditions are as shown. Employ a value of 0.5

for D and 0.1 for k.

32.5 Two plates are 10 cm apart, as shown in Fig. P32.5. Initially, both

plates and the ! uid are still. At t 5 0, the top plate is moved at a constant

velocity of 8 cm/s. The equations governing the motions of the ! uids are

0 yoil

0t 5 moil

0 2yoil

0x2 and

0 ywater

0t 5 mwater

0 2ywater

0x2

and the following relationships hold true at the oil-water interface:

yoil 5 ywater and moil 0yoil

0x 5 mwater

0ywater

0x

What is the velocity of the two ! uid layers at t 5 0.5, 1, and 1.5 s

at distances x 5 2, 4, 6, and 8 cm from the bottom plate? Note that

mwater and moil 5 1 and 3 cp, respectively.

32.6 The displacement of a uniform membrane subject to a tension

and a uniform pressure can be described by the Poisson equation

0 2z

0x2 1 0

2z

0y2 5 2

P

T

Solve for the displacement of a 1-cm-square membrane that has

PyT 5 0.6/cm and is fastened so that it has zero displacement along

its four boundaries. Employ Dx 5 Dy 5 0.1 cm. Display your re-

sults as a contour plot.

Civil/Environmental Engineering

32.7 Perform the same computation as in Sec. 32.2, but use

Dx 5 Dy 5 0.4 m.

32.8 The ! ow through porous media can be described by the

Laplace equation

0 2h

0x2 1 0

2h

0y2 5 0

where h is head. Use numerical methods to determine the distribu-

tion of head for the system shown in Fig. P32.8.

FIGURE P32.4

30

10

10

Open boundary

Wall

c = 40

c = 100

FIGURE P32.5

Oil

Water

10

8

6

4

2

x = 0

FIGURE P32.8

2

= 0

12

­h

­y

= 0

h = 20

­h

­n

= 0­h ­y

= 1­h ­x

PROBLEMS 929

32.9 The velocity of water ! ow through the porous media can be

related to head by D’Arcy’s law

qn 5 2K dh

dn

where K is the hydraulic conductivity and qn is discharge velocity

in the n direction. If K 5 5 3 1024 cm/s, compute the water ve-

locities for Prob. 32.8.

Electrical Engineering

32.10 Perform the same computation as in Sec. 32.3 but for the

system depicted in Fig. P32.10.

32.11 Perform the same computation as in Sec. 32.3 but for the

system depicted in Fig. P32.11.

32.12 Use Poisson’s equation to compute the electric potential

over a unit square (1 3 1) plate with zero voltage at the edges and

point charge sources of ryye (0.7, 0.7) 5 1 and ryye (0.3, 0.3) 5 21.

Employ Dx 5 Dy 5 0.1 and display your results as a contour plot.

Mechanical/Aerospace Engineering

32.13 Perform the same computation as in Sec. 32.4, but change

the force to 1.5 and the spring constants to

Spring 1 2 3 4

k 0.75 1.5 0.5 2

32.14 Perform the same computation as in Sec. 32.4, but use a

force of 2 and ” ve springs with

Spring 1 2 3 4 5

k 0.25 0.5 1.5 0.75 1

32.15 An insulated composite rod is formed of two parts arranged

end to end, and both halves are of equal length. Part a has thermal

conductivity ka, for 0 # x # 1y2, and part b has thermal conductiv-

ity kb, for 1y2 # x # 1. The nondimensional transient heat conduc-

tion equations that describe the temperature u over the length x of

the composite rod are

0 2u

0x2 5 0u

0t 0 # x # 1y2

r 0

2u

0x2 5 0u

0t 1y2 # x # 1

where u 5 temperature, x 5 axial coordinate, t 5 time, and r 5 kaykb.

The boundary and initial conditions are

Boundary conditions u(0, t ) 5 1 u(1, t ) 5 1

a 0u 0x b

a 5 a 0u 0x b

b x 5 1/2

Initial conditions u(x, 0) 5 0 0 , x , 1

Solve this set of equations for the temperature distribution as a func-

tion of time. Use second-order accurate ” nite-difference analogues

for the derivatives with a Crank-Nicolson formulation to integrate in

time. Write a computer program for the solution, and select values of

Dx and Dt for good accuracy. Plot the temperature u versus length x

for various values of time t. Generate a separate curve for the follow-

ing values of the parameter r 5 1, 0.1, 0.01, 0.001, and 0.

32.16 Solve the nondimensional transient heat conduction equa-

tion in two dimensions, which represents the transient temperature

distribution in an insulated plate. The governing equation is

0 2u

0x2 1 0

2u

0y2 5 0u

0t

FIGURE P32.10

FIGURE P32.11

a

V = 10

V = 0

V = 5

V = 40

V = 20

a

V = 10

2

= 0

111

­V

­y

= 0­V ­y

= 0­V ­x

V = 70

V = 100

930 CASE STUDIES: PARTIAL DIFFERENTIAL EQUATIONS

where u 5 temperature, x and y are spatial coordinates, and

t 5 time. The boundary and initial conditions are

Boundary conditions u(x, 0, t ) 5 0 u(x, 1, t ) 5 1

u(0, y, t ) 5 0 u(1, y, t ) 5 1

Initial condition u(x, y, 0) 5 0 0 # x , 1 0 # y , 1

Solve using the alternating direction-implicit technique. Write a

computer program to implement the solution. Plot the results using

a three-dimensional plotting routine where the horizontal plan con-

tains the x and y axes and the z axis is the dependent variable u.

Construct several plots at various times, including the following:

(a) the initial conditions; (b) one intermediate time, approximately

halfway to steady state; and (c) the steady-state condition.

27.1 CURRENT 1ST LEVEL HEAD 931

931

PT8.3 TRADE-OFFS

The primary trade-offs associated with numerical methods for the solution of partial

differential equations involve choosing between  nite-difference and  nite-element ap-

proaches. The ! nite-difference methods are conceptually easier to understand. In addi-

tion, they are easy to program for systems that can be approximated with uniform grids.

However, they are dif! cult to apply to systems with complicated geometries.

Finite-difference approaches can be divided into categories depending on the type

of PDE that is being solved. Elliptic PDEs can be approximated by a set of linear alge-

braic equations. Consequently, the Liebmann method (which, in fact, is Gauss-Seidel)

can be employed to obtain a solution iteratively.

One-dimensional parabolic PDEs can be solved in two fundamentally different ways:

explicit or implicit approaches. The explicit method steps out in time in a fashion that is

similar to Euler’s technique for solving ODEs. It has the advantage that it is simple to

program but has the shortcoming of a very stringent stability criterion. In contrast, stable

implicit methods are available. These typically involve solving simultaneous tridiagonal

algebraic equations at each time step. One of these approaches, the Crank-Nicolson method,

is both accurate and stable and, therefore, is widely used for one-dimensional linear para-

bolic problems.

Two-dimensional parabolic PDEs can also be modeled explicitly. However, their

stability constraints are even more severe than for the one-dimensional case. Special

implicit approaches, which are generally referred to as splitting methods, have been

developed to circumvent this shortcoming. These approaches are both ef! cient and stable.

One of the most common is the ADI, or alternating-direction implicit, method.

All the above  nite-difference approaches become unwieldy when applied to systems

involving nonuniform shapes and heterogeneous conditions. Finite-element methods are

available that handle such systems in a superior fashion.

Although the  nite-element method is based on some fairly straightforward ideas,

the mechanics of generating a good ! nite-element code for two- and three-dimensional

problems is not a trivial exercise. In addition, it can be computationally expensive for

large problems. However, it is vastly superior to ! nite-difference approaches for systems

involving complicated shapes. Consequently, its expense and conceptual “overhead” are

often justi! ed because of the detail of the ! nal solution.

PT8.4 IMPORTANT RELATIONSHIPS AND FORMULAS

Table PT8.3 summarizes important information that was presented regarding the ! nite-

difference methods in Part Eight. This table can be consulted to quickly access important

relationships and formulas.

EPILOGUE: PART EIGHT

932 EPILOGUE: PART EIGHT

TABLE PT8.3 Summary of fi nite-difference methods.

Computational Molecule Equation

Elliptic PDEs

i – 1, j i, j i + 1, j

i, j + 1

i, j – 1

Ti,j 5 Ti11,j 1 Ti21,j 1 Ti,j11 1 Ti,j21

4 Liebmann’s method

Parabolic PDEs (one-dimensional) Explicit method

i – 1, l i, l i + 1, l

i, l + 1

T l11i 5 T

l i 1 l(T

l i11 2 2T

l i 1 T

l i21)

Implicit method

i – 1, l + 1

i, l

i + 1, l + 1i, l + 1

2lT l11i21 1 (1 1 2l)T l11 i 2 lT

l11 i11 5 T

l i

Crank-Nicolson method

i – 1, l + 1

i – 1, l i, l

i + 1, l + 1

i + 1, l

i, l + 1

i, l + 1 2

2lT l11i21 1 2(1 1 l)T l11 i 2 lT

l11 i11

5 lT li21 1 2(1 2 l)T l i 1 lT

l i11

PT8.5 ADVANCED METHODS AND ADDITIONAL REFERENCES

Carnahan, Luther, and Wilkes (1969); Rice (1983); Ferziger (1981); and Lapidus and

Pinder (1981) provide useful surveys of methods and software for solving PDEs. You

can also consult Ames (1977), Gladwell and Wait (1979), Vichnevetsky (1981, 1982), and

Zienkiewicz (1971) for more in-depth treatments. Additional information on the ! nite-

element method can be found in Allaire (1985), Huebner and Thornton (1982), Stasa

(1985), and Baker (1983). Aside from elliptic and hyperbolic PDEs, numerical methods

are also available to solve hyperbolic equations. Nice introductions and summaries of

some of these methods can be found in Lapidus and Pinder (1981), Ferziger (1981),

Forsythe and Wasow (1960), and Hoffman (1992).

933

The Fourier Series

A A P P E N D I X A

The Fourier series can be expressed in a number of different

formats. Two equivalent trigonometric expressions are

f(t) 5 a0 1 a q

k51

[ak cos (kv0t) 1 bk sin (kv0t)]

or

f(t) 5 a0 1 a q

k51

[ck cos (kv0t 1 uk)]

where the coef! cients are related by (see Fig. A.1)

ck 5 2a2k 1 b2k and

uk 5 2tan 21 abk

ak b

In addition to the trigonometric formats, the series can

also be expressed in terms of the exponential function as

f(t) 5 c̃0 1 a q

k51

[c̃k e ikv0t

1 c̃2k e 2ikv0 t] (A.1)

where (see Fig. A.2)

c̃0 5 a0

c̃k 5 1

2 (ak 2 ibk) 5 Z c̃k Z e

ifk

c̃2k 5 1

2 (ak 1 ibk) 5 Z c̃k Z e

2ifk

FIGURE A.1 Relationships between rectangular and polar forms of the Fourier series coeffi cients.

a k

b k

–u k

a k +

b k2

2

FIGURE A.2 Relationships between complex exponential and real coeffi cients of the Fourier series.

c –k

c k

k

–k

a k

2

ck

ck b

k

2 –

934 APPENDIX A THE FOURIER SERIES

where Z c̃0 Z 5 a0 and

Z c̃k Z 5 1

2 2a2k 1 b2k 5 ck

2

and

fk 5 tan 21 a2bk

ak b

Note that the tilde signi! es that the coef! cient is a complex

number.

Each term in Eq. (A.1) can be visualized as a rotating

phasor (the arrows in Fig. A.2). Terms with a positive sub-

script rotate in a counterclockwise direction, whereas those

with a negative subscript rotate clockwise. The coef! cients

c̃k and c̃2k specify the position of the phasor at t 5 0. The

infinite summation of the spinning phasors, which are

allowed to rotate at t 5 0, is then equal to f(t).

935

Getting Started with MATLAB

MATLAB software is a computer program that provides the user with a convenient en-

vironment for many types of calculations—in particular, those that are related to matrix

manipulations. MATLAB operates interactively, executing the user’s command one-by-one

as they are entered. A series of commands may be saved as a script and run like an

interpretive program. MATLAB has a large number of built-in functions; however, it is

possible for users to build their own functions made up of MATLAB commands and

functions. The primary features of MATLAB are built-in vector and matrix computations

including:

Vector-matrix arithmetic.

Matrix inversion and eigenvalue/vector analysis.

Complex arithmetic and polynomial operations.

Statistical calculations.

Graphical displays.

Control system design.

Fitting process models from test data.

MATLAB has a number of optional toolboxes that provide specialized functions. These

include: signal processing, control systems, system identi! cation, optimization, and statistics.

MATLAB is available in versions that run on PCs, Macs, and workstations. The

modern version that runs on PCs does so in the Windows environment. The seven exer-

cises that follow are meant to give you the # avor of computing with MATLAB; they do

not constitute a comprehensive tutorial. There are additional tutorial materials in the

MATLAB manuals. A number of textbooks now feature MATLAB exercises. Also, on-

line information is available for any command or function by typing: , where

identi! es the command. Do not just look through these exercises; try them all and

try variations that occur to you. Check the answers that MATLAB gives and make sure

you understand them and they are correct. That is the effective way to learn MATLAB.

B A P P E N D I X B

936 APPENDIX B GETTING STARTED WITH MATLAB

1. Assignment of Values to Variable Names

Assignment of values to scalar variables is similar to other computer languages. Try typing

and

Note how the assignment echoes to con! rm what you have done. This is a characteristic

of MATLAB. The echo can be suppressed by terminating the command line with the

semicolon ( ) character. Try typing

MATLAB treats names in a case-sensitive manner, that is, the name is not the same

as the name . To illustrate this, enter

and

See how their values are distinct. They are distinct names.

Variable names in MATLAB generally represent matrix quantities. A row vector can

be assigned as follows:

The echo con! rms the assignment again. Notice how the new assignment of has taken

over. A column vector can be entered in several ways. Try them.

or

or, by transposing a row vector with the operator,

A two-dimensional matrix of values can be assigned as follows:

or

APPENDIX B GETTING STARTED WITH MATLAB 937

The values stored by a variable can be examined at any time by typing the name alone,

for example,

or

Also, a list of all current variables can be obtained by entering the command

or, with more detail, enter

There are several prede! ned variables, for example, .

It is also possible to assign complex values to variables, since MATLAB handles

complex arithmetic automatically. To do this, it is convenient to assign a variable name,

usually either or , to the square root of 21.

Then, a complex value can be assigned, like

2. Mathematical Operations

Operations with scalar quantities are handled in a straightforward manner, similar to

computer languages. The common operators, in order of priority, are

These operators will work in calculator fashion. Try

Also, scalar real variables can be included:

Results of calculations can be assigned to a variable, as in the next-to-last example, or

simply displayed, as in the last example.

Calculations can also involve complex quantities. Using the de! ned above, try

938 APPENDIX B GETTING STARTED WITH MATLAB

The real power of MATLAB is illustrated in its ability to carry out matrix calculations.

The inner product of two vectors (dot product) can be calculated using the operator,

and likewise, the outer product

To illustrate vector-matrix multiplication, ! rst rede! ne and ,

and

Now, try

or

What happens when the dimensions are not those required by the operations? Try

Matrix-matrix multiplication is carried out in likewise fashion:

Mixed operations with scalars are also possible:

It is important to always remember that MATLAB will apply the simple arithmetic op-

erators in vector-matrix fashion if possible. At times, you will want to carry out calcula-

tions item-by-item in a matrix or vector. MATLAB provides for that too. For example,

results in matrix multiplication of with itself. What if you want to square each element

of ? That can be done with

The ? preceding the operator signi! es that the operation is to be carried out item-by-

item. The MATLAB manual calls these array operations.

When the division operator ( ) is used with matrices, the use of a matrix inverse is im-

plied. Therefore, if is a square, nonsingular matrix, then corresponds to the right

multiplication of by the inverse of . A longer way to do this used the inv function, that is,

; however, using the division operator is more ef! cient since is actually

solved as the set of equations using a decomposition/elimination scheme.

The “left division” operator ( , the backslash character) is used in matrix op-

erations also. As above, corresponds to the left multiplication of by the inverse

APPENDIX B GETTING STARTED WITH MATLAB 939

of . This is actually solved as the set of equations , a common engineering

calculation.

For example, if is a column vector with values , , and , the solution of

, where has been set above, can be obtained by typing

Try that.

3. Use of Built-In Functions

MATLAB and its Toolboxes have a rich collection of built-in functions. You can use

on-line help to ! nd out more about them. One of their important properties is that they

will operate directly on vector and matrix quantities. For example, try

and you will see that the natural logarithm function is applied in array style, element by

element, to the matrix . Most functions, like sqrt, abs, sin, acos, tanh, and exp, operate

in array fashion. Certain functions, like exponential and square root, have matrix de! ni-

tions also. MATLAB will evaluate the matrix version when the letter is appended to

the function name. Try

A common use of functions is to evaluate a formula for a series of arguments. Create a

column vector that contains values from to in steps of ,

Check the number of items in the array with the Length function,

Now, say that you want to evaluate a formula 5 , where the formula is computed

for each value of the array, and the result is assigned to a corresponding position in the

array. For example,

Done! [Note the use of the array operators adjacent decimal points.] This is similar to

creating a column of the values on a spreadsheet and copying a formula down an

adjacent column to evaluate values.

4. Graphics

MATLAB’s graphics capabilities have similarities to those of a spreadsheet program.

Graphs can be created quickly and conveniently; however, there is not much # exibility

to customize them.

For example, to create a graph of the arrays from the data above, enter

940 APPENDIX B GETTING STARTED WITH MATLAB

That’s it! You can customize the graph a bit with commands like the following:

The graph appears in a separate window and can be printed or transferred via the clipboard

(PCs with Windows or Macs) to other programs.

There are other features of graphics that are useful, for example, plotting objects

instead of lines, families of curves plots, plotting on the complex plane, multiple graphs

windows, log-log or semilog plots, three-dimensional mesh plots, and contour plots.

5. Polynomials

There are many MATLAB functions that allow you to operate on arrays as if their entries

were coef! cients or roots of polynomial equations. For example, enter

and then

and the roots of the polynomial x3 1 x2 1 x 1 1 5 0 should be printed and are also

stored in the array. The polynomial coef! cients can be computed from the roots with

the poly function,

and a polynomial can be evaluated for a given value of . For example,

If another polynomial, 2×2 2 0.4x 2 1, is represented by the array ,

the two polynomials can be multiplied symbolically with the convolution function, conv,

to yield the coef! cients of the product polynomial,

The deconvolution function, deconv, can be used to divide one polynomial into another,

for example,

The result is the quotient, and the result is the remainder.

There are other polynomial functions that may become useful to you, such as the

residue function for partial fraction expansion.

6. Statistical Analysis

The Statistics Toolbox contains many features for statistical analysis; however, common

statistical calculations can be performed with MATLAB’s basic function set. You can

APPENDIX B GETTING STARTED WITH MATLAB 941

generate a series of (pseudo) random numbers with the rand function. Either a uniform

(rand) or normal (randn) distribution is available:

(Did you forget the !!!)

You probably understand why using the semicolon at the end of the commands above is

important, especially if you neglected to do so.

If you would like to see a plot of noise, try

These are supposed to be normally distributed numbers with a mean of zero and variance

(and standard deviation) of one. Check by

and

No one is perfect! You can ! nd minimum and maximum values,

There is a convenient function for plotting a histogram of the data:

where 20 is the number of bins.

If you would like to ! t a polynomial to some data by least squares, you can use the

poly! t function. Try the following example:

The values in are the ! tted polynomial coef! cients. To generate the computed

value of ,

5

and to plot the data versus the ! tted curve,

The plot of the continuous curve is piecewise linear; therefore, it does not look very

smooth. Improve this as follows:

942 APPENDIX B GETTING STARTED WITH MATLAB

7. This and That

There are many, many other features to MATLAB. Some of these you will ! nd useful;

perhaps others you will never use. We encourage you to explore and experiment.

To save a copy of your session, MATLAB has a useful capability called diary. You

issue the command

and MATLAB opens a disk ! le in which it stores all the subsequent commands and

results (not graphs) of your session. You can turn the diary feature off:

and back on with the same ! le:

After you leave MATLAB, the diary ! le is available to you. It is common to use an

editor or word processor to clean up the diary ! le (getting rid of all those errors you

made before anyone can see them!) and then print the ! le to obtain a hard copy of the

important parts of your work session, for example, key numerical results.

Exit MATLAB with the or commands. It is possible to save the current

state of your work with the command. It is also possible to reload that state with

the command.

943

Getting Started with Mathcad

Mathcad has a unique way to handle equations, numbers, text, and graphs. It works like

a scratch pad and pencil. The screen interface is a blank worksheet on which you can

enter equations, graph data or functions, and annotate operations with text. It uses stan-

dard mathematical symbols to represent operators when possible. Therefore, you may

 nd that the Mathcad interface is quite natural and familiar.

Mathcad can solve a wide range of mathematical problems either numerically or

symbolically. The symbolic capabilities of Mathcad have relatively little application in

this text, although they may be used to check our numerical results. Therefore, they will

not be covered in detail in this overview. Mathcad has a comprehensive set of operators

and functions that allow you to perform many of the numerical methods covered in this

text. It also has a programming language that allows you to write your own multiline

procedures and subprograms. The following discussion provides a brief description of

the features of Mathcad you will  nd most useful for this text.

THE BASICS OF MATHCAD

Applications in this text will require that you be able to create your own worksheets. To

facilitate your efforts, let’s go over the main features of the Mathcad application window.

The Main Menu

This is your gateway to Mathcad. It also provides commands that handle the details of

editing and managing your worksheets. For example, click on the File and Tools menus

to see some of the functionality available to you.

The Standard Toolbar

Several toolbars should be automatically displayed just below the Main menu. As the

name implies, the Standard toolbar provides shortcuts for many common tasks, from

worksheet opening and  le saving to bringing up lists of built-in functions and units.

Depending on what you are doing in your worksheet, one or more of these buttons may

C A P P E N D I X C

944 APPENDIX C GETTING STARTED WITH MATHCAD

appear grayed out. If you let your mouse hover over each of the buttons on the palette,

you will see a description of the button’s function.

The Math Palette

The Math Palette may automatically be displayed at the top of the screen. If not, just

select View, Toolbars, Math and it will appear. The buttons and their functions are

described below:

Click on one of these buttons to bring up the full palette. You can use the palettes to

insert math symbols and operations directly into your Mathcad worksheet.

ENTERING TEXT AND MATHEMATICAL OPERATIONS

Entering Text

To create a text region, click in a blank area of the screen to position the red crosshair

cursor and type a double quote [“]. Now you can type whatever you like, just as in a

word processor. As the region grows, a black box appears around the text. The box has

resizing “handles” on the right and bottom edges of the rectangle. Once you are done,

click outside the text region to go back to inputting math operations. The black selection

box disappears when you are no longer working in the text region.

Mathematical Operations

Type See on Screen

11

Click somewhere in the upper-left-hand corner of the worksheet, and the red crosshair

should move to where you click. After you type the number 1 and the 1 sign you will see

a little black box delimited by blue editing lines. In Mathcad this black box is called a

APPENDIX C GETTING STARTED WITH MATHCAD 945

placeholder. If you continue typing, whatever you type next will appear in the placeholder.

For example, type 2 in the placeholder, then press the equals key ( 5 ) to see the result.

1 1 2 5 3

The basic arithmetic operators are listed below, along with their keystrokes and Calculator

Palette button equivalents.

Operation Keystroke Palette Example

Addition 1 1 2 1 2 5 4 Subtraction 2 2 2 2 2 5 0 Multiplication * 3 2 ? 2 5 4 Division / 4 22 5 1 Exponentiation ^ xY 22 5 4

Notice that operations in a Mathcad worksheet appear in familiar notation—multiplication

as a dot, division with a fraction bar, exponents in a raised position, and so on. Calculations

are computed internally to 15 places, but you can show fewer places in the answer. To

change the default display of numerical and symbolic results in a worksheet, click in a

blank area of the worksheet. Then select Result from the Format menu to display the

Result Format dialog box, and choose your default settings. Make sure that the button

labeled “Set as default” is checked, and click OK. If you just want to change the display

of a particular result, click on the equation, and follow the same steps.

Here are a few more examples that demonstrate Mathcad features.

B 1.837 # 103

100 1 35 5 2.3142353232

Most standard engineering and mathematical functions are built in.

log(1347.2) # sin a3 5

# pb 5 2.976 Mathcad’s functions and operators easily handle complex numbers.

(2.3 1 4.7i)3 1 e322i 5 2148.613 2 47.498i

MATHEMATICAL FUNCTIONS AND VARIABLES

The de nition symbol :5 is used to de ne a function or variable in Mathcad. For example,

click an empty worksheet to position the red crosshair in a blank area and type:

Type See on Screen

f(x):x^2

946 APPENDIX C GETTING STARTED WITH MATHCAD

The de nition symbol is also located on the Evaluation selection of the Math Palette.

When you change a de nition function or variable, Mathcad immediately recalculates

any new values that depend on it. Once you’ve de ned a function like f(x), you can use

it in a number of ways, for example:

f(x) :5 x2

Now you can insert a numerical value as the argument of f(x)

f(10) 5 100

or de ne a variable and insert it as the argument of f(x).

x :5 3

f(x) 5 9

You can even de ne another function in terms of f(x).

g(y) :5 f(y) 1 6

g(x) 5 15

Note that you can de ne a function using expressions you build up from the keyboard

or from the palettes of math operators. You can also include any of Mathcad’s hundreds

of built-in functions. To see a list of built-in functions along with brief descriptions,

select Function from the Insert menu, or click on the f(x) button. You can also type the

name of any built-in function directly from the keyboard. The following are just a few

examples that use some of Mathcad’s built-in functions.

Trig and Logs

ln(26) 5 3.258 csc(45 # .deg) 5 1.414

Matrix Functions

identity(3) 5 £ 1 0 00 1 0 0 0 1

§ Probability Distributions

pnorm(2,0,1) 5 0.977

Range Variables

In Mathcad you will  nd yourself wanting to work with a range of values for many

applications—for example, to de ne a series of values to plot. Mathcad therefore provides

the range operator ( .. ), which can be entered by typing a semicolon ( ; ) at the keyboard.

APPENDIX C GETTING STARTED WITH MATHCAD 947

The  rst and last numbers establish the endpoints of the range variable, and the second

number sets the increment. For example,

Type See on Screen

z:0,0.5;2 z:50,0.5..2

z 5

Matrix Computations and Operations

To enter a matrix, click on the 3 3 3 matrix icon in the Matrix Palette (or choose Matrix

from the Insert menu), choose the number of rows and columns, then  ll in the placeholders.

For example,

A :5 £ 4 5 15 0 212 27 2 8

§ To compute the inverse,

Type See on Screen

A^–15 A21 5 £ 0.074 20.117 20.1840.135 0.12 0.163 0.031 20.132 20.077

§

Mathcad has a comprehensive set of commands to perform various matrix operations.

For example, to  nd the determinant, type a vertical bar ( Z ) or use the button on the Matrix Palette.

ZA Z 5 326

Units

Mathcad can also handle units. To see the built-in units, choose Unit from the Insert

menu, or click on the appropriate toolbar button. Let’s start with a simple example. Open

a new worksheet in Mathcad and type [Enter]. You should see

Mass :5 75 kg

948 APPENDIX C GETTING STARTED WITH MATHCAD

You could also have typed [Enter], multiplying the quantity times the unit.

Now, enter and you should have

g :5 9.8 m

s2

To see how Mathcad manages the units with calculations, enter and the result

should be displayed with combined units as

Mass # g 5 735 N

Mathcad uses the SI unit system by default, but you can change that from Tools,

Worksheet Options, Unit System. Alternate systems include CGS, MKS, and US. In-

stead of typing in the unit, you can also insert it from a list. Try the following. Type

then click on Insert, Unit. Select Temperature from the upper box

and Kelvin(K) from the lower box and click OK.

NUMERICAL METHODS FUNCTION

Mathcad has a number of special built-in functions that perform a variety of numerical

operations of particular interest to readers of this book. Examples of the development

and application of these functions are described in detail in the text. Here we will provide

a brief list of some of the more important functions just to give you an overview of the

capabilities. We illustrate their use in the relevant sections of this book.

Function Name Use

root Solves f(x) 5 0

polyroots Finds all roots of a polynomial

fi nd Solves a system of nonlinear algebraic equations

minerr Returns a minimum error solution of a system of equations

lsolve Solves a system of linear algebraic equations

linterp Linear interpolation

cspline Cubic spline interpolation

regress Polynomial regression

genfi t General nonlinear regression

fft Fourier transform

ifft Inverse Fourier transform

rkfi xed Solves a system of differential equations using a fi xed step-size fourth- order Runge-Kutta method

rkadapt Solves a system of differential equations using a variable step-size fourth-order Runge-Kutta method

sbval Solves a two-point boundary value problem

eigenvals Finds eigenvalues

eigenvecs Finds eigenvectors

relax Solves Poisson’s equation for a square domain

APPENDIX C GETTING STARTED WITH MATHCAD 949

MULTILINE PROCEDURES AND SUBPROGRAMS

The Programming Palette in Mathcad provides the capability for multiline procedures

or subprograms with standard control structures such as FOR and WHILE loops, branch-

ing, recursion, and more. Subprograms can be integrated with Mathcad’s worksheets and

can operate on scalars, vectors, arrays, and even arrays of arrays.

CREATING GRAPHS

Mathcad’s graphics capabilities are particularly important to engineering work. The  rst

type of graph to know about is the QuickPlot. Start with a new worksheet and enter the

following formula. Leave the formula selected.

e 2X

4 # (2 2 x) 2 1 Z

From the menu, select Insert, Graph, X-Y Plot. Click away from the graph and you

should see an automatic QuickPlot.

This plot can now be adjusted as desired. For example, click in the plot to select it and

change the x limits to 0 to 1. This should appear as

Then, click away from the plot, and the y axis will rescale automatically. Double-click

on the plot, and the Formatting Currently Selected X-Y Plot dialog box should appear.

Check the boxes for X and Y gridlines and click OK. Click away from the plot, and you

should now have

950 APPENDIX C GETTING STARTED WITH MATHCAD

Mathcad graphs one point for each value of the range variable x. This variable was

created automatically in this case. The x-y points are joined by short straight-line seg-

ments. You can create your own range variables for the x axis.

Instead of using a formula for the y axis, you can use a function. To illustrate this,

enter the following function de” nition above your chart:

and change the y axis from the formula to f(x). You should have the same plot, but now

it is in terms of the function f(x) instead of the direct formula.

A function can also be used for the x axis. Try another example below your current

graph. Make the following de” nitions:

N :5 100 u :5 0, 2 # x

N .. 2 # x

x(u) :5 cos(u) y(u) :5 sin(u)

Insert a blank plot by pressing the @ key (Shift-2). Enter (u) in the y-axis placeholder

and u in the x-axis placeholder and click away from the graph. This should yield the

plot of a circle:

APPENDIX C GETTING STARTED WITH MATHCAD 951

It is also possible to plot the elements of a vector. Create the following vector of binomial

probabilities:

i :50.. 10

pi :50.4 i.0.6(102 i)

and insert a graph with i on the x axis and pi on the y axis (you can use the [ key for the

subscript). Your graph should look like

Of course, you can plot one vector against another too, as long as they have the same

number of elements. The vectors could contain data instead a mathematical formula.

There are many axis settings that can be adjusted by double-clicking on the graph.

These are self-explanatory to a great extent, and you can become familiar with them

through practice.

There are many other styles of plots that can be generated by Mathcad. These include

polar, surface, contour, 3D bar, scatter, vector-” eld plots, and graphical animations.

SYMBOLIC MATHEMATICS

An intriguing and valuable feature of Mathcad is its capability to carry out symbolic

math manipulations. The symbolic capabilities include

Algebraic manipulations.

Calculus: differentiation and integration.

Solving algebraic equations and systems of such equations.

and, more advanced features

Symbolic Fourier, Laplace, and z transforms.

Symbolic optimization.

We will review the ” rst group here.

Let’s start with a simple example of symbolic algebra. Enter the expression

(x 1 2) # (x 2 1) # (x 1 4)

Expand the horizontal editing line to encompass the entire expression and then select

Expand from the Symbolics menu. You should see below:

x3 1 5 # x2 1 2 # x 2 8

952 APPENDIX C GETTING STARTED WITH MATHCAD

Now, enter the polynomial x3 1 3×2 1 3x 1 1 and follow the same procedure, except pick

Factor from the Symbolics menu. You should have

x3 1 3 # x2 1 3 # x 1 1

(x 1 1)3

Another way to carry out symbolic commands is with keystrokes. Enter the following

expression:

x2 2 3 # x 2 4

x 2 4 1 2 # x 2 5 Z

Then press the Ctrl-Shift-. key combination and type into the placeholder

that appears. You should get

x2 2 3 # x 2 4

x 2 4 1 2 # x 2 5 simplify S 3 # x 2 4

This is a different style of symbolic evaluation with the keyword retained and the result

appearing out to the right. You’ve seen the use of three important symbolic operators:

expand Expand all powers and products of sums.

factor Factor into a product of simpler functions.

simplify Simplify by performing arithmetic, canceling common factors, using

identities, and simplifying powers.

Additional algebraic features include expansion to a series, partial fraction expansion,

and extracting coef” cients of a polynomial into a vector.

Now, let’s experiment with simple differentiation. Enter the expression

and leave the T selected (or click on it to select it). Then select Variable and Differentiate

from the Symbolics menu. You should have the result

Another way to do this is to use the differentiation operator from the Calculus toolbar.

Enter the following expression:

APPENDIX C GETTING STARTED WITH MATHCAD 953

and then click on the button on the Evaluation toolbar (you can also press Ctrl-.).

The result should be

Symbolic integrals can be determined either in inde” nite or de” nite form. For an

inde” nite integral, start by typing Ctrl-i or click on the button on the Calculus

toolbar. Then enter the desired function and differential followed by the button to

produce the following result:

Mathcad can also compute limits symbolically. The appropriate buttons are on the Calculus

toolbar.

LEARNING MORE ABOUT MATHCAD

In this brief introduction we have covered only the Mathcad basics. Further help is avail-

able right in the Mathcad software package in a variety of forms.

ToolTips

Let your mouse pointer hover over a palette or toolbar button for a few seconds. You

will see an explanatory tooltip displayed near the button. Look also on the message line

at the bottom of the Mathcad application window for helpful tips and shortcuts.

Resource Center and QuickSheets

To help you get going fast and keep you learning, Mathcad comes complete with Quick-

Sheets. These provide mathematical shortcuts for frequently used analyses—from graph-

ing a function to solving simultaneous equations to the analysis of variance. There are

numerous QuickSheets. To open the QuickSheets section, choose QuickSheets from the

Help option on the Main menu.

Online Help

Online Help provides detailed, step-by-step instructions for using all of Mathcad’s features.

Help is available at any time by simply going to the Help button on the Main menu. There

you will ” nd several links including the Mathcad website and Mathcad training.

954

BIBLIOGRAPHY

Al-Khafaji, A. W., and J. R. Tooley, Numerical Methods

in Engineering Practice, Holt, Rinehart and Winston,

New York, 1986.

Allaire, P. E., Basics of the Finite Element Method, William C.

Brown, Dubuque, IA, 1985.

Ames, W. F., Numerical Methods for Partial Differential

Equations, Academic Press, New York, 1977.

Ang, A. H-S., and W. H. Tang, Probability Concepts in

Engineering Planning and Design, Vol. 1: Basic Principles,

Wiley, New York, 1975.

APHA (American Public Health Association). 1992. Standard

Methods for the Examination of Water and Wastewater,

18th ed., Washington , DC.

Atkinson, K. E., An Introduction to Numerical Analysis, Wiley,

New York, 1978.

Atkinson, L. V., and P. J. Harley, An Introduction to Numerical

Methods with Pascal, Addison-Wesley, Reading, MA, 1983.

Baker, A. J., Finite Element Computational Fluid Mechanics,

McGraw-Hill, New York, 1983.

Bathe, K.-J., and E. L. Wilson, Numerical Methods in Finite

Element Analysis, Prentice-Hall, Englewood Cliffs, NJ, 1976.

Booth, G. W., and T. L. Peterson, “Nonlinear Estimation,” I.B.M.

Share Program Pa. No. 687 WLNL1, 1958.

Boyce, W. E., and R. C. DiPrima, Elementary Differential

Equations and Boundary Value Problems, 5th ed. Wiley,

New York, 1992.

Branscomb, L. M., “Electronics and Computers: An Overview,”

Science, 215:755, 1982.

Brent, R. P., Algorithms for Minimization Without Derivatives ,

Prentice-Hall, Englewood Cliffs, NJ, 1973.

Brigham, E. O., The Fast Fourier Transform, Prentice-Hall,

Englewood Cliffs, NJ, 1974.

Burden, R. L., and J. D. Faires, Numerical Analysis, 8th ed., PWS

Publishing, Boston, 2005.

Butcher, J. C., “On Runge-Kutta Processes of Higher Order,”

J. Austral. Math. Soc., 4:179, 1964.

Carnahan, B., H. A. Luther, and J. O. Wilkes, Applied Numerical

Methods, Wiley, New York, 1969.

Cash, J. R., and A. H. Karp, ACM Transactions on Mathematical

Software, 16:201–222, 1990.

Chapra, S. C., Surface Water-Quality Modeling, McGraw-Hill,

New York, 1997.

Chapra, S. C., Applied Numerical Methods with MATLAB, 2nd

ed., McGraw-Hill, New York, 2007.

Cheney, W., and D. Kincaid, Numerical Mathematics and

Computing, 6th ed., Brooks/Cole, Monterey, CA, 2008.

Chirlian, P. M., Basic Network Theory, McGraw-Hill,

New York, 1969.

Cooley, J. W., P. A. W. Lewis, and P. D. Welch, “Historical Notes

on the Fast Fourier Transform,” IEEE Trans. Audio

Electroacoust., AU-15(2):76–79, 1977.

Dantzig, G. B., Linear Programming and Extensions, Princeton

University Press, Princeton, NJ, 1963.

Davis, H. T., Introduction to Nonlinear Differential and Integral

Equations, Dover, New York, 1962.

Davis, L., Handbook of Genetic Algorithms, Van Nostrand

Reinhold, New York, 1991.

Davis, P. J., and P. Rabinowitz, Methods of Numerical Integration,

Academic Press, New York, 1975.

Dennis, J. E., and R. B. Schnabel, Numerical Methods for

Unconstrained Optimization and Nonlinear Equations,

Society for Industrial and Applied Mathematics (SIAM),

Philadelphia, PA, 1996.

Dekker, T. J., “Finding a Zero by Means of Successive Linear

Interpolation , ” in Constructive Aspects of the Fundamental

Theorem of Algebra , B. Dejon and P. Henrici (editors),

Wiley-Interscience, New York, 1969, pp. 37–48.

Dijkstra, E. W., “Go To Statement Considered Harmful,”

Commun. ACM, 11(3):147–148, 1968.

Draper, N. R., and H. Smith, Applied Regression Analysis, 2d ed.,

Wiley, New York, 1981.

Enright, W. H., T. E. Hull, and B. Lindberg, “Comparing

Numerical Methods for Stiff Systems of ODE’s,” BIT,

15:10, 1975.

Fadeev, D. K., and V. N. Fadeeva, Computational Methods of

Linear Algebra, Freeman, San Francisco, 1963.

Ferziger, J. H., Numerical Methods for Engineering Application,

Wiley, New York, 1981.

Fletcher, R., Practical Methods of Optimization: 1:

Unconstrained Optimization, Wiley, Chichester, UK, 1980.

Fletcher, R., Practical Methods of Optimization: 2: Constrained

Optimization, Wiley, Chichester, 1981.

Forsythe, G. E., and W. R. Wasow, Finite-Difference Methods for

Partial Differential Equations, Wiley, New York, 1960.

BIBLIOGRAPHY 955

Forsythe, G. E., M. A. Malcolm, and C. B. Moler, Computer

Methods for Mathematical Computation, Prentice-Hall,

Englewood Cliffs, NJ, 1977.

Fylstra, D., L. S. Lasdon, J. Watson, and A. Waren, “Design and

Use of the Microsoft Excel Solver,” Interfaces, 28(5):29–55,

1998.

Gabel, R. A., and R. A. Roberts, Signals and Linear Systems,

Wiley, New York, 1987.

Gear, C. W., Numerical Initial-Value Problems in Ordinary

Differential Equations, Prentice-Hall, Englewood Cliffs,

NJ, 1971.

Gerald, C. F., and P. O. Wheatley, Applied Numerical Analysis,

7th ed., Addison-Wesley, Reading, MA, 2004.

Gill, P. E., W. Murray, and M. H. Wright, Practical Optimization,

Academic Press, London, 1981.

Gladwell, J., and R. Wait, A Survey of Numerical Methods of

Partial Differential Equations, Oxford University Press, New

York, 1979.

Goldberg, D. E., Genetic Algorithms in Search, Optimization and

Machine Learning, Addison-Wesley, Reading, MA, 1989.

Guest, P. G., Numerical Methods of Curve Fitting, Cambridge

University Press, New York, 1961.

Hamming, R. W., Numerical Methods for Scientists and

Engineers, 2d ed., McGraw-Hill, New York, 1973.

Hartley, H. O., “The Modi! ed Gauss-Newton Method for Fitting

Non-linear Regression Functions by Least Squares,”

Technometrics, 3:269–280, 1961.

Hayt, W. H., and J. E. Kemmerly, Engineering Circuit Analysis,

McGraw-Hill, New York, 1986.

Heideman, M. T., D. H. Johnson, and C. S. Burrus, “Gauss and

the History of the Fast Fourier Transform,” IEEE ASSP

Mag. , 1(4):14–21, 1984.

Henrici, P. H., Elements of Numerical Analysis, Wiley,

New York, 1964.

Hildebrand, F. B., Introduction to Numerical Analysis, 2d ed.,

McGraw-Hill, New York, 1974.

Hillier, F. S., and G. J. Lieberman, Introduction to Operations

Research , 8th ed., McGraw-Hill, New York, 2005.

Hoffman, J., Numerical Methods for Engineers and Scientists,

McGraw-Hill, New York, 1992.

Holland, J. H., Adaptation in Natural and Arti! cial Systems,

University of Michigan Press, Ann Arbor, MI, 1975.

Hornbeck, R. W., Numerical Methods, Quantum, New York,

1975.

Householder, A. S., Principles of Numerical Analysis,

McGraw-Hill, New York, 1953.

Householder, A. S., The Theory of Matrices in Numerical Analy-

sis, Blaisdell, New York, 1964.

Householder, A.S. The Numerical Treatment of a Single Nonlinear

Equation, McGraw-Hill, New York, 1970.

Huebner, K. H., and E. A. Thornton, The Finite Element Method

for Engineers, Wiley, New York, 1982.

Hull, T. E., and A. L. Creemer, “The Ef! ciency of Predictor-

Corrector Procedures,” J. Assoc. Comput. Mach.,

10:291, 1963.

Isaacson, E., and H. B. Keller, Analysis of Numerical Methods,

Wiley, New York, 1966.

Jacobs, D. (ed.), The State of the Art in Numerical Analysis,

Academic Press, London, 1977.

James, M. L., G. M. Smith, and J. C. Wolford, Applied Numerical

Methods for Digital Computations with FORTRAN and

CSMP, 3d ed., Harper & Row, New York, 1985.

Keller, H. B., Numerical Methods for Two-Point Boundary-Value

Problems, Wiley, New York, 1968.

Lapidus, L., and G. F. Pinder, Numerical Solution of Partial

Differential Equations in Science and Engineering, Wiley,

New York, 1981.

Lapidus, L., and J. H. Sein! eld, Numerical Solution of Ordinary

Differential Equations, Academic Press, New York, 1971.

Lapin, L. L., Probability and Statistics for Modern Engineering,

Brooks/Cole, Monterey, CA, 1983.

Lasdon, L. S., and S. Smith, “Solving Large Nonlinear Programs

Using GRG,” ORSA Journal on Computing, 4(1):2–15, 1992.

Lasdon, L. S., A. Waren, A. Jain, and M. Ratner, “Design and

Testing of a Generalized Reduced Gradient Code for

Nonlinear Programming,” ACM Transactions on

Mathematical Software, 4(1):34–50, 1978.

Lawson, C. L., and R. J. Hanson, Solving Least Squares Problems,

Prentice-Hall, Englewood Cliffs, NJ, 1974.

Luenberger, D. G., Introduction to Linear and Nonlinear

Programming, Addison-Wesley, Reading, MA, 1984.

Lyness, J. M., “Notes on the Adaptive Simpson Quadrature

Routine,” J. Assoc. Comput. Mach., 16:483, 1969.

Malcolm, M. A., and R. B. Simpson, “Local Versus Global

Strategies for Adaptive Quadrature,” ACM Trans. Math.

Software, 1:129, 1975.

Maron, M. J., Numerical Analysis, A Practical Approach,

Macmillan, New York, 1982.

Milton, J. S., and J. C. Arnold, Introduction to Probability and

Statistics: Principles and Applications for Engineering and

the Computing Sciences, 4th ed., McGraw-Hill, New

York, 2002.

Moler, C. B., Numerical Computing with MATLAB , SIAM,

Philadelphia, 2005.

Muller, D. E., “A Method for Solving Algebraic Equations

Using a Digital Computer,” Math. Tables Aids Comput.,

10:205, 1956.

Na, T. Y., Computational Methods in Engineering Boundary Value

Problems, Academic Press, New York, 1979.

Noyce, R. N., “Microelectronics,” Sci. Am., 237:62, 1977.

956 BIBLIOGRAPHY

Oppenheim, A. V., and R. Schafer, Digital Signal Processing,

Prentice-Hall, Englewood Cliffs, NJ, 1975.

Ortega, J., and W. Rheinboldt, Iterative Solution of Nonlinear

Equations in Several Variables, Academic Press,

New York, 1970.

Ortega, J. M., Numerical Analysis— A Second Course, Academic

Press, New York, 1972.

Prenter, P. M., Splices and Variational Methods, Wiley,

New York, 1975.

Press, W. H., B. P. Flanner, S. A. Teukolsky, and W. T. Vetterling,

Numerical Recipes: The Art of Scienti! c Computing, 3rd ed.

Cambridge University Press, Cambridge, 2007.

Rabinowitz, P., “Applications of Linear Programming to

Numerical Analysis,” SIAM Rev., 10:121–159, 1968.

Ralston, A., “Runge-Kutta Methods with Minimum Error

Bounds,” Match. Comp., 16:431, 1962.

Ralston, A., and P. Rabinowitz, A First Course in Numerical

Analysis, 2d ed., McGraw-Hill, New York, 1978.

Ramirez, R. W., The FFT, Fundamentals and Concepts,

Prentice-Hall, Englewood Cliffs, NJ, 1985.

Rao, S. S., Engineering Optimization: Theory and Practice,

3d ed., Wiley-Interscience, New York, 1996.

Revelle, C. S., E. E. Whitlach, and J. R. Wright, Civil and

Environmental Systems Engineering, Prentice-Hall,

Englewood Cliffs, NJ, 1997.

Rice, J. R., Numerical Methods, Software and Analysis,

McGraw-Hill, New York, 1983.

Ruckdeschel, F. R., BASIC Scienti! c Subroutine, Vol. 2,

Byte/McGraw-Hill, Peterborough, NH, 1981.

Scarborough, J. B., Numerical Mathematical Analysis, 6th ed.,

Johns Hopkins Press, Baltimore, MD, 1966.

Scott, M. R., and H. A. Watts, “A Systematized Collection of

Codes for Solving Two-Point Boundary-Value Problems,” in

Numerical Methods for Differential Equations, L. Lapidus

and W. E. Schiesser (eds.), Academic Press, New York, 1976.

Shampine, L. F., and R. C. Allen, Jr., Numerical Computing: An

Introduction, Saunders, Philadelphia, 1973.

Shampine, L. F., and C. W. Gear, “A User’s View of Solving Stiff

Ordinary Differential Equations,” SIAM Review, 21:1, 1979.

Simmons, E. F., Calculus with Analytical Geometry,

McGraw-Hill, New York, 1985.

Stark, P. A., Introduction to Numerical Methods, Macmillan,

New York, 1970.

Stasa, F. L., Applied Finite Element Analysis for Engineers,

Holt, Rinehart and Winston, New York, 1985.

Stewart, G. W., Introduction to Matrix Computations, Academic

Press, New York, 1973.

Swokowski, E. W., Calculus with Analytical Geometry, 2d ed.,

Prindle, Weber and Schmidt, Boston, 1979.

Taylor, J. R., An Introduction to Error Analysis, University Science

Books, Mill Valley, CA, 1982.

Tewarson, R. P., Sparse Matrices, Academic Press, New York, 1973.

Thomas, G. B., Jr., and R. L. Finney, Calculus and Analytical

Geometry, 5th ed., Addison-Wesley, Reading, MA, 1979.

Van Valkenburg, M. E., Network Analysis, Prentice-Hall,

Englewood Cliffs, NJ, 1974.

Varga, R., Matrix Iterative Analysis, Prentice-Hall, Englewood

Cliffs, NJ, 1962.

Vichnevetsky, R., Computer Methods for Partial Differential

Equations, Vol. 1: Elliptical Equations and the Finite

Element Method, Prentice-Hall, Englewood Cliffs,

NJ, 1981.

Vichnevetsky, R., Computer Methods for Partial Differential

Equations, Vol. 2: Initial Value Problems, Prentice-Hall,

Englewood Cliffs, NJ, 1982.

Wilkinson, J. H., The Algebraic Eigenvalue Problem, Oxford

University Press, Fair Lawn, NJ, 1965.

Wilkinson, J. H., and C. Reinsch, Linear Algebra: Handbook for

Automatic Computation, Vol. 11, Springer-Verlag, Berlin,

1971.

Wold, S., “Spline Functions in Data Analysis,” Technometrics,

16(1):1–11, 1974.

Yakowitz, S., and F. Szidarovsky, An Introduction to Numerical

Computation, Macmillan, New York, 1986.

Young, D. M., Iterative Solution of Large Linear Systems,

Academic Press, New York, 1971.

Zienkiewicz, O. C., The Finite Element Method in Engineering

Science, McGraw-Hill, London, 1971.

957

INDEX

A Absolute value, normalized, 68

Accuracy, 58–59, 112

Adams-Bashforth, 771–773

Adams-Moulton, 773–774

Adaptive quadrature, 601, 633, 640–642

Adaptive Runge-Kutta (RK) methods,

707, 744–751

Adaptive step-size control, 745, 748–749, 768

Addition, 73

large and small number, 75–76

matrix operations, 236

smearing, 77–79

Advanced methods/additional references,

113–114

curve  tting, 584–585

linear algebraic equations, 342–343

numerical integration, 695

ordinary differential equations (ODEs),

842–843

partial differential equations (PDEs), 932

roots of equations, 227–229

Air resistance

falling parachutist problem, 14–18

formulation, 14

Alternating-direction implicit (ADI) method,

850, 878–882, 885–888, 931, 932

Amplitude, 528–529

Analytical methods of problem solving

falling parachutist problem, 14–17. See also

Falling parachutist problem

nature of, 14, 15

Angular frequency, 529

Antidifferentiation, 599

Approximations, 55–64. See also Estimation

accuracy/inaccuracy, 58–59, 112

approximate percent relative error,

61, 62, 114

computer algorithm for iterative

calculations, 62–64

error calculation, 59–62

error de nitions, 59–64

 nite-element methods, 891–894

polynomial, 83–85

precision/imprecision, 58–59

signi cant  gures/digits, 56–57

Taylor series, 81–86, 92–97, 655–658

Areal integrals, 596

Arithmetic mean, 444

Arithmetic operations, 73–74, 937–939,

944–945

Assemblage property matrix, 894

Associative property, matrix operations, 238

Augmentation, matrix operations, 239–240

Auxiliary conditions, 705

B Background information

blunders, 106–107

computer programming and software, 27–28

conservation laws and engineering, 18–21

curve  tting, 443–452

data uncertainty, 58–59, 107, 662

differential calculus, 597–599

eigenvalue problems, 789

error propagation, 97–101, 114

Excel, 39–43. See also Excel

formulation errors, 107

integral calculus, 597–599

linear algebraic equations, 233–241

Mathcad, 47–48, 943–953. See also

Mathcad

MATLAB, 43–47, 935–942. See also

MATLAB

modular programming, 37–39

numerical differentiation, 93–97

optimization, 350–351

ordinary differential equations (ODEs),

703–705

overview of problem-solving process, 12

polynomials, 176–179

root equation, 119–120, 179–182

round-off errors, 65–79, 103–105

simple mathematical model, 11–18

structured programming, 28–37

Taylor series, 81–97

total numerical error, 101–106

truncation errors, 81, 89–93, 103–105

Back substitution, 254–256

LU decomposition, 283, 301

Backward de! ation, 182

Backward difference approximation, 93–94

Bairstow’s method, 187–191, 226

Banded matrices, 300–301

Base-2 (binary) number system, 65, 67–72

Base-8 (octal) number system, 65

Base-10 (decimal) number system, 65, 66–67,

73–74

Basic feasible solution, 397, 398

Basic variables, 397

BFGS algorithm, 388, 401

Bilinear interpolation, 522–523

Binary (base-2) number system, 65, 67–72

Binding constraints, 394

Bisection method, 120, 127–135, 226, 356–357

bisection algorithm, 133, 134

computer methods, 132–133

de ned, 127

error estimates, 129–133

false-position method versus, 137, 138–139

graphical method, 128–129, 130, 131, 228

incremental search methods versus, 127

minimizing function evaluations, 134–135

problem statement/solution, 128–129

termination criteria, 129

Blunders, 106–107

Boole’s rule, 622, 623, 641–642

Boundary conditions

derivative, 787–788, 860–863, 877

 nite-element methods, 894, 903,

906–908, 927

irregular boundaries, 863–866

Laplace equation, 850, 855–858, 860–866

Boundary-value problems, 705, 782–789, 842

eigenvalue, 792–795

shooting method, 707, 782, 783–786

Bracketing methods, 123–141, 227, 366

bisection method, 120, 127–135, 226,

356–357

computer methods, 126–127

de ned, 123

false-position method, 120, 135–141, 226

958 INDEX

Bracketing methods—Cont.

graphical method, 123–127, 128

incremental searches/determining initial

guesses, 141

Break command, 46

Break loops, 32, 33–34

Brent’s method, 120–121, 162–166, 226, 227

computer methods, 164–166, 366–368

graphical method, 162, 163

inverse quadratic interpolation, 162–164

optimization, 352, 356, 366–368, 438

root of polynomials, 199

Broyden-Fletcher-Goldfarb-Shanno (BFGS)

algorithms, 388, 401

B splines, 585

Butcher’s  fth-order Runge-Kutta method,

737–739

Butter! y network, 547, 549

C C11, 48

Cartesian coordinates, 596

CASE structure, 31, 32, 41, 45

Cash-Karp RK method, 747, 749–750

Centered  nite divided-difference

approximation, 94, 95

Central Limit Theorem, 449

Chaotic solutions, 822

Characteristic, 67–68

Characteristic equation, 177–178

Charge, conservation of, 20

Chebyshev economization, 585

Chemical/biological engineering

analyzing transient response of reactor,

811–818

conservation of mass, 20

determining total quantity of heat, 673–675

ideal gas law, 204–207

integral calculus, 673–675

least-cost design of a tank, 416–420

linear algebraic equations, 319–322

linear regression, 563–567

one-dimensional mass balance of reactor,

915–919

optimization, 416–420

ordinary differential equations (ODEs),

811–818

partial differential equations (PDEs),

915–919

population growth models, 563–567

roots of equations, 204–207

steady-state analysis of system of reactors,

319–322

Cholesky decomposition, 302–304

Chopping, 70–71

Civil/environmental engineering

analysis of statically determinate truss,

322–326

conservation of momentum, 20

curve  tting, 567–568

de! ections of a plate, 919–921

effective force on mast of racing sailboat,

675–677

greenhouse gases and rainwater, 207–209

integral calculus, 675–677

least-cost treatment of wastewater,

421–424

linear algebraic equations, 322–326

optimization, 416, 421–424

ordinary differential equations (ODEs),

818–822

partial differential equations (PDEs),

919–921

predator-prey models and chaos,

818–822

roots of equations, 207–209

splines to estimate heat transfer, 567–568

Classical fourth-order Runge-Kutta method,

735–737, 843

Coef cient, method of undetermined, 644–645

Coef cient of determination, 463

Coef cient of interpolating polynomial, 507

Coef cient of thermal conductivity, 853

Coef cient of variation, 445

Colebrook equation, 212, 214

Column vectors, 234

Commutative property, matrix operations,

236, 238

Complex systems, linear algebraic

equations, 271

Composite, integration formulas, 609–612

Computational error, 59–62, 74

Computer programming and software, 27–48, 111.

See also Pseudocode algorithms

bisection method, 133, 134

bracketing methods, 126–127

Brent’s method, 164–166

computer programs, de ned, 28

cost comparison, 111–113

curve  tting, 449–450, 454, 465–468,

475–476, 478–479, 552–560

Excel. See Excel

linear algebraic equations, 243–244,

269–270, 311–316

linear programming, 402–404

linear regression, 464–468

Mathcad. See Mathcad

MATLAB. See MATLAB

modular programming, 37–39

numerical integration/differentiation,

663–670

optimization, 352, 402–413, 419–420

ordinary differential equations (ODEs), 707,

718–721, 728, 739, 742–744, 749–751,

801–808

other languages and libraries, 48

partial differential equations (PDEs), 850,

869–870, 908–912

roots of equations, 126–127, 192–201

software user types, 27–28

step-size control, 768

structured programming, 28–37

trapezoidal rule algorithms, 612–615

Condition numbers, 100–101

matrix, 241, 294–296

Con dence intervals, 446–452, 481–482

Conjugate directions, 374

Conjugate gradient, 352, 386–388, 401

Conservation laws, 18–21

by  eld of engineering, 20

simple models in speci c  elds, 19, 20

stimulus-response computations, 290–291

Conservation of charge, 20

Conservation of energy, 20

Conservation of mass, 20, 319–322

Conservation of momentum, 20

Constant of integration, 704

Constant step size, 768

Constitutive equation, 853–854

Constrained optimization, 351, 352, 390–401

linear programming, 350, 352, 390–401

nonlinear, 352, 401, 404–408, 413

Constraints

binding/nonbinding, 394

optimization, 348, 350

Continuous Fourier series, 533–536

approximation, 534–536

determination of coef cients, 534

Control-volume approach, 866–869

Convergences

de ned, 877

 xed-point iteration, 147–150

Gauss-Seidel (Liebmann) method, 306–309

linear, 147–150

nature of, 150

of numerical methods of problem

solving, 111

Cooley-Tukey algorithm, 545, 550–551

Corrector equation, 723, 759–760

INDEX 959

Correlation coef cient, 463

Count-controlled loops, 33–34, 41, 45, 46

Cramer’s Rule, 248, 249–250, 341

Crank-Nicolson method, 850, 882–885,

931, 932

Critically damped case, 178–179

Crout decomposition, 285–287

Cubic splines, 511, 517–521, 582, 584, 695

computer algorithms, 520–521

derivation, 518–519

interpolation with Mathcad, 559–560

Cumulative normal distribution, 651–653

Current balance, 20

Curvature, 588

Curve  tting, 441–585

advanced methods and additional references,

584–585

case studies, 563–571

coef cients of an interpolating

polynomial, 507

comparisons of alternative methods,

582–583

computer methods, 449–450, 454, 465–468,

475–476, 478–479, 552–560

de ned, 441

engineering applications, 442–443, 563–571

estimation of con dence intervals, 446–452,

481–482

extrapolation, 508–509

Fourier approximation, 479, 526–560, 583

general linear least squares model,

453, 479–483

goals/objectives, 454–455

important relationships and formulas,

583–584

interpolation, 441, 454, 490–509

inverse interpolation, 507–508

Lagrange interpolating polynomial, 454,

490, 502–507, 509, 582, 584

least-squares regression, 441, 452, 456–486

linear regression, 452, 456–472

mathematical background, 443–452

multidimensional interpolation, 521–523

multiple linear regression, 452, 476–479,

582, 583, 584

Newton’s divided-difference interpolating

polynomials, 491–502

Newton’s interpolating polynomial, 454,

490, 491–502, 504–505, 509, 582, 584

noncomputer methods, 441–442

nonlinear regression, 470, 483–486,

555, 582

normal distribution, 446

polynomial regression, 452, 472–476, 583, 584

power spectrum, 551–552

scope/preview, 452–454

simple statistics, 443–446

with sinusoidal functions, 527–533

spline interpolation, 454, 511–521

time domains, 536–540

D Data distribution, 446

Data uncertainty, 58–59, 107, 662

Davidon-Fletcher-Powell (DFP) method of

optimization, 388, 439

Decimal (base-10) number system, 65, 66–67,

73–74

Decimation-in-frequency, 545

Decimation-on-time, 545

Decision loops, 32

De nite integration, 588n

De! ation, 800

forward, 181–182

polynomial, 180–182

Degrees of freedom, 444

Dependent variables, 11–12, 118, 699

Derivative boundary conditions, 787–788,

860–863, 877

Derivative mean-value theorem, 88

Descriptive models, 346

Design, 21

Design variables, 35, 350

Determinants, in Gauss elimination, 248–249,

261–263

Determination, coef cient of, 463

Diagonally dominant systems, 309

Differential calculus, 587–590, 655–670. See

also Numerical differentiation;

Optimization; Ordinary differential

equations (ODEs); Partial differential

equations (PDEs)

data with errors, 661–662

differentiate, de ned, 587–588

differentiation of unequally spaced data,

660–661

differentiation with computer software,

663–670

engineering applications, 593–594, 663–670

 rst derivative, 587–588, 656–657

goals/objectives, 601–602

high-accuracy differentiation formulas,

601, 655–658

mathematical background, 597–599

noncomputer methods for differentiation,

590–592

numerical differentiation with software

packages, 663–670

partial derivatives, 588, 662–663

Richardson’s extrapolation, 601, 633,

635–638, 641, 658–660

scope/preview, 599–601

second derivative, 588, 656–657

terminology, 587–589

Differential equations, 13–16, 27, 38, 699

Direct approach

 nite-element methods, 897–901

optimization, 352, 370, 371–375

Directional derivative, 376

Dirichlet boundary condition, 787–788,

855–858, 909

Discrete Fourier transform (DFT), 542–544

Discretization,  nite-element methods, 891,

896, 904, 924–925

Discriminant, 178

Distributed-parameter system, 916

Distributed variable systems, 232, 233

Distributive property, matrix operations, 238

Division, 74

synthetic, 180–181

by zero, 258

DOEXIT construct, 32, 33, 35, 41, 45

DOFOR loops, 33–34

Double integrals, 627–629

Double roots, 166, 167

Drag coef cient, 14

Dynamic instability, 919

E Eigenvalue problems, 789–808

boundary-value problem, 792–795

computer methods, 801–808

eigenvalue, de ned, 789

eigenvalue analysis of axially loaded

column, 794–795

eigenvectors, 789, 791–792

mass-spring system, 791–792

mathematical background, 789

other methods, 800–801

physical background, 790–792

polynomial method, 177–178, 795–797

power method, 707, 797–800

Eigenvectors, 789, 791–792

Electrical engineering

conservation of charge, 20

conservation of energy, 20

currents and voltages in resistor circuits,

326–328

curve  tting, 569–570

960 INDEX

Electrical engineering—Cont.

design of electrical circuit, 209–212

Fourier analysis, 569–570

integral calculus, 677–680

linear algebraic equations, 326–328

maximum power transfer for a circuit,

425–429

optimization, 416, 425–429

ordinary differential equations (ODEs),

822–827

partial differential equations (PDEs),

921–924

root-mean-square current, 677–680

roots of equations, 209–212

simulating transient current for electric

circuit, 822–827

two-dimensional electrostatic  eld

problems, 921–924

Element properties,  nite-element methods, 894

Element stiffness matrix, 894, 926

Elimination of unknowns, 250–256

back substitution, 254–256

forward, 252–254

Elliptic partial differential equations (PDEs),

846–847, 852–870, 931, 932

boundary conditions, 850, 860–866

computer software solutions, 869–870

control-volume approach, 866–869

Gauss-Seidel (Liebmann) method,

850, 856–858, 881

Laplace equation, 846, 850, 852–866,

922–924

Embedded Runge-Kutta (RK) method, 747

ENDDO statement, 33–34

End statement, 46

Energy

conservation of, 20

equilibrium and minimum potential, 429–430

Energy balance, 118

Engineering problem solving

chemical engineering. See Chemical/

biological engineering

civil engineering. See Civil/environmental

engineering

conservation laws, 18–21

curve  tting, 442–443, 563–571

dependent variables, 11–12, 118

differential calculus, 593–594, 663–670

electrical engineering. See Electrical

engineering

falling parachutist problem. See Falling

parachutist problem

forcing functions, 11–12

fundamental principles, 118

independent variables, 11–12, 118

integral calculus, 594–597, 663–670,

673–683

linear algebraic equations, 232–233,

319–330

mechanical engineering. See Mechanical/

aerospace engineering

Newton’s second law of motion, 11–18,

55, 118, 328, 702

numerical differentiation, 593–597

optimization, 346–350, 352, 416–430

ordinary differential equations (ODEs),

701–702, 707, 811–830

parameters, 11–12, 118, 816

partial differential equations (PDEs),

846–848, 850, 915–927

practical issues, 21

roots of equations, 118–119, 122, 176–179,

204–215

two-pronged approach, 11, 12, 14–18

Entering variables, 398–399

Epilimnion, 567

Equal-area graphical differentiation, 590–591

Equality constraint optimization, 350

Error(s)

approximations. See Approximations

bisection method, 129–133

blunders, 106–107

calculation, 59–62, 74

data uncertainty, 58–59, 107, 662

de ned, 55

differential calculus, 661–662

estimates for iterative methods, 61–62

estimates in multistep method, 764–765

estimation, 464

estimation for Euler’s method, 714–715

falling parachutist problem, 55

formulation, 107

Gauss quadrature, 649–650

integral calculus, 661–662

linear algebraic equations, 291–297

Newton-Raphson estimation method,

152–154

Newton’s divided-difference interpolating

polynomial estimation, 497–502

numerical differentiation, 102–105

predictor-corrector approach, 723–724,

762–767

quantizing, 70–71, 72, 75

relative, 100

residual, 457, 461–464

round-off. See Round-off errors

Simpson’s 1/3 rule estimation, 616

true fractional relative error, 59

truncation. See Truncation errors

Error de nitions, 59–64

approximate percent relative error, 61, 62, 114

stopping criterion, 62, 63, 114

true error, 59, 98, 104, 114

true percent relative error, 59, 61, 64, 114

Error propagation, 97–101, 114

condition, 100–101

functions of more than one variable, 99–100

functions of single variable, 97–98

stability, 100–101

Estimated mean, 449

Estimation. See also Approximations

con dence interval, 446–452, 481–482

errors, 464, 497–502, 616, 714–715

Newton-Raphson estimation method,

152–154

parameter, 816

standard error of the estimate, 462

standard normal estimate, 448–449

Euler-Cauchy method. See Euler’s method

Euler’s method, 16–17, 27, 38, 48, 178–179

algorithm for, 718–721

backward/implicit, 757

effect of reduced step size, 715–717

error analysis, 712–717

Euler’s formula, 794

improvements, 721–729

ordinary differential equations (ODEs),

705–707, 710–729, 841, 842, 843

as predictor, 759–760

problem statement/solution, 710–712

systems of equations, 740

Excel, 27–28, 33, 39–43

computer implementation of iterative

calculation, 63–64

curve  tting, 552–555, 566–567

Data Analysis Toolpack, 552, 553–555

described, 39

Goal Seek, 192, 193

linear algebraic equations, 311–312

linear programming, 402–404

linear regression, 464

nonlinear constrained optimization, 404–408

optimization, 352, 402–408, 419–420,

423–425

ordinary differential equations (ODEs), 801,

817–818

INDEX 961

partial differential equations (PDEs),

908–910

roots of equations, 77, 192–195, 212–213

Solver, 192, 193–195, 402–408, 423–429,

566–567, 801, 817–818

standard use, 39–40

Trendline command, 552–553

VBA macros, 40–43

Explicit solution technique

de ned, 118

ordinary differential equations (ODEs),

757–759

parabolic partial differential equations

(PDEs), 874–878, 879, 885, 931

Exponent, 67–68

Exponential model of linear regression,

469–470

Extended midpoint rule, 651

Extrapolation, 508–509

Extreme points, 395

Extremium, 356–359

F Factors, polynomial, 180

Falling parachutist problem, 14–18, 118–119

analytical problem statement/solution, 14–17

computer algorithm, 269–270

error, 55

Gauss elimination, 269–270

Gauss quadrature application, 649

numerical problem statement/solution,

17–18

optimization of parachute drop cost,

347–350, 404–408

schematic diagram, 13

velocity of the parachutist, 465–468,

505–507, 709–710

False-position method, 120, 135–141, 226

bisection method versus, 137, 138–139

false-position formula, 136–138

graphical method, 135, 139, 228

modi ed false positions, 140–141, 226

pitfalls, 138–141

problem statement/solution, 136–138

secant method versus, 158–160

Faraday’s law, 702

Fast Fourier transform (FFT), 454,

544–551, 560

Cooley-Tukey algorithm, 545, 550–551

Sande-Tukey algorithm, 545, 546–550

Feasible extreme points, 395

Feasible solution space, 392–395

Fibonacci numbers, 358–359

Fick’s law of diffusion, 702

Finish, 33–34

Finite-difference methods, 16–17, 81, 93,

95–97, 655–658

elliptic partial differential equations (PDEs),

846–847, 850, 852–870, 931, 932

high-accuracy differentiation formulas,

601, 655–658

optimization, 380–381

ordinary differential equations (ODEs),

707, 786–789

parabolic partial differential equations

(PDEs), 846, 847–848, 850, 852–870,

873–888, 931, 932

Finite-divided-difference approximations of

derivatives, 93, 95–97

Finite-element methods, 890–908

assembly, 894, 901–903, 926–927

boundary conditions, 894, 903, 906–908, 927

de ned, 890–891

discretization, 891, 896, 904, 924–925

element equations, 891–894, 897–901,

904–906, 925–926

general approach, 891–894

partial differential equations (PDEs), 850,

890–908, 931

single dimension, 895–904

solution and postprocessing, 894, 904, 908, 927

two dimensions, 904–908

First backward difference, 93–94

First derivative, 587–588, 656–657

First  nite divided difference, 93

First forward difference, 93, 114

First forward  nite divided difference, 93, 95,

96, 114

First-order approximation, 81–82, 84, 86, 92–93

First-order methods, 699, 715

First-order splines, 513–514

Fixed (Dirichlet) boundary condition, 787–788,

855–858, 909

Fixed-point iteration, 146–151, 226

algorithm, 150–151

convergences, 147–150

graphical method, 147–150

nonlinear equations, 170–171

Fletcher-Reeves conjugate gradient algorithm,

386–387, 439

Floating-point operations/! ops, 256–258

Floating-point representation, 67–72

chopping, 70–71

fractional part/mantissa/signi cand, 67–68

integer part/exponent/characteristic, 67–68

machine epsilon, 71–72

over! ow error, 69–70

quantizing errors, 70–71, 72, 75

Flowcharts, 29–31

sequence structure, 30

simple selection constructs, 31

symbols, 29

Force balance, 20, 118

Forcing functions, 11–12

Formulation errors, 107

Fortran 90, 48, 74–75

Forward de! ation, 181–182

Forward elimination of unknowns, 252–254

Forward substitution, LU decomposition,

283, 301

Fourier approximation, 479, 526–552, 583

continuous Fourier series, 534–536

curve  tting with sinusoidal functions,

527–533

de ned, 526–527

discrete Fourier transform (DFT), 542–544

engineering applications, 569–570

fast Fourier transform (FFT), 454,

544–551, 560

Fourier integral and transform, 540–551

frequency domain, 536–540

power spectrum, 551–552

time domain, 536–540

Fourier integral, 540–542

Fourier series, 533–536, 537, 933–934

Fourier’s law of heat conduction, 593–594, 702,

853, 921

Fourier transform, 540–551

discrete Fourier transform (DFT),

542–544

fast Fourier transform (FFT), 454,

544–551, 560

Fourier transform pair, 540

Fourth derivative, 656–657

Fourth-order methods

Adams, 771–774, 777–779, 841, 842, 843

Runge-Kutta, 735–737, 741–742, 743, 746,

750–751, 843

Fractional parts, 67–68

Fractions, ! oating-point representation, 68

Frequency domain, 536–540

Frequency plane, 536–537

Friction factor, 212

Frobenius norm, 294

Fully augmented version, 396

FUNCTION, 38

962 INDEX

Function(s)

error propagation, 97–100

forcing, 11–12

interpolation, 892–893

mathematical behavior, 112

modular programming, 37

penalty, 401

sinusoidal, 527–533

spline, 511, 585

Functional approximation, 585

Fundamental frequency, 533

Fundamental theorem of integral calculus, 598

G Gauss elimination, 245–275, 343

computer algorithm, 269–270

Cramer’s Rule, 248, 249–250, 341

determinants, 248–249, 261–263

elimination of unknowns, 250–251

Gauss-Jordan method, 273–275

graphical method, 245–247

improving solutions, 264–269

LU decomposition version, 280–285

more signi cant  gures, 264

naive, 252–258

operation counting, 256–258

pitfalls of elimination methods, 258–264

pivoting, 241, 253–254, 258, 264–269, 341

solving small numbers of equations, 245–251

Gauss-Jordan method, 273–275

Gauss-Legendre formulas, 643, 645–650,

679, 695

higher-point, 648–649

two-point, 645–648

Gauss-Newton method, 483–486, 585

Gauss quadrature, 601, 633, 642–650, 680,

694, 696

error analysis, 649–650

Gauss-Legendre formulas, 643, 645–650,

679, 695

method of undetermined coef cients,

644–645

Gauss-Seidel (Liebmann) method, 241–242,

300, 304–311, 341–342, 343, 931

algorithm, 309–310

convergence criterion, 306–309

elliptic partial differential equations (PDEs),

850, 856–858, 881

graphical method, 307

iteration cobwebs, 308

problem contexts, 310–311

relaxation, 309

Generalized reduced gradient (GRG), 401, 439

General linear least-squares model, 453, 479–483

con dence intervals for linear regression,

481–482

general matrix formulation, 479–480

statistical aspects of least-squares theory,

480–483

General solution, 177

Genetic algorithm, 373

Given’s method, 801

Global truncation error, 713

Golden ratio, 358–359

Golden-section search optimization, 352,

356–363, 427–428, 438

extremium, 356–359

golden ratio, 358–359

single-variable optimization, 356

unimodal, 356–357

Gradient, de ned, 594

Gradient methods of optimization, 352, 370,

375–388

conjugate gradient method (Fletcher-Reeves),

352, 386–387, 439

 nite difference approximation, 380–381

gradients, 376–378

Hessian, 352, 378–380, 439

Marquardt’s method, 352, 387–388, 585

path of steepest ascent/descent, 352,

377–378, 381–386, 585

quasi-Newton methods, 352, 388, 401, 439

Graphical methods

bisection, 128–129, 130, 131, 228

bracketing, 123–127, 128

Brent’s method, 162, 163

false-position method, 135, 139, 228

 xed-point iteration, 147–150

Gauss elimination, 245–247

Gauss-Seidel (Liebmann) method, 307

linear algebraic equations, 245–247,

320–321, 323, 325, 327–329, 341

linear programming, 392–395

Newton-Raphson method, 151, 156, 228

open, 145

roots of equations, 117, 120–121, 123–127,

145, 146–151, 157–166, 226

secant, 157, 159, 160, 162, 228

Greenhouse gases, 207–209

H Half-saturation constant, 563–564

Hamming’s method, 779

Harmonics, 533

Hazen-Williams-equation, 571

Heat balance, 118

Heat-conduction equation, 846, 847–848,

873–888. See also Parabolic partial

differential equations (PDEs)

Hessenberg form, 801

Hessian, 352, 378–380, 439

Heun’s method, 707, 722–726, 728, 729, 732,

841, 843

High-accuracy differentiation formulas, 601,

655–658

Histograms, 447–448

Hooke’s law, 328, 429–430

Hotelling’s method, 800

Householder’s method, 801

Hyperbolic partial differential equations (PDEs),

846, 848

Hypolimnion, 567

Hypothesis testing, 442–443

I Ideal gas law, 204–207

IEEE format, 72

IF/THEN/ELSE/IF structure, 31, 41, 45

IF/THEN/ELSE structure, 30, 31, 32, 35, 41, 45

IF/THEN structure, 30, 31, 37, 41, 45, 266

Ill-conditioned systems, 101, 259–263

effect of scale on determinant, 261–263

elements of matrix inverse as measure

of, 292

singular systems, 247, 263–264

Implicit solution technique

de ned, 119

ordinary differential equations (ODEs),

707, 755, 757–759

parabolic partial differential equations (PDEs),

850, 878–882, 885–888, 931, 932

Imprecision, 58–59

Improper integrals, 601, 633, 650–653

cumulative normal distribution, 651–653

extended midpoint rule, 651

normalized standard deviate, 651–653

Improved polygon method. See Midpoint

(improved polygon) method

Inaccuracy, 58–59

Incremental search methods

bisection method versus, 127

de ned, 127

determining initial guesses, 141

Increment function, 729–730

Inde nite integral, 700

Inde nite integration, 588n

INDEX 963

Independent variables, 11–12, 118, 699

Indexes, 33–34

Inequality constraint optimization, 350

Inferential statistics, 447, 449

Initial value, 705

Initial-value problems, 705, 781

Inner products, 79

In place implementation, 266

INPUT statements, 38

Integer part, 67–68

Integer representation, 65–67

Integral, 348–349

Integral calculus, 588–590, 633–653

Adams formula, 771–774, 777–779, 841,

842, 843

adaptive quadrature, 601, 633, 640–642

Boole’s rule, 622, 623, 641–642

calculation of integrals, 594–597

closed forms, 599–601, 604–605, 622–624,

633–634, 771, 773–774

data with errors, 661–662

engineering applications, 594–597,

663–670, 673–683

fundamental theorem, 598

Gauss quadrature, 601, 633, 642–650, 680,

694, 696

goals/objectives, 601–602

improper integrals, 601, 633, 650–653

integrate, de ned, 588

integration with computer software, 663–670

integration with unequal segments,

601, 624–627

mathematical background, 597–599

multiple integrals, 627–629

Newton-Cotes formulas, 599–601, 603–629,

633–634, 694–695, 728, 768–771

noncomputer methods for integration, 592

numerical integration with software

packages, 663–670

open forms, 601, 604–605, 627, 633,

650–651, 770–773

Richardson’s extrapolation, 601, 633,

635–638, 641, 658–660

Romberg integration, 601, 633, 634–640,

641, 679, 694, 696

scope/preview, 599–601

Simpson’s 1/3 rule, 600, 615–620, 622, 623,

676, 694, 696

Simpson’s 3/8 rule, 600, 620–622, 623,

694, 696

Simpson’s rules, 600, 615–624, 625–627,

641, 696

terminology, 588

trapezoidal rule, 600, 605–615, 623,

624–627, 636–637, 676, 694, 696, 726

Integral form, 82

Integrand, 588, 664

Interdependent computations, 74–75

Interpolation

coef cients of interpolating polynomial, 507

computers in, 505–507, 559–560

curve  tting, 441, 454, 490–509

with equally spaced data, 508–510

 nite-element methods, 892–893

interpolation functions, 892–893

inverse, 507–508

inverse quadratic, 162–164

Lagrange interpolating polynomials, 454,

490, 502–507, 509, 582, 584

linear interpolation method, 162, 491–492

multidimensional, 521–523

Newton’s divided-difference interpolating

polynomials, 454, 490, 491–502,

504–505, 509, 582, 584

polynomial, 490–509

quadratic, 493–495

spline, 454, 511–521

Interval estimator, 447

Inverse Fourier transform of F, 540–541

Inverse interpolation, 507–508

Inverse quadratic interpolation, 162–164

Irregular boundaries, 863–866

Iterative approach to computation

computer algorithms, 62–64

de ned, 60–61

error estimates, 61–62

Gauss-Seidel (Liebmann) method, 241–242,

300, 304–311, 341–342, 343, 931

iterative re nement, 296–297

J Jacobian, 172

Jacobi iteration, 306

Jacobi’s method, 800–801

Jenkins-Traub method, 192, 229

K Kirchhoff’s laws, 118, 209–212, 326, 822

L Lagging phase angle, 529

Lagrange interpolating polynomials, 454, 490,

502–507, 509, 582, 584

Lagrange multiplier, 346, 424

Lagrange polynomial, 163

Laguerre’s method, 192, 199, 229

Laplace equation, 846, 852–866, 922–924

boundary conditions, 850, 855–858, 860–866

described, 852–854

! ux distribution of heated plate, 859–860

Liebmann method, 850, 856–858, 931

secondary variables, 859–860

solution technique, 854–860

Laplacian difference equation, 855–856

Large computations, interdependent

computations, 74–75

Large versus small systems, 21

Least-squares  t of a sinusoid, 530–533

Least-squares regression

curve  tting, 441, 452, 456–486

general linear least-squares model, 453,

479–483

least-squares  t of a straight line, 459–461

linear regression, 452, 456–472, 582–584

Leaving variables, 398–399

Levenberg-Marquardt method, 412

Liebmann method. See Gauss-Seidel

(Liebmann) method

Linear algebraic equations, 231–343

advanced methods and additional references,

342–343

case studies, 319–330

comparisons of methods, 341–342

complex systems, 271

computer methods, 243–244, 269–270,

311–316

Cramer’s rule, 248, 249–250, 341

determinants, 248–249

distributed variable systems, 232, 233

division by zero, 258

elimination of unknowns, 250–251

engineering applications, 232–233, 319–330

error analysis, 291–297

Gauss elimination, 241, 245–277, 341, 343

Gauss-Jordan method, 273–275

Gauss-Seidel (Liebmann) method, 241–242,

300, 304–311, 341–342, 343, 931

general form, 231

goals/objectives, 243–244

graphical method, 245–247, 320–321, 323,

325, 327–329, 341

ill-conditioned systems, 247, 259–263

important relationships and formulas,

342, 343

LU decomposition methods, 241, 278–287,

330, 341, 343

964 INDEX

Linear algebraic equations—Cont.

lumped variable systems, 232, 233

mathematical background, 233–241

matrix inverse, 238–239, 241, 287–291

matrix notation, 234–235

matrix operating rules, 236–240

more signi cant  gures, 264

noncomputer methods for solving, 231–232

nonlinear systems of equations, 271–273

pivoting, 241, 253–254, 258, 264–266

representing in matrix form, 240–241

round-off errors, 259

scaling, 261–263, 266–269

scope/preview, 241–243

singular systems, 247, 263–264

special matrices, 300–304

system condition, 291–297

Linear convergences, 147–150

Linear interpolation method. See also Brent’s

method; False-position method

de ned, 162, 491–492

linear-interpolation formula, 491–492

Linearization, 700–701

Linear programming

computer solutions, 402–404

de ned, 390

feasible solution space, 392–395

graphical solution, 392–395

optimization, 346, 350, 352, 390–401

possible outcomes, 394–395

setting up problem, 391–392

simplex method, 346, 352, 396–401

standard form, 390–392

Linear regression, 456–472, 582–584

computer programs, 464–468

con dence intervals, 481–482

criteria for “best”  t, 458–459

curve  tting, 452, 456–472

estimation errors, 464

exponential model, 469–470

general comments, 472

general linear least-squares model,

479–483

least-squares  t of straight line, 459–461

linearization of nonlinear relationships,

468–472

linearization of power equation, 470–472

minimax criterion, 459, 585

multiple, 452, 476–479, 582, 583, 584

quanti cation of error, 461–464

residual error, 457, 461–464

standard error of the estimate, 462

Linear splines, 511–514

Linear trend, 82–83

Line spectra, 538–540

Local truncation error, 713

Logical representation, 30–37

algorithm for root of a quadratic, 34–37

repetition, 31–34

selection, 30–31

sequence, 30

Lorenz equations, 819–822

Lotka-Volterra equations, 818–822

LR method (Rutishauser), 801

LU decomposition methods, 241, 278–287,

330, 341, 343

algorithm, 282, 284–285, 286–287

Crout decomposition, 285–287

de ned, 278

LU decomposition step, 279, 280, 283, 284,

300, 301

overview, 279–280

substitution step, 279, 280, 283–285

version of Gauss elimination, 280–285

Lumped-parameter systems, 915–916

Lumped variable systems, 232, 233

M MacCormack’s method, 877–878

Machine epsilon, 71–72

Maclaurin series expansion, 61–62

Mantissa, 67–69

Maple V, 48

Marquardt’s method, 352, 387–388, 585

Mass, conservation of, 20, 319–322

Mass balance, 20, 118

Mathcad, 47–48, 943–953

basics, 943–944

curve  tting, 558–560

entering text, 944

graphics, 949–951

linear algebraic equations, 314–316

mathematical functions and variables,

945–948

mathematical operations, 944–945

Minerr, 412

multigrid function, 911–912

multiline procedures/subprograms, 949

numerical integration/differentiation, 669–670

numerical methods function, 948

online help, 953

optimization, 352, 412–413

ordinary differential equations (ODEs),

806–808

partial differential equations (PDEs),

911–912

QuickSheets, 953

relax function, 911–912

resource center, 953

roots of equations, 199–201, 212–213

symbolic mathematics, 951–953

ToolTips, 953

Mathematical laws, 20

Mathematical models, de ned, 11–12

Mathematical programming. See Optimization

Mathsoft Inc., 47

MathWorks, Inc., 43

MATLAB, 27–28, 33, 935–942

assignment of values to variable names,

936–937

built-in functions, 939

computer implementation of iterative

calculation, 63–64

curve  tting, 555–558

described, 43

graphics, 939–940

linear algebraic equations, 312–314

linear regression, 464

mathematical operations, 937–939

matrix analysis, 313

M- les, 43–47, 103–105, 430

numerical differentiation, 103–105

numerical integration/differentiation,

663–669

optimization, 352, 366–368, 408–412, 430

ordinary differential equations (ODEs),

802–806, 815–817, 825–827

partial differential equations (PDEs),

910–911

polynomials, 940

roots of equations, 195–198, 212–213

statistical analysis, 940–941

Matrix condition number, 241, 294–296

Matrix inverse, 238–239, 241, 287–291

calculating, 288–290

stimulus-response computations, 290–291

Matrix norms, 292–294

Matrix operations

banded matrices, 300–301

Cholesky decomposition, 302–304

components, 234–235

error analysis and system condition,

291–297

matrix, de ned, 234

matrix condition number, 241, 294–296

matrix inverse, 238–239, 241, 287–291

INDEX 965

matrix notation, 234–235

representing linear algebraic equations in

matrix form, 240–241

rules, 236–240

symmetric matrices, 300

tridiagonal systems, 301–302

Maximum attainable growth, 563–564

Maximum likelihood principle, 461–462

Mean value, 444, 449, 528–529

con dence interval on the mean, 451–452

derivative mean-value theorem, 88

determining mean of discrete points,

594–595

spread around, 462

Mechanical/aerospace engineering

analysis of experimental data, 570–571

conservation of momentum, 20

curve  tting, 570–571

equilibrium and minimum potential energy,

429–430

 nite-element solution of series of springs,

924–927

integral calculus, 680–683

linear algebraic equations, 328–330

numerical integration to compute work,

680–683

optimization, 416, 429–430

ordinary differential equations (ODEs),

827–830

partial differential equations (PDEs),

924–927

pipe friction, 212–215

roots of equations, 212–215

spring-mass systems, 328–330

swinging pendulum, 827–830

Method of false position. See False-position

method

Method of lines, 877–878

Method of undetermined coef cients, 644–645

Method of weighted residuals (MWR),

 nite-element methods, 897–901

M- les (MATLAB), 43–47, 103–105, 430

Microsoft, Inc., 39

Midpoint (improved polygon) method, 707,

726–728, 729, 733–734

Milne’s method, 775–779, 841

Minimax criterion, 459, 585

MINPACK algorithms, 412

Mixed partial derivatives, 663

Modi ed Euler. See Midpoint (improved

polygon) method

Modi ed secant method, 161–162, 226

Modular programming, 37–39

advantages, 38

de ned, 37

Momentum, conservation of, 20

m surplus variables, 396–397

Müller’s method, 183–187, 199, 226

Multidimensional interpolation, 521–523

Multidimensional unconstrained optimization,

370–388

direct methods (nongradient), 352, 370,

371–375

gradient methods (descent/ascent), 352, 370,

375–388

MATLAB, 410–412

pattern directions, 374–375

Powell’s method, 374–375, 386, 438

random search method, 352, 371–373

univariate search method, 352, 373

Multimodal optimization, 355–356

Multiple-application trapezoidal rule,

609–612, 696

Multiple integrals, 627–629

Multiple linear regression, 452, 476–479, 582,

583, 584

Multiple roots, 125, 166–169

double roots, 166, 167

modi ed Newton-Raphson method for

multiple roots, 167–169, 226

Newton-Raphson method, 166–167

secant method, 166–167

triple roots, 166, 167

Multiplication, 74

inner products, 79

matrix operations, 236–238

Multistep methods, 707, 755, 759–779, 841

N Naive Gauss elimination, 252–258

back substitution, 254–256

forward elimination of unknowns, 252–254

operation counting, 256–258

n-dimensional vector, 350

Newmann boundary condition, 787–788,

860–863

Newton-Cotes integration formulas, 599–601,

603–629, 633–634, 728

Boole’s rule, 622, 623, 641–642

closed formulas, 771, 773–774

comparisons, 694–695

de ned, 603

higher-order, 622–624, 637–638, 694

open formulas, 770–771

ordinary differential equations (ODEs),

768–771

Simpson’s 1/3 rule, 600, 615–620, 622, 623,

625–627, 676, 694, 696

Simpson’s 3/8 rule, 600, 620–622, 623,

625–627, 694, 696

trapezoidal rule, 600, 605–615, 623–627,

636–637, 676, 694, 696, 726

Newton-Raphson method, 120–121, 151–157,

206–207, 214, 227, 365

algorithm, 155–157

error estimates, 152–154

graphical method, 151, 156, 228

modi ed method for multiple roots,

167–169, 226

multiple roots, 166–167

Newton-Raphson formula, 152

nonlinear equations, 171–173

pitfalls, 154–155

polynomials, 183, 188

slowly converging function, 154–155

Taylor series expansion, 272

termination criteria, 152–154

Newton’s divided-difference interpolating

polynomials, 454, 490, 491–502, 509, 582, 584

computer algorithm, 499–502

de ned, 496–497

derivation of Lagrange interpolating

polynomial from, 504–505

error estimation, 497–502

general form, 495–497

quadratic interpolation, 493–495

Newton’s laws of motion, 118, 827–828

Newton’s method optimization, 352, 365–366,

380, 438–439

Newton’s second law of motion, 11–18, 55, 118,

328, 702

Nodal lines/planes, 891

Nonbasic variables, 397

Nonbinding constraints, 394

Nonideal versus idealized laws, 21

Nonlinear constrained optimization, 352, 401

Excel, 404–408

Mathcad, 413

Nonlinear equations

de ned, 169

 xed-point iteration, 170–171

linear equations versus, 21, 169

Newton-Raphson method, 171–173

roots of equations, 121, 169–173

systems of equations, 120–121, 231–232,

271–273

966 INDEX

Nonlinear programming optimization, 350

Nonlinear regression, 470, 483–486,

555, 582

Non-self-starting Heun, 228, 229, 707,

722–726, 732, 759–767, 841, 843

Normal distribution, 446

Normalized standard deviate, 651–653

Norms

de ned, 292

matrix, 292–294

vector, 292–294

nth  nite divided difference, 495–496

Number systems, 65. See also speci! c number

systems

Numerical differentiation, 93–97, 114, 655–670.

See also Differential calculus

backward difference approximation,

93–94

centered difference approximation, 95

with computer software, 663–670

control of numerical errors, 105–106

engineering applications, 593–597

error analysis, 102–105

 nite-divided-difference approximations,

93, 95–97

high-accuracy differentiation formulas,

601, 655–658

polynomial, 179–180

Richardson’s extrapolation, 601, 633,

635–638, 641, 658–660

Numerical integration. See also Integral

calculus

advanced methods and additional

references, 695

case studies, 673–683

comparisons, 694–695

with computer software, 663–670

engineering applications, 673–683

important relationships and formulas,

695, 696

Numerical methods of problem solving,

110, 111–112

falling parachutist problem, 17–18

nature of, 15–16

Numerical Recipe library, 48

Numerical stability, 100–101

O Objective function optimization, 348, 350

Octal (base-8) number system, 65

ODEs. See Ordinary differential equations

(ODEs)

Ohm’s law, 326

One-dimensional unconstrained optimization,

351, 352, 355–368

Brent’s method, 352, 356, 366–368

golden-section search, 352, 356–363,

427–428, 438

MATLAB, 409–410

multimodal, 355–356

Newton’s method, 352, 365–366, 380,

438–439

parabolic interpolation, 352, 363–365, 438

One-point iteration, 120

One-sided interval, 447

One-step methods, 705, 709–751, 841

Open methods, 120, 145–173, 366

de ned, 145–146

 xed-point iteration, 146–151

graphical method, 145

Optimal steepest ascent, 384–386, 585

Optimization, 345–439

additional references, 439

Brent’s method, 352, 356, 366–368, 438

case studies, 416–430

computer methods, 352, 402–413, 419–420

de ned, 345

engineering applications, 346–350, 352,

416–430

goals/objectives, 352–354

golden-section search, 352, 356–363,

427–428, 438

history, 346

linear programming, 346, 350, 352, 390–401

mathematical background, 350–351

multidimensional unconstrained,

352, 355–356, 370–388

Newton’s method, 352, 365–366, 380,

438–439

noncomputer methods, 346

nonlinear constrained optimization,

352, 401, 404–408, 413

one-dimensional unconstrained, 351, 352,

355–368

parabolic interpolation, 352, 363–365, 438

problem classi cation, 350–351

scope/preview, 352

Order of polynomials, 119

Ordinary differential equations (ODEs),

176–178, 699–843

advanced methods and additional references,

842–843

boundary-value problems, 705, 707,

782–789, 792–795, 842

case studies, 811–830

components, 699

computer methods, 707, 718–721, 728,

739, 742–744, 749–751, 801–808

de ned, 699

eigenvalue problems, 707, 789–808

engineering applications, 701–702, 707,

811–830

Euler’s method, 705–707, 710–729, 841,

842, 843

explicit solution technique, 757–759

falling parachutist problem, 701, 709–710

 nite-difference methods, 707, 786–789

 rst-order equations, 699

fourth-order Adams, 771–774, 777–779,

841, 842, 843

goals/objectives, 707–708

Heun’s method, 707, 722–726, 728, 729,

732, 759–767, 841, 843

higher-order equations, 699–700, 721, 775–779

implicit solution technique, 707, 755, 757–759

initial-value problems, 705, 781

mathematical background, 703–705

midpoint (improved polygon) method,

707, 726–728, 729, 733–734

Milne’s method, 775–779, 841

multistep methods, 707, 755, 759–779, 841

noncomputer methods for solving, 700–701

one-step methods, 705, 709–751, 841

power methods, 707, 797–800

Ralston’s method, 732–734, 735, 843

Runge-Kutta (RK), 705–707, 729–751,

841, 842, 843

scope/preview, 705–707

second-order equations, 699, 730–734

shooting method, 707, 782, 783–786

stiff systems, 707, 755–759, 804–806, 842

systems of equations, 707, 739–744

Orthogonal, 378

Orthogonal polynomials, 584–585

Overconstrained optimization, 351

Overdamped case, 178

Overdetermined equations, 343

Over! ow error, 69–70

Overrelaxation, 309

P Parabolic interpolation optimization,

352, 363–365, 438

Parabolic partial differential equations (PDEs),

873–888

alternating-direction implicit (ADI) method,

850, 878–882, 885–888, 931, 932

Crank-Nicolson method, 850, 882–885,

931, 932

INDEX 967

explicit methods, 874–878, 879, 885, 931

 nite-difference methods, 846, 847–848,

850, 873–888, 931, 932

heat-conduction equation, 846, 847–848,

873–888

implicit methods, 850, 878–882, 885–888,

931, 932

Laplace equation, 846, 850, 852–866, 922–924

one-dimensional, 884–885, 931

two-dimensional, 885–888, 931

Parameter estimation, 816

Parameters, 11–12, 118, 816

distributed-parameter system, 916

estimation, 816

lumped-parameter systems, 915–916

sinusoidal function, 527–530

Parametric Technology Corporation (PTC), 47

Partial derivatives, 588, 622–623

Partial differential equations (PDEs), 309, 699,

845–932

advanced methods and additional

references, 932

case studies, 915–927

characteristics, 845–846

computer solutions, 850, 869–870, 908–912

de ned, 845

elliptic equations, 846–847, 850, 852–870,

931, 932

engineering applications, 846–848, 850,

915–927

 nite-difference methods, 846–848, 850,

852–870, 873–888, 931, 932

 nite-element methods, 850, 890–908, 931

goals/objectives, 850–851

higher-order temporal approximations,

877–878

hyperbolic equations, 846, 848

important relationships and formulas, 931–932

order of, 845

parabolic equations, 846, 847–848, 850,

873–888, 931, 932

precomputer methods of solving, 848

scope/preview, 849–850

Partial pivoting, 241, 264–269

Pattern directions, 374–375

Pattern searches, 352

Penalty functions, 401

Period, sinusoidal function, 527–528

Phase-plane representation, 819–822

Phase shift, 529

Pivoting, 264–269, 341

complete, 264

division by zero, 258

effect of scaling, 266–269

partial, 241, 264–269

pivot coef cient/element, 253–254

Place value, 65

Point-slope method. See Euler’s method

Poisson equation, 854, 895–904, 919–924

Polynomial regression, 452, 472–476, 583, 584

algorithm, 475–476

 t of second-order polynomial, 473–475

Polynomials

characteristic equation, 177–178

computing with, 179–182

critically damped case, 178–179

de ned, 119

de! ation, 180–182

discriminant, 178

eigenvalue problems, 177–178, 795–797

engineering applications, 176–179

evaluation and differentiation, 179–180

factored form, 180

general solution, 177

interpolation, 490–509

Lagrange, 163

Lagrange interpolating, 454, 490, 502–507,

509, 582, 584

Newton-Raphson method, 180, 183, 188

Newton’s divided-difference, 454, 490,

491–502, 504–505, 509, 582, 584

order, 119

ordinary differential equations (ODEs),

176–178, 707

orthogonal, 584–585

overdamped case, 178

polynomial approximation, 83–85

regression, 452, 472–476

roots. See Roots of polynomials

synthetic division, 180–181

underdamped case, 179

Populations, estimating properties of, 446–447

Positional notation, 65

Positive de nite matrix, 304

Postprocessing,  nite-element methods, 894,

904, 908, 927

Posttest loops, 32–33

Potential energy, 429–430

Powell’s method of optimization, 374–375,

386, 438

Power equations, linear regression of, 470–472

Power methods

de ned, 797

ordinary differential equations (ODEs), 707,

797–800

Power spectrum, 551–552

Precision, 58–59

Predator-prey models, 818–822

Predictor-corrector approach, 723–724, 762–767

Predictor equation, 722–723

Predictor modi er, 765–767

Prescriptive models, 346

Pretest loops, 32–33

Product, matrix operations, 236

Programming and software. See Computer

programming and software

Propagated truncation error, 713

Propagation problems, 847. See also Hyperbolic

partial differential equations (PDEs); Parabolic

partial differential equations (PDEs)

Proportionality, 291

Pseudocode algorithms

adaptive quadrature, 641–642

Bairstow’s method, 190–191

bisection, 133, 134

Brent’s method, 164–166, 366–368

Cholesky decomposition, 304

cubic splines, 520–521

curve  tting, 454, 568

de ned, 30

discrete Fourier transform (DFT), 542–544

Euler’s method, 718–721

Excel VBA versus, 41

fast Fourier transform (FFT), 549–550

 xed-point iteration, 150–151

forward elimination, 254

function that involves differential equation, 38

Gauss-Seidel (Liebmann) method, 309–310

for generic iterative calculation, 62–63

golden-section-search optimization, 361,

362, 427–428

linear regression, 464–465, 478–479

logical representation, 30–37

LU decomposition, 282, 284–285, 286–287

MATLAB versus, 45

matrix inverse, 289–290

modi ed false-position method, 140

Müller’s method, 186–187

multiple linear regression, 478–479

Newton’s divided-difference interpolating

polynomials, 499–502

optimization, 427–428

partial pivoting, 266, 268

polynomial regression, 475–476

Romberg integration, 639–640

roots of quadratic equation, 34–37, 77

Runge-Kutta (RK) method, 749–750

Simpson’s rules, 622, 623, 626–627

Thomas algorithm, 301–302

968 INDEX

Q QR factorization, 482

QR method (Francis), 801

Quadratic equation, algorithm for roots, 34–37

Quadratic interpolation, 493–495

Quadratic programming, 350

Quadratic splines, 514–517

Quadrature methods, 592

Quantizing errors, 70–71, 72, 75

Quasi-Newton methods of optimization,

352, 388, 401, 439

Quotient difference (QD) algorithm, 228

R Ralston’s method, 732–734, 735, 843

Random search method of optimization,

352, 371–373

Rate equation, 699

Reaction kinetics, 816

Regression. See Linear regression; Polynomial

regression

Relative error, 100

Relaxation, 309, 911–912

Remainder, 61, 62, 114

Taylor series, 87–89, 114

Repetition, in logical representation, 31–34

Residual error, 457, 461–464

Response, 35

Richardson’s extrapolation, 601, 633, 635–638,

641, 658–660

Ridder method, root of polynomials, 199

Romberg integration, 601, 633, 634–640, 641,

679, 694, 696

Root polishing, 182

Roots of equations, 117–229

advanced methods and additional references,

227–229

Bairstow’s method, 187–191, 226

bisection method, 120, 127–135, 226, 228,

356–357

bracketing methods. See Bracketing methods

Brent’s method, 120–121, 162–166, 226, 227

case studies, 122, 204–215

computer methods, 126–127, 192–201

engineering applications, 118–119, 122,

176–179, 204–215

false-position method, 120, 135–141, 226, 228

 xed-point iteration, 146–151, 226

goals/objectives, 122

graphical methods, 117, 120–121, 123–127,

145, 146–151, 157–166, 226

important relationships and formulas,

227, 228

incremental searches/determined

incremental guesses, 127, 141

mathematical background, 119–120,

179–182

Müller’s method, 183–187, 199, 226

multiple roots, 125, 166–169

Newton-Raphson method, 120–121,

151–157, 166–167, 226, 227, 228, 365

noncomputer methods, 117

nonlinear equations, 121, 169–173

open methods, 145–173

optimization and, 345

other methods, 192

polynomials, 120, 121–122, 176–192

scope/preview, 120–122

secant method, 120, 157–162, 166–167,

226, 228

as zeros of equation, 117

Roots of polynomials, 120, 121–122,

176–192

Bairstow’s method, 187–191

Brent’s method, 199

computer methods, 192–201

conventional methods, 182–183

Jenkins-Traub method, 192, 229

Laguerre’s method, 192, 199, 229

Müller’s method, 183–187, 199, 226

polynomial de! ation, 180–182

Rounding, 71

Round-off errors, 65–79

adding a large and a small number, 75–76

arithmetic manipulation of computer

numbers, 73–79

common arithmetic operations, 73–74

computer representation of numbers, 65–73

de ned, 56, 59

Euler’s method, 713

extended precision, 72–73

! oating-point representation, 67–72

Gauss elimination, 259

integer representation, 65–67

iterative re nement, 296–297

large computations, 74–75

linear algebraic equations, 259

number systems, 65

numerical differentiation, 103–105

signi cant digits and, 57

smearing, 77–79

subtractive cancellation, 76–77

total numerical error, 101–106

Row-sum norms, 294

Row vectors, 234

Runge-Kutta Fehlberg method, 747–748, 749

Runge-Kutta (RK) methods, 705–707, 729–751,

841, 842

adaptive, 707, 744–751

adaptive step-size control, 745,

748–749, 768

Cash-Karp RK method, 747, 749–750

comparison, 737–739

computer algorithms, 739

embedded, 747

fourth-order, 735–737, 741–742, 743, 746,

750–751, 843

higher-order, 737–739

Runge-Kutta Fehlberg method,

747–748, 749

second-order, 730–734

systems of equations, 740–742

third-order, 734–735

S Saddle, 379

Samples, estimating properties of, 446–447

Sande-Tukey algorithm, 545, 546–550

Scaling

effect of scale on determinant in

ill-conditioned systems, 261–263

effect on pivoting and round-off, 266–269

Secant method, 120, 157–162

algorithm, 161

false-position method versus, 158–160

graphical method, 157, 159, 160, 162, 228

modi ed, 161–162, 226

multiple roots, 166–167

root of polynomials, 199

Second Adams-Moulton formula, 773–774

Second derivative, 588, 656–657

Second  nite divided difference, 495

Second forward  nite divided difference, 96–97

Second-order approximation, 82–83, 86

Second-order closed Adams formula, 773–774

Second-order equations, 699, 730–734

Selection, in logical representation, 30–31

Sensitivity analysis, 21, 42–43

Sentinel variables, 309–310

Sequence, in logical representation, 30

Shadow price, 424

Shooting method, 707, 782, 783–786

Signed magnitude method, 65–66

Signi cance level, 448

Signi cand, 67–68

INDEX 969

Signi cant  gures/digits, 56–57

Simple statistics, 443–446

Simplex method, 346, 352, 396–401

algebraic solution, 396–397

implementation, 398–401

slack variables, 396

Simpson’s 1/3 rule, 600, 615–620, 676, 694, 696

computer algorithms, 623

derivation and error estimate, 616

multiple-application, 618–620, 641

single-application, 617–618

with unequal segments, 625–627

Simpson’s 3/8 rule, 600, 620–622, 694, 696

computer algorithms, 623

with unequal segments, 625–627

Simultaneous overrelaxation, 309

Single-value decomposition, 585

Single-variable optimization, 356

Singular systems, 247, 263–264

Sinusoidal functions, 527–533

least-squares  t of sinusoid, 530–533

parameters, 527–530

Slack variables, 396

Smearing, 77–79

Software. See Computer programming and

software

Spline functions, 511, 585

Spline interpolation, 454, 511–521

cubic splines, 511, 517–521, 559–560, 582,

584, 695

engineering applications, 567–568

linear splines, 511–514

quadratic splines, 514–517

splines, de ned, 511

Spread around the mean, 462

Spread around the regression line, 462

Spreadsheets. See Excel

Square matrices, 235

Stability

de ned, 877

error propagation, 100–101

of numerical methods of problem solving,

111–112

Standard deviation, 444

Standard error of the estimate, 462

Standard normal estimate, 448–449

Standard normal random variable, 449

Statistical inference, 447, 449

Statistics, 443–452

estimation of con dence interval, 446–452,

481–482

least-squares theory, 480–483

maximum likelihood principle, 461–462

normal distribution, 446

simple statistics, 443–446

Steady-state computation, 19, 319–322. See also

Elliptic partial differential equations (PDEs)

Steepest ascent/descent optimization,

352, 381–386

optimal steepest ascent, 384–386, 585

using gradient to evaluate, 377–378

Stiffness matrix,  nite-element methods, 894, 926

Stiff ordinary differential equations (ODEs),

707, 755–759, 804–806, 842

Euler’s method, 756, 757

stiff system, de ned, 755

Stimulus-response computations, 290–291

Stopping criterion, 62, 63, 114

Strip method, 592–593, 604

Structured programming, 28–37

de ned, 29

! owcharts, 29–30

logical representation, 30–37

pseudocode, 30–37

Subroutines, modular programming, 37

Subtraction, 74

matrix operations, 236

subtractive cancellation, 76–77

Successive overrelaxation, 309

Summation, 588

Superposition, 291

Swamee-Jain equation, 212

Symmetric matrices, 300

Synthetic division, 180–181

Systems of equations

nonlinear equations, 120–121, 231–232,

271–273

ordinary differential equations (ODEs),

707, 739–744

T Tableau, 398–401

Taylor series, 81–97, 114. See also

Finite-difference methods

approximation of polynomial, 83–85

backward difference approximation, 93–94

centered  nite divided-difference

approximation, 94, 95

de ned, 81

derivative mean-value theorem, 88

error propagation, 97–101

to estimate error for Euler’s method,

714–715

to estimate truncation errors, 89–93, 721

expansion of Newton-Raphson method, 272

expansion of Newton’s divided-difference

interpolating polynomials, 497–498

expansions, 85–89, 114, 272, 497–498

 nite difference approximations, 96–97

 nite-divided-difference approximations,

93, 95–96, 655–658

 rst forward difference, 93

 rst-order approximation, 81–82, 84, 86,

92–93

 rst theorem of mean for integrals, 82

in nite number of derivatives, 86–87

linear trend, 82–83

nonlinearity, 89–93, 483

numerical differentiation, 93–97

remainder, 87–89, 114

second-order approximation, 82–83, 86

second theorem of mean for integrals, 82

step size, 89–93

Taylor’s theorem/formula, 81, 82

zero-order approximation, 81, 84, 86

t distribution, 450–451

Terminal velocity, 15

Thermal conductivity, 853

Thermal diffusivity, 853

Thermocline, 567

Third derivative, 656–657

Third-order methods, 734–735

Thomas algorithm, 301–302

Time domains, 536–540

Time plane, 536–537

Time-variable (transient) computation, 18

Topography, 351

Total numerical error, 101–106

Total sum of the squares, 462–463

Total value, 588

Trace, matrix operations, 239

Transcendental function, 120

Transient computation, 18

Transpose, matrix operations, 239

Trapezoidal rule, 600, 605–615, 623, 624–627,

676, 694, 696, 726

computer algorithms, 612–615

as corrector, 759–760

error/error correction, 607–609, 636–637

multiple-application, 609–612, 696

single-application, 608–609

with unequal segments, 624–625

Trend analysis, 442–443

Tridiagonal systems, 241–243, 301–302

Triple roots, 166, 167

True derivative approximation, 94

970 INDEX

True error, 59, 98, 104, 114

True mean, 449

True percent relative error, 59, 61, 64, 114

Truncation errors. See also Discretization,

 nite-element methods

de ned, 56, 59, 81

Euler’s method, 712, 721

numerical differentiation, 103–105

per-step, 765

Taylor series to estimate, 89–93, 721.

See also Taylor series

total numerical error, 101–106

types, 712–713

Twiddle factors, 547

2’s complement, 67

Two-dimensional interpolation, 522–523

Two-sided interval, 447–448

U Uncertainty, 58–59, 107, 662

Unconditionally stable, 757

Unconstrained optimization, 351, 352

multidimensional. See Multidimensional

unconstrained optimization

one-dimensional. See One-dimensional

unconstrained optimization

Underdamped case, 179

Underdetermined equations, 342–343, 396

Underrelaxation, 309

Underspeci ed equations, 396

Uniform matrix norms, 294

Uniform vector norms, 294

Unimodal optimization, 356–357

Univariate search method, 352, 373

V Van der Waals equation, 205

Variable metric methods of optimization,

352, 388

Variables

basic, 397

dependent, 11–12, 118, 699

design, 35, 350

entering, 398–399

independent, 11–12, 118, 699

leaving, 398–399

lumped-variable systems, 232, 233, 311

single-variable optimization, 356

slack, 396

standard normal random, 449

Variable step size, 768

Variance, 444, 449

Variation, coef cient of, 445

Vector norms, 292–294

Very large numbers, ! oating-point

representation, 68

Visual Basic Editor (VBE), 40–43

Voltage balance, 20

Volume-integral approach, 866–869

Volume integrals, 596

W Wave equation, 846, 848

Well-conditioned systems, 259

WHILE structure, 33

Z Zero, division by, 258

Zero-order approximation, 81, 84, 86

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Writers Hero only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Writers Hero are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Writers Hero is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Writers hero, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.