Numerical Solution of Ordinary Differential Equations
Total Page:16
File Type:pdf, Size:1020Kb
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS Kendall Atkinson, Weimin Han, David Stewart University of Iowa Iowa City, Iowa A JOHN WILEY & SONS, INC., PUBLICATION Copyright c 2009 by John Wiley & Sons, Inc. All rights reserved. Published by John Wiley & Sons, Inc., Hoboken, New Jersey. Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008. Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created ore extended by sales representatives or written sales materials. The advice and strategies contained herin may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. For general information on our other products and services please contact our Customer Care Department with the U.S. at 877-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print, however, may not be available in electronic format. Library of Congress Cataloging-in-Publication Data: Numerical Solution of Ordinary Differential Equations / Kendall E. Atkinson . [et al.]. p. cm.—(Wiley series in ???????) “Wiley-Interscience." Includes bibliographical references and index. ISBN ????????????? (pbk.) 1. Numerical analysis. 2. Ordinary differential equations. I. Atkinson, Kendall E. II. Series. MATLAB R is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB R software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB R software. QA31.????.???? 2008 510.??????-??? Printed in the United States of America. 10987654321 To Alice, Huidi, and Sue Preface This book is an expandedversion of supplementarynotes that we usedfora courseon ordinary differential equations for upper-division undergraduate students and begin- ning graduate students in mathematics, engineering, and sciences. The book intro- duces the numerical analysis of differential equations, describing the mathematical background for understanding numerical methods and giving information on what to expect when using them. As a reason for studying numerical methods as a part of a more general course on differential equations, many of the basic ideas of the numerical analysis of differential equations are tied closely to theoretical behavior associated with the problem being solved. For example, the criteria for the stability of a numericalmethod is closely connectedto the stability of the differential equation problem being solved. This book can be used for a one-semester course on the numerical solution of dif- ferentialequations, orit can be used as a supplementarytextforacourseonthetheory and application of differential equations. In the latter case, we present more about numericalmethodsthanwouldordinarilybecoveredin a class on ordinary differential equations. This allows the instructor some latitude in choosing what to include, and it allows the students to read further into topics that may interest them. For example, the book discusses methods for solving differential algebraic equations (Chapter 10) and Volterra integral equations (Chapter 12), topics not commonly included in an introductory text on the numerical solution of differential equations. vii viii PREFACE We also include MATLAB R programs to illustrate many of the ideas that are introduced in the text. Much is to be learned by experimenting with the numerical solution of differential equations. The programs in the book can be downloadedfrom the following website. http://www.math.uiowa.edu/NumericalAnalysisODE/ This site also contains graphical user interfaces for use in experimenting with Euler’s method and the backward Euler method. These are to be used from within the framework of MATLAB. Numerical methods vary in their behavior, and the many different types of differ- ential equation problems affect the performance of numerical methods in a variety of ways. An excellent book for “real world” examples of solving differential equations is that of Shampine, Gladwell, and Thompson [74]. The authors would like to thank Olaf Hansen, California State University at San Marcos, for his comments on reading an early version of the book. We also express our appreciation to John Wiley Publishers. CONTENTS Introduction 1 1 Theory of differential equations: An introduction 3 1.1 General solvability theory 7 1.2 Stability of the initial value problem 8 1.3 Direction fields 11 Problems 13 2 Euler’s method 15 2.1 Definition of Euler’s method 16 2.2 ErroranalysisofEuler’smethod 21 2.3 Asymptotic error analysis 26 2.3.1 Richardsonextrapolation 28 2.4 Numerical stability 29 2.4.1 Roundingerroraccumulation 30 Problems 32 ix x CONTENTS 3 Systems of differential equations 37 3.1 Higher-orderdifferentialequations 39 3.2 Numericalmethodsforsystems 42 Problems 46 4 The backward Euler method and the trapezoidal method 49 4.1 The backward Euler method 51 4.2 The trapezoidal method 56 Problems 62 5 Taylor and Runge–Kutta methods 67 5.1 Taylor methods 68 5.2 Runge–Kutta methods 70 5.2.1 A general framework for explicit Runge–Kutta methods 73 5.3 Convergence, stability, and asymptotic error 75 5.3.1 Errorpredictionandcontrol 78 5.4 Runge–Kutta–Fehlbergmethods 80 5.5 MATLAB codes 82 5.6 ImplicitRunge–Kuttamethods 86 5.6.1 Two-pointcollocationmethods 87 Problems 89 6 Multistep methods 95 6.1 Adams–Bashforth methods 96 6.2 Adams–Moulton methods 101 6.3 Computercodes 104 6.3.1 MATLAB ODE codes 105 Problems 106 7 General error analysis for multistep methods 111 7.1 Truncation error 112 7.2 Convergence 115 7.3 A general error analysis 117 7.3.1 Stability theory 118 7.3.2 Convergence theory 122 7.3.3 Relative stability and weak stability 122 Problems 123 CONTENTS xi 8 Stiff differential equations 127 8.1 Themethodoflinesforaparabolicequation 131 8.1.1 MATLABprogramsforthemethodoflines 135 8.2 Backwarddifferentiationformulas 140 8.3 Stability regions for multistep methods 141 8.4 Additionalsourcesofdifficulty 143 8.4.1 A-stability and L-stability 143 8.4.2 Time-varyingproblemsandstability 145 8.5 Solvingthefinite-differencemethod 145 8.6 Computercodes 146 Problems 147 9 Implicit RK methods for stiff differential equations 149 9.1 FamiliesofimplicitRunge–Kuttamethods 149 9.2 StabilityofRunge–Kuttamethods 154 9.3 Order reduction 156 9.4 Runge–Kuttamethodsforstiffequationsinpractice 160 Problems 161 10 Differential algebraic equations 163 10.1 Initial conditions and drift 165 10.2DAEsasstiffdifferentialequations 168 10.3 Numericalissues:higherindexproblems 169 10.4 BackwarddifferentiationmethodsforDAEs 173 10.4.1 Index 1 problems 173 10.4.2 Index 2 problems 174 10.5Runge–KuttamethodsforDAEs 175 10.5.1 Index 1 problems 176 10.5.2 Index 2 problems 179 10.6 Indexthreeproblemsfrommechanics 181 10.6.1 Runge–Kuttamethodsformechanicalindex3systems 183 10.7 Higher index DAEs 184 Problems 185 11 Two-point boundary value problems 187 11.1 A finite-difference method 188 11.1.1 Convergence 190 xii CONTENTS 11.1.2 A numerical example 190 11.1.3Boundaryconditionsinvolvingthederivative 194 11.2 Nonlineartwo-pointboundaryvalueproblems 195 11.2.1Finitedifferencemethods 197 11.2.2 Shooting methods 201 11.2.3 Collocation methods 204 11.2.4Othermethodsandproblems 206 Problems 206 12 Volterra integral equations 211 12.1 Solvability theory 212 12.1.1 Special equations 214 12.2 Numerical methods 215 12.2.1Thetrapezoidalmethod 216 12.2.2Errorforthetrapezoidalmethod 217 12.2.3Generalschemafornumericalmethods 219 12.3 Numerical methods: Theory 223 12.3.1 Numerical stability 225 12.3.2Practicalnumericalstability 227 Problems 231 Appendix A. Taylor’s Theorem 235 Appendix B. Polynomial interpolation 241 References 245 Index 250 Introduction Differential equations are among the most important mathematical tools used in pro- ducing models in the physical sciences, biological sciences, and engineering. In this text, we consider numerical methods for solving ordinary differential equations, that is, those differential equations that have only one independent variable. The differential equations we consider in most of the book are of the form Y ′(t)= f(t, Y (t)), where Y (t) is an unknown function that is being sought. The given