Ordinary and Partial Differential Equation Routines in C, C++, Fortran, Java, Maple, and MATLAB.pdf

(1581 KB) Pobierz
Ordinary and Partial Differential
Equation Routines in C, C ++ ,
Fortran, Java ® , Maple ® , and M ATLAB ®
Copyright © 2004 by Chapman & Hall/CRC
(C) 2004 by Chapman & Hall/CRC
Copyright 2004 by Chapman & Hall/CRC
840447084.068.png 840447084.079.png 840447084.090.png 840447084.101.png 840447084.001.png 840447084.011.png 840447084.020.png 840447084.021.png 840447084.022.png 840447084.023.png 840447084.024.png 840447084.025.png 840447084.026.png
Ordinary and Partial Differential
Equation Routines in C, C ++ ,
Fortran, Java ® , Maple ® , and M ATLAB ®
H.J. Lee and W.E. Schiesser
CHAPMAN & HALL/CRC
A CRC Press Company
Boca Raton London New York Washington, D.C.
Copyright © 2004 by Chapman & Hall/CRC
(C) 2004 by Chapman & Hall/CRC
Copyright 2004 by Chapman & Hall/CRC
840447084.027.png 840447084.028.png 840447084.029.png 840447084.030.png 840447084.031.png 840447084.032.png 840447084.033.png 840447084.034.png 840447084.035.png 840447084.036.png 840447084.037.png 840447084.038.png 840447084.039.png
Java is a registered trademark of Sun Microsystems, Inc.
Maple is a registered trademark of Waterloo Maple, Inc.
MATLAB is a registered trademark of The MathWorks, Inc. For product information, please contact:
The MathWorks, Inc.
3 Apple Hill Drive
Natick, MA 01760-2098
Tel.: 508-647-7000
Fax: 508-647-7001
e-mail: info@mathworks.com
Web: www.mathworks.com http://www.mathworks.com/
Library of Congress Cataloging-in-Publication Data
Lee, H. J. (Hyun Jin)
Ordinary and partial differential equation routines in C, C++, Fortran, Java, Maple, and
MATLAB / H.J. Lee and W.E. Schiesser.
p. cm.
Includes bibliographical references and index.
ISBN 1-58488-423-1 (alk. paper)
1. Differential equations—Data processing. 2. Differential equations, Partial—Data
processing. I. Schiesser, W. E. II. Title.
QA371.5.D37L44 2003
515
¢.
352
¢
0285—dc22
2003055809
This book contains information obtained from authentic and highly regarded sources. Reprinted material
is quoted with permission, and sources are indicated. A wide variety of references are listed. Reasonable
efforts have been made to publish reliable data and information, but the author and the publisher cannot
assume responsibility for the validity of all materials or for the consequences of their use.
Neither this book nor any part may be reproduced or transmitted in any form or by any means, electronic
or mechanical, including photocopying, microfilming, and recording, or by any information storage or
retrieval system, without prior permission in writing from the publisher.
The consent of CRC Press LLC does not extend to copying for general distribution, for promotion, for
creating new works, or for resale. Specific permission must be obtained in writing from CRC Press LLC
for such copying.
Direct all inquiries to CRC Press LLC, 2000 N.W. Corporate Blvd., Boca Raton, Florida 33431.
Trademark Notice:
Product or corporate names may be trademarks or registered trademarks, and are
used only for identification and explanation, without intent to infringe.
Visit the CRC Press Web site at www.crcpress.com
© 2004 by Chapman & Hall/CRC
No claim to original U.S. Government works
International Standard Book Number 1-58488-423-1
Library of Congress Card Number 2003055809
Printed in the United States of America 1 2 3 4 5 6 7 8 9 0
Printed on acid-free paper
Copyright © 2004 by Chapman & Hall/CRC
(C) 2004 by Chapman & Hall/CRC
Copyright 2004 by Chapman & Hall/CRC
840447084.040.png 840447084.041.png 840447084.042.png 840447084.043.png 840447084.044.png 840447084.045.png 840447084.046.png 840447084.047.png 840447084.048.png 840447084.049.png 840447084.050.png 840447084.051.png 840447084.052.png 840447084.053.png 840447084.054.png 840447084.055.png 840447084.056.png 840447084.057.png 840447084.058.png 840447084.059.png 840447084.060.png 840447084.061.png 840447084.062.png 840447084.063.png 840447084.064.png 840447084.065.png 840447084.066.png 840447084.067.png 840447084.069.png 840447084.070.png 840447084.071.png 840447084.072.png 840447084.073.png 840447084.074.png 840447084.075.png 840447084.076.png 840447084.077.png 840447084.078.png 840447084.080.png 840447084.081.png 840447084.082.png 840447084.083.png 840447084.084.png 840447084.085.png 840447084.086.png 840447084.087.png 840447084.088.png 840447084.089.png 840447084.091.png 840447084.092.png 840447084.093.png 840447084.094.png 840447084.095.png 840447084.096.png 840447084.097.png 840447084.098.png 840447084.099.png 840447084.100.png 840447084.102.png 840447084.103.png 840447084.104.png 840447084.105.png 840447084.106.png 840447084.107.png 840447084.108.png 840447084.109.png
 
