17.11.2012 Views

Numerical recipes

Numerical recipes

Numerical recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 16. Integration of Ordinary<br />

Differential Equations<br />

16.0 Introduction<br />

Problems involving ordinary differential equations (ODEs) can always be<br />

reduced to the study of sets of first-order differential equations. For example the<br />

second-order equation<br />

d2y dy<br />

+ q(x) = r(x) (16.0.1)<br />

dx2 dx<br />

can be rewritten as two first-order equations<br />

dy<br />

= z(x)<br />

dx<br />

dz<br />

= r(x) − q(x)z(x)<br />

dx<br />

(16.0.2)<br />

where z is a new variable. This exemplifies the procedure for an arbitrary ODE. The<br />

usual choice for the new variables is to let them be just derivatives of each other (and<br />

of the original variable). Occasionally, it is useful to incorporate into their definition<br />

some other factors in the equation, or some powers of the independent variable,<br />

for the purpose of mitigating singular behavior that could result in overflows or<br />

increased roundoff error. Let common sense be your guide: If you find that the<br />

original variables are smooth in a solution, while your auxiliary variables are doing<br />

crazy things, then figure out why and choose different auxiliary variables.<br />

The generic problem in ordinary differential equations is thus reduced to the<br />

study of a set of N coupled first-order differential equations for the functions<br />

yi, i =1, 2,...,N, having the general form<br />

dyi(x)<br />

dx = fi(x, y1,...,yN), i =1,...,N (16.0.3)<br />

where the functions fi on the right-hand side are known.<br />

A problem involving ODEs is not completely specified by its equations. Even<br />

more crucial in determining how to attack the problem numerically is the nature of<br />

the problem’s boundary conditions. Boundary conditions are algebraic conditions<br />

on the values of the functions yi in (16.0.3). In general they can be satisfied at<br />

707<br />

Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)<br />

Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by <strong>Numerical</strong> Recipes Software.<br />

Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable<br />

files (including this one) to any server computer, is strictly prohibited. To order <strong>Numerical</strong> Recipes books or CDROMs, visit website<br />

http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!