You are on page 1of 972
low PRICE EDITION Mma eace iby Introduction to Numerical Analysis Pir lam =de- ol ee A Friendly Introduction to Numerical Analysis Brian Bradie Christopher Newport University Department of Mathematics An inprint of Pearson Education Pearson Prentice Hall™ is a trademark of Pearson Education, Inc “MATLAB" is a registered trademark and the L-shape of membrane logo is a trademark of The Mathwork, Inc. used by permission. Copyright © 2006 by Pearson Education, Inc. This edition is published by arrangement with Pearson Education, Ine. and Dorling Kindersley Publishing, Inc. This book is sold subject to the condition that it shall not, by way of trade or otherwise, be lent, resold, hired out, or otherwise circulated without the publisher's prior written consent in any form of bit ‘cover other than that in which ic is published and without a similar condition including this condition being imposed on the subsequent purchaser and without limiting the rights under copyright reserved above, no prt ofthis publication may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording or otherwise), without the prior ‘written permission of both the copyright owner and the above-mentioned publisher of this book ISBN 81-317.0942.6 First Impression, 2007 This edition is manufactured in India and is authorized for sale only in India, Bangladesh, Bhutan, Pakistan, Nepal, Sri Lanka and the Maldives. Circulation of this edition outside of these territories is UNAUTHORIZED. Published by Dorling Kindersley (India) Pvt Ltd, licensees of Pearson Education in South Asia Head Office: 482, FLE., Pataparganj, Delhi 110 092, India, Registered Office: 14 Local Shopping Centre, Panchsheel Park, New Delhi 110 017, India Printed in ia by Anand Sons. Contents Preface Jetting Started 1.1 Algorithms 1.2. Convergence 1.3 Mathematics on the Computer Floating Point Number S 1.4 Mathematics on the Computer: Floating Point Arithmetic 2 Rootfinding 2.1 The Bisection Method . 2.2 The Method of False Position 2.3. Fixed Point Iteration Schemes 2.4 Newton’s Method . 2.5 Secant Method . 2.6 Accelerating Convergen 2.7 Roots of Polynomials . 3 Systems of Equations 3.0. Linear Algebra Review 3.1 Gaussian Elimination 3.2. Pivoting Strategies 3.3 Vector and Matrix Norms Error Estimates and Condition Number . . LU Decomposition Direct Factorization Special Matrices Iterative Techniques for Linear Systems: Basic Concepts and Methods 3.9 Conjugate Gradient Method 3.10 Nonlinear Systems of Equations . 4 Eigenvalues and Eigenvectors 4.1 The Power Method 4.2. The Inverse Power Method 4.3 Deflation nae « ree 4.4 Reduction to Symmetric Tridiagonal Form . 4.5 Eigenvalues of Symmetric Tridiagonal Matrices 13 22 32 42 84 70 83 93 107 119 126 138 154 161 172 183 193 203 217 223 235 249 261 273 277 293 308 = 320 333 6 Contents 5 Interpolation (and Curve Fitting) 5.1 Lagrange Form of the Interpolating Polynomial 5.2. Neville’s Algorithm i : 5.3 The Newton Form of the Interpolating Polynomial. 5.4 Optimal Points for Interpolation 5.5 Piecewise Linear Interpolation . . . 5.6 Cubic Spline Interpolation 5.7 Hermite and Hermite Cubic Interpolation . 5.8 Regression 6 Differentiation and Integration 6.1 Numerical Differentiation, Part I 6.2 Numerical Differentiation, Part II 6.3. Richardson Extrapolation 6.4 Numerical Integration—The Basics and Newton-Cotes Quadrature 6.5 Composite Newton-Cotes Quadrature 6.6 Gaussian Quadrature 6.7 Romberg Integration 68 Adaptive Quadrature 6.9 Improper Integrals and Other Discontinuities . 7 Initial Value Problems of Ordinary Differential Equations 7.1 Key Numerical Concepts and Elements of Continuous Theory 7.2. Buler's Method . 7.8 Higher-Order One-Step Methods: ‘Taylor Methods 74 Runge-Kutta Methods 7.5 Multistep Methods . . . 7.6 Convergence and Stability Analysis 7.7 Error Control and Variable Step Size Algorithms 7.8 Systems of Equations and Higher-Order Equations 9 Absolute Stability and iff Equations 8 Two-Point Boundary Value Problems 8.1 Finite Difference Method, Part I: The Linear Problem with Dirichlet cay CORMAICNOIIR 6) y.0 be uly AE g wey untet omg, ag iovleoh 8.2. Finite Difference Method, Part I: The Linear Problem with Non- Dirichlet Boundary Conditions ...... ‘ 83. Finite Difference Method, Part III: Nonlinear Problems 8.4 The Shooting Method, Part I: Linear Boundary Value Problems 8.5 The Shooting Method, Part II: Nonlinear Boundary Value Problems 353 - 865 375 386 - 398 405 417 430 441 444 450 459 . 467 479 494 508 517 532 549. 558 572 582 595 - 610 620 635 647 672 685 699 m1 725 Contents 7 9 Elliptic Partial Differential Equations 137 9.1. The Poisson Equation on a Rectangular Domain, I: Dirichlet Bound- ary Conditions : 742 9.2. The Poisson Equation on a Rectangular Domain, I: Non-Dirichlet Boundary Conditions RSs cabo IBe 9.3. Solving the Discrete Equations: Relaxation Methods... .. . . 769 9.4 Local Mode Analysis of Relaxation and the Multigrid Method . 783 9.5 Irregular Domains “ * . . 798 10 Parabolic Partial Differential Equations 815 10.1 The Heat Equation with Dirichlet Boundary Conditions i‘ 817 10.2 Absolute Stability... . Bae OR a ot eat 10.3 More General Parabolic Equations... . 840 10.4 Non-Dirichlet Boundary Conditions . 853 10.5 Polar Coordinates ey : 4 + 864 106 Problems in Two Spatial Dimensions... 00.0... ese. 02+ 877 11 Hyperbolic Equations and the Convection-Diffusion Equation 895 11.1 Advection Equation, I: Upwind Differencing............. . 900 11.2 Advection Equation, II: MacCormack Method 914 11.3 Conveetion-Diffusion Equation ih aimee . 926 11.4 The Wave Equation flansa tetas: etatia a Mah 0 seam » 936 APPENDICES A Important Theorems from Calculus 947 B Algorithm for Solving a Tridiagonal System of Linear Equations 948 References 951 Index 963 Answers to Selected Exercises *Web *Answors to Selected Exercises are available to text users at the web address of wwy.pes.cnu.edu/"bbradie/textbookansvers. html Preface ‘This is an introduction to the fundamental concepts and techniques of numerical analysis and numerical methods for undergraduates, as well as for graduate en- gineers and applied scientists receiving their first exposure to numerical analysis. Applications drawn from the literature of many different fields will prepare students to use the techniques covered to solve a wide variety of practical problems. There is. also sufficient mathematical detail to prepare students to embark upon an investi- gation of more advanced topics, especially in PDEs. ‘The presentation style is what 1 like to call tell and show. This means that the concepts and techniques are first developed in a clear, concise, and easy-to-read manner, and then illustrated with at least one fully worked example. In total, nearly 250 fully worked examples are presented to help the students grasp the sequence of calculations associated with a particular method and gain better insight into algorithm operation. The text is organized around mathematical problems, with each chapter de- voted to a single type of problem (e.¢., rootfinding, numerical calculus: differenti tion and integration, the matrix eigenvalue problem, and elliptic partial differential equations). Within each chapter the presentation begins with the simplest and most basic methods, progressing gradually to more advanced topics. Early chap- ters generally contain easier material, while later chapters proceed at increasing levels of difficulty and complexity, Throughout, emphasis is placed on understand- ing and being able to work with the key concepts of rate/order of convergence and stability, and assessing the accuracy of numerical results. This emphasis helps stu- dents develop skill in numerically verifying theoretical convergence speed. More importantly, the text emphasizes that it is not sufficient to obtain the correct an- swer from a numerical algorithm; one must also check that convergence toward the correct answer is happening at the correct speed. I have always felt very strongly that a textbook must provide students with some means of checking their under- standing and honing their skills, some means of making the knowledge their own. ‘This is invariably accomplished through the exercises. This text features more than 1200 numbered exercises (many with multiple parts) organized into exercise sets at the end of each section. Each exercise set contains problems designed to provide students with the opportunity to practice (with paper, pencil, and calculator) the sequence of calculations associated with a particular method. ‘The exercises usually also require the verification of theoretical error bounds and/or theoretical rates of convergence. Additional exercises may require the derivation of a method, an exam- ination of conditions under which methods perform better or worse than predicted by theory, or extension of material presented in the section. Many exercises require students to code a numerical method on the computer and then use that computer code, and many exercises are application problems that require interpretation of results 10 Preface Distinctive Features A quick scan of the table of contents will reveal that certain topics typically found in a book of this nature, such as approximation (orthogonal least-squares, FFT, ratio nal function approximation) and optimization, have been omitted. In place of these topics is an extensive coverage of material not, usually found, or only briefly dis- cussed, in other texts. This extensive coverage includes treatment of non-Dirichlet boundary conditions, and artificial singularities for one-dimensional boundary value problems; treatment of non-Dirichlet boundary conditions, the multigrid method and irregular domains for elliptic partial differential equations; treatment of source and decay terms, non-Dirichlet boundary conditions, polar coordinates and prob- Jems in two space dimensions for parabolic partial differential equations; and treat- ment of the advection and convection-diffusion equations. Why did I select such non-standard topics for inclusion? My primary objective in writing this text was to create a book that would allow students to immediately apply the numerical tech- niques they have learned to real-world problems. After reviewing technical journals and textbooks to determine the most commonly used basic numerical techniques and discussing topics with my colleagues and non-academic scientists/engineers, I felt that students would benefit more from an expanded coverage of boundary | value problems and partial differential equations than they would from a superfi- cial coverage of these same topics and inclusion of those topics which have been omitted. | In keeping with the objective of preparing students to apply numerical tech- niques, an extensive set of application problems has been compiled from the lit- erature of many different fields. Physies, biology, chemistry, chemical engineering, thermodynamics, heat transfer, electrostatics, ecology, manufacturing and sociol- ogy are among the fields represented. Each chapter opens with outlines of several real-world problems which serve to motivate the study and to demonstrate the broad applicability of the class of methods which will be treated in that chapter. Application problems then appear throughout the chapter as both worked examples and exercises. An added benefit of the application problems is that they afford the opportunity to discuss practical issues, such as introducing nondimensional vari- ables, treating singularities, and manipulating problems into the form required by a particular method. Perhaps the most distinctive feature of this book is the min- imal amount of pseudocode which appears. This feature is in marked contrast to other introductory textbooks on numerical analysis, which tend to have a lot of pseudocode, and usually some Maple and/or MATLAB code fragments, too. Un- fortunately, it has been my experience that most students don't use pseudocode properly. What is intended by an author as a teaching tool, more often than not, is used by the students just to expedite the completion of an assignment. Instead of digging through each line of code to develop a deeper understanding of how and why each method works, the student simply translates the code into whatever happens to be the language of choice. When this happens, little or no transfer of knowledge takes place. The end result in such a case is that the presence of pseudocode hinders, rather than promotes, student learning. For this reason, I have chosen to include Preface 11 pseudocode only when the natural language description of an algorithm became too cumbersome or when the pseudocode was needed to develop some other essential idea. Although pseudocode has largely been removed, students have most certainly not been left without guidance in the production of efficient, working code. Where appropriate, programming hints have been provided, and important implementa- tion details have been discussed. Then, of course, there are the worked examples. These provide dynamic demonstrations for each of the algorithms being developed and contain sufficient detail to suggest an overall structure for the implementation of the algorithm. Furthermore, to recognize that structure, the student will have to become actively involved with the details of the example. Thus, when compared with pseudocode, which is a static representation of an algorithm, worked examples are, in my opinion, the superior alternative. Supplements and Software This text is accompanied by an Instructors Solutions Manual that can be ob- tained (by instructors only) by contacting either the local Prentice Hall sales rep or george_lobell@premhall.com. There are also 70 plus pages of Answers to Selected Exercises for students, found on the website ww. pes. cnu. edu/“bbradie/textbookanswers. html To accommodate differing viewpoints on the pseudocode issue, implementations for all of the methods developed in the text can be downloaded via the Inter net. Each method is available in MATLAB and C++ formats. Depending upon demand, Maple, Mathematica, MathCad and Fortran implementations may be added. Instructions for using the MATLAB functions are contained in the header of the corresponding m-file and are accessible through the standard MATLAB help (function name) facility. Each C++ function is described in the comments at the beginning of the code. The main page for obtaining the software is located at www.pcs.cnu.edu/“bbradie/textbookcode html. To the Student ‘The best advice that I can give for working with this textbook is to be an active reader. This means that each time you come to a worked example, you should verify the results of all calculations on your own and attempt to fill in all of the missing details. A similar procedure should be employed for each proof that you read. Working in this fashion will not only hone your general mechanical and analytical skills, but will also significantly improve your understanding of how and why each numerical method works, and will stimulate the process by which you assimilate new knowledge and make it your own, The most common stumbling block encountered by numerical analysis students is difficulty in translating the natural language description of an algorithm into working computer code. Here is a scheme that you may find helpful in overcoming this problem. Start by identifying the inputs. ‘The inputs should include every item that must be known for the code to perform its intended task. Don’t forget values that are needed to control 12 Preface the termination of an iterative process. Next, identify the outputs, which are, of course, the values which the code is supposed to compute. Once the inputs and the outputs have been clearly identified, focus on the construction of a logical and well-defined sequence of steps that will produce the outputs from the inputs. The worked examples should prove extremely useful at this point. Finally, convert each step into the appropriate set of assignment statements, conditional/branching statements, loop structures and function calls. As with any new skill, the more you practice, the better you will become. Acknowledgments At the top of the list of those to whom I owe a debt of gratitude are George Lobell Jennifer Urban, and Debbie Ryan at Prentice Hall, I doubt that working with a novice author is ever easy, but they led me through the process to publication with unbelievable patience and kindness. Next comes George Webb, the Dean of the College of Science and Technology at Christopher Newport University, who was a constant source of encouragement and enthusiasm. The reviewers of earlier drafts supplied numerous important comments/suggestions and criticisms/corrections to make what was a good book a much better one. They are: Herman Gollwitzer, Drexel University; Jan $. Hesthaven, Brown University; Carl Gardner, Arizona State University; Scott R. Fulton, Clarkson University; Charles Odion, Prairie View A&M University; Mark S. Gockenbach, Michigan ‘Technological University; Jeffrey S. Scroggs, North Carolina State University; Stephen E. Stuckwisch, Auburn University; Chi-Ming Tang, SUNY Geneseo; Alejandro Engel, Rochester Institute of Technology; Mark Arnold, University of Arkansas; Kuiyuan Li, University of West Florida; Richard A. Zalik, Auburn University; and Rakhim Aitbayev, New Mexico Institute of Mining and Technology. The students who served as guinea pigs for the rough drafts—Brad Abbott, Marchele Bachini, Neal Cheney, Chandon Davis, Brent Goodwin, James Laverty, Peter Parker, Nathan Phillips, Sonny Price, Michelle Reaves, and Kenneth Surles-Law—also made many valuable suggestions. Peter Parker and Michelle Reaves deservé special recognition for detecting more typographical errors than I would like to admit. Finally, I wish to thank Vernon Mason, Melissa Waugh and Debbie Decker, whose workouts helped me to relieve a tremendous amount of stress and to break through several rough bouts of writers block. If you find any errors, please email me as soon as possible. I will make corrections immediately and post on thie website errata. Brian Bradie bbradie@pes.cnu.edu CBAC Bia Bike wal Getting Started AN OVERVIEW ‘The diagram shown below provides a greatly oversimplified view of applied mathe- matics. The starting point is almost always some real-world problem or real-world phenomena that needs to be studied. The axioms and postulates of the appropriate cipline(s)—be they from the physical, natural, or social sciences—are then used to develop a set of assumptions and a set of equations, known as a mathematical model, which will be used for subsequent analysis. The type of equations that arise can range from simple algebraic equations to extremely complicated coupled systems of nonlinear partial differential equations. Once the model has been set, the next step is to solve the equations and interpret the results in the context of the original problem. If the predictions of the model are in agreement with experi- mental data, the model is accepted and can be used to make predictions regarding situations for which experimental data is unavailable. On the other hand, if the model fails to accurately reflect some desired aspect of the dynamical behavior of the system, it is necessary to return to the model building phase and reexamine the validity of the model’s basic assumptions, Real-world problem Real-world phenomena | Mathematical model Fo applied at the other end. The magnitude of the force that can be withstood depends on the angle @ through which the rope is wrapped around the cylinder (see figure above) and on the coefficient of friction, 1, between the rope and the cylinder. The coefficient of friction is defined by the relation dF @ BE. 18 Chapter 1 Getting Started As part of a physics lab, students need to estimate the coefficient of friction between a given rope and cylinder. For a restraining force of F) = 5 Ib, they have obtained the following data for F as a function of 6. 0 0 x/2 30/2 26 Se/2 3x Tn/2 4m Qn/2 5m F(@) 5.00 7.83 12.27 19.22 30.10 47.15 73.86 115.70 181.24 283.90 444.71 To complete the lab, the students must be able to take this data and estimate 4F/d8. This problem requires techniques for numerical differentiation, which are considered in Chapter 6. Projection Printing @) Light source fees an Optics (eerie some cress], a Make

You might also like