Preface
Initial value ordinary differential equations (ODEs) and partial differential
equations (PDEs) are among the most widely used forms of mathematics in
science and engineering. However, insights from ODE/PDE-based models
are realized only when solutions to the equations are produced with accept-
able accuracy and with reasonable effort.
Most ODE/PDE models are complicated enough (e.g., sets of simultane-
ous nonlinear equations) to preclude analytical methods of solution; instead,
numerical methods must be used, which is the central topic of this book.
The calculation of a numerical solution usually requires that well-
established numerical integration algorithms are implemented in quality li-
brary routines. The library routines in turn can be coded (programmed) in a
variety of programming languages. Typically, for a scientist or engineer with
an ODE/PDE- based mathematical model, finding routines written in a famil-
iar language can be a demanding requirement, and perhaps even impossible
(if such routines do not exist).
The purpose of this book, therefore, is to provide a set of ODE/PDE in-
tegration routines written in six widely accepted and used languages. Our
intention is to facilitate ODE/PDE-based analysis by using the library rou-
tines to compute reliable numerical solutions to the ODE/PDE system of
interest.
However, the integration of ODE/PDEs is a large subject, and to keep this
discussion to reasonable length, we have limited the selection of algorithms
and the associated routines. Specifically, we concentrate on explicit (nonstiff)
Runge Kutta (RK) embedded pairs. Within this setting, we have provided
integrators that are both fixed step and variable step; the latter accept a user-
specified error tolerance and attempt to compute a solution to this required
accuracy. The discussion of ODE integration includes truncation error moni-
toring and control, h and p refinement, stability and stiffness, and explicit and
implicit algorithms. Extensions to stiff systems are also discussed and illus-
trated through an ODE application; however, a detailed presentation of stiff
(implicit) algorithms and associated software in six languages was judged
impractical for a book of reasonable length.
Further, we have illustrated the application of the ODE integration routines
to PDEs through the method of lines (MOL). Briefly, the spatial (boundary
value) derivatives of the PDEs are approximated algebraically, typically by
finite differences (FDs); the resulting system of initial-value ODEs is then
solved numerically by one of the ODE routines.
Copyright © 2004 by Chapman & Hall/CRC
(C) 2004 by Chapman & Hall/CRC
Copyright 2004 by Chapman & Hall/CRC
840447084.110.png
 
840447084.002.png 840447084.003.png 840447084.004.png 840447084.005.png 840447084.006.png 840447084.007.png 840447084.008.png 840447084.009.png
Thus, we have attempted to provide the reader with a set of computational
tools for the convenient solution of ODE/PDE models when programming
in any of the six languages. The discussion is introductory with limited math-
ematical details. Rather, we rely on numerical results to illustrate some basic
mathematical properties, and we avoid detailed mathematical analysis (e.g.,
theorems and proofs), which may not really provide much assistance in the
actual calculation of numerical solutions to ODE/PDE problems.
Instead, we have attempted to provide useful computational tools in the
form of software. The use of the software is illustrated through a small number
of ODE/PDE applications; in each case, the complete code is first presented,
and then its components are discussed in detail, with particular reference
to the concepts of integration, e.g., stability, error monitoring, and control.
Since the algorithms and the associated software have limitations (as do all
algorithms and software), we have tried to point out these limitations, and
make suggestions for additional methods that could be effective.
Also, we have intentionally avoided using features specific to a particular
language, e.g., sparse utilities, object-oriented programming. Rather, we have
emphasized the commonality of the programming in the six languages, and
thereby illustrate how scientific computation can be done in any of the lan-
guages. Of course, language-specific features can be added to the source code
that is provided.
We hope this format will allow the reader to understand the basic elements
of ODE/PDE integration, and then proceed expeditiously to a numerical solu-
tion of the ODE/PDE system of interest. The applications discussed in detail,
two in ODEs and two in PDEs, can be used as a starting point (i.e., as tem-
plates) for the development of a spectrum of new applications.
We welcome comments and questions about how we might be of assis-
tance (directed to wes1@lehigh.edu). Information for acquiring (gratis) all the
source code in this book is available from http://www.lehigh.edu/˜ wes1/
wes1.html. Additional information about the book and software is available
from the CRC Press Web site, http://www.crcpress.com.
Dr. Fred Chapman provided expert assistance with the Maple program-
ming. We note with sadness the passing of Jaeson Lee, father of H. J. Lee,
during the completion of H. J. Lee’s graduate studies at Lehigh University.
H. J. Lee
W. E. Schiesser
Bethlehem, PA
Copyright © 2004 by Chapman & Hall/CRC
(C) 2004 by Chapman & Hall/CRC
Copyright 2004 by Chapman & Hall/CRC
840447084.010.png 840447084.012.png 840447084.013.png 840447084.014.png 840447084.015.png 840447084.016.png 840447084.017.png 840447084.018.png 840447084.019.png
Zgłoś jeśli naruszono regulamin