1. Trang chủ
  2. » Thể loại khác

John wiley sons yang w et al applied numerical methods using matlab (2005)(isbn 0471698334)(511s)

511 175 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 511
Dung lượng 2,3 MB

Nội dung

APPLIED NUMERICAL METHODS USING MATLAB Won Young Yang Chung-Ang University, Korea Wenwu Cao Pennsylvania State University Tae-Sang Chung Chung-Ang University, Korea John Morris The University of Auckland, New Zealand A JOHN WILEY & SONS, INC., PUBLICATION Questions about the contents of this book can be mailed to wyyang@cau.ac.kr MATLAB and Simulink are trademarks of the The MathWorks, Inc and are 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 and Simulink software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB and Simulink software Copyright  2005 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 authors 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 or extended by sales representatives or written sales materials The advice and strategies contained herein 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 within 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 Yang, Won-young, 1953– Applied numerical methods using MATLAB / Won Y Yang, Wenwu Cao, Tae S Chung, John Morris p cm Includes bibliographical references and index ISBN 0-471-69833-4 (cloth) Numerical analysis–Data processing MATLAB I Cao, Wenwu II Chung, Tae-sang, 1952– III Title QA297.Y36 2005 518–dc22 2004013108 Printed in the United States of America 10 To our parents and families who love and support us and to our teachers and students who enriched our knowledge CONTENTS Preface MATLAB Usage and Computational Errors xiii 1.1 Basic Operations of MATLAB / 1.1.1 Input/Output of Data from MATLAB Command Window / 1.1.2 Input/Output of Data Through Files / 1.1.3 Input/Output of Data Using Keyboard / 1.1.4 2-D Graphic Input/Output / 1.1.5 3-D Graphic Output / 10 1.1.6 Mathematical Functions / 10 1.1.7 Operations on Vectors and Matrices / 15 1.1.8 Random Number Generators / 22 1.1.9 Flow Control / 24 1.2 Computer Errors Versus Human Mistakes / 27 1.2.1 IEEE 64-bit Floating-Point Number Representation / 28 1.2.2 Various Kinds of Computing Errors / 31 1.2.3 Absolute/Relative Computing Errors / 33 1.2.4 Error Propagation / 33 1.2.5 Tips for Avoiding Large Errors / 34 1.3 Toward Good Program / 37 1.3.1 Nested Computing for Computational Efficiency / 37 1.3.2 Vector Operation Versus Loop Iteration / 39 1.3.3 Iterative Routine Versus Nested Routine / 40 1.3.4 To Avoid Runtime Error / 40 1.3.5 Parameter Sharing via Global Variables / 44 1.3.6 Parameter Passing Through Varargin / 45 1.3.7 Adaptive Input Argument List / 46 Problems / 46 vii viii CONTENTS System of Linear Equations 71 2.1 Solution for a System of Linear Equations / 72 2.1.1 The Nonsingular Case (M = N ) / 72 2.1.2 The Underdetermined Case (M < N ): Minimum-Norm Solution / 72 2.1.3 The Overdetermined Case (M > N ): Least-Squares Error Solution / 75 2.1.4 RLSE (Recursive Least-Squares Estimation) / 76 2.2 Solving a System of Linear Equations / 79 2.2.1 Gauss Elimination / 79 2.2.2 Partial Pivoting / 81 2.2.3 Gauss–Jordan Elimination / 89 2.3 Inverse Matrix / 92 2.4 Decomposition (Factorization) / 92 2.4.1 LU Decomposition (Factorization): Triangularization / 92 2.4.2 Other Decomposition (Factorization): Cholesky, QR, and SVD / 97 2.5 Iterative Methods to Solve Equations / 98 2.5.1 Jacobi Iteration / 98 2.5.2 Gauss–Seidel Iteration / 100 2.5.3 The Convergence of Jacobi and Gauss–Seidel Iterations / 103 Problems / 104 Interpolation and Curve Fitting 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 Interpolation by Lagrange Polynomial / 117 Interpolation by Newton Polynomial / 119 Approximation by Chebyshev Polynomial / 124 Pade Approximation by Rational Function / 129 Interpolation by Cubic Spline / 133 Hermite Interpolating Polynomial / 139 Two-dimensional Interpolation / 141 Curve Fitting / 143 3.8.1 Straight Line Fit: A Polynomial Function of First Degree / 144 3.8.2 Polynomial Curve Fit: A Polynomial Function of Higher Degree / 145 3.8.3 Exponential Curve Fit and Other Functions / 149 3.9 Fourier Transform / 150 3.9.1 FFT Versus DFT / 151 3.9.2 Physical Meaning of DFT / 152 3.9.3 Interpolation by Using DFS / 155 Problems / 157 117 CONTENTS Nonlinear Equations 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 ix 179 Iterative Method Toward Fixed Point / 179 Bisection Method / 183 False Position or Regula Falsi Method / 185 Newton(–Raphson) Method / 186 Secant Method / 189 Newton Method for a System of Nonlinear Equations / 191 Symbolic Solution for Equations / 193 A Real-World Problem / 194 Problems / 197 Numerical Differentiation/Integration 209 5.1 Difference Approximation for First Derivative / 209 5.2 Approximation Error of First Derivative / 211 5.3 Difference Approximation for Second and Higher Derivative / 216 5.4 Interpolating Polynomial and Numerical Differential / 220 5.5 Numerical Integration and Quadrature / 222 5.6 Trapezoidal Method and Simpson Method / 226 5.7 Recursive Rule and Romberg Integration / 228 5.8 Adaptive Quadrature / 231 5.9 Gauss Quadrature / 234 5.9.1 Gauss–Legendre Integration / 235 5.9.2 Gauss–Hermite Integration / 238 5.9.3 Gauss–Laguerre Integration / 239 5.9.4 Gauss–Chebyshev Integration / 240 5.10 Double Integral / 241 Problems / 244 Ordinary Differential Equations 6.1 6.2 6.3 6.4 Euler’s Method / 263 Heun’s Method: Trapezoidal Method / 266 Runge–Kutta Method / 267 Predictor–Corrector Method / 269 6.4.1 Adams–Bashforth–Moulton Method / 269 6.4.2 Hamming Method / 273 6.4.3 Comparison of Methods / 274 6.5 Vector Differential Equations / 277 6.5.1 State Equation / 277 6.5.2 Discretization of LTI State Equation / 281 6.5.3 High-Order Differential Equation to State Equation / 283 6.5.4 Stiff Equation / 284 263 x CONTENTS 6.6 Boundary Value Problem (BVP) / 287 6.6.1 Shooting Method / 287 6.6.2 Finite Difference Method / 290 Problems / 293 Optimization 321 7.1 Unconstrained Optimization [L-2, Chapter 7] / 321 7.1.1 Golden Search Method / 321 7.1.2 Quadratic Approximation Method / 323 7.1.3 Nelder–Mead Method [ W-8] / 325 7.1.4 Steepest Descent Method / 328 7.1.5 Newton Method / 330 7.1.6 Conjugate Gradient Method / 332 7.1.7 Simulated Annealing Method [W-7] / 334 7.1.8 Genetic Algorithm [W-7] / 338 7.2 Constrained Optimization [L-2, Chapter 10] / 343 7.2.1 Lagrange Multiplier Method / 343 7.2.2 Penalty Function Method / 346 7.3 MATLAB Built-In Routines for Optimization / 350 7.3.1 Unconstrained Optimization / 350 7.3.2 Constrained Optimization / 352 7.3.3 Linear Programming (LP) / 355 Problems / 357 Matrices and Eigenvalues 371 8.1 Eigenvalues and Eigenvectors / 371 8.2 Similarity Transformation and Diagonalization / 373 8.3 Power Method / 378 8.3.1 Scaled Power Method / 378 8.3.2 Inverse Power Method / 380 8.3.3 Shifted Inverse Power Method / 380 8.4 Jacobi Method / 381 8.5 Physical Meaning of Eigenvalues/Eigenvectors / 385 8.6 Eigenvalue Equations / 389 Problems / 390 Partial Differential Equations 9.1 Elliptic PDE / 402 9.2 Parabolic PDE / 406 9.2.1 The Explicit Forward Euler Method / 406 9.2.2 The Implicit Backward Euler Method / 407 401 CONTENTS xi 9.2.3 The Crank–Nicholson Method / 409 9.2.4 Two-Dimensional Parabolic PDE / 412 9.3 Hyperbolic PDE / 414 9.3.1 The Explicit Central Difference Method / 415 9.3.2 Two-Dimensional Hyperbolic PDE / 417 9.4 Finite Element Method (FEM) for solving PDE / 420 9.5 GUI of MATLAB for Solving PDEs: PDETOOL / 429 9.5.1 Basic PDEs Solvable by PDETOOL / 430 9.5.2 The Usage of PDETOOL / 431 9.5.3 Examples of Using PDETOOL to Solve PDEs / 435 Problems / 444 Appendix A Mean Value Theorem 461 Appendix B Matrix Operations/Properties 463 Appendix C Differentiation with Respect to a Vector 471 Appendix D Laplace Transform 473 Appendix E Fourier Transform 475 Appendix F Useful Formulas 477 Appendix G Symbolic Computation 481 Appendix H Sparse Matrices 489 Appendix I MATLAB 491 References 497 Subject Index 499 Index for MATLAB Routines 503 Index for Tables 509 PREFACE This book introduces applied numerical methods for engineering and science students in sophomore to senior levels; it targets the students of today who not like or not have time to derive and prove mathematical results It can also serve as a reference to MATLAB applications for professional engineers and scientists, since many of the MATLAB codes presented after introducing each algorithm’s basic ideas can easily be modified to solve similar problems even by those who not know what is going on inside the MATLAB routines and the algorithms they use Just as most drivers only have to know where to go and how to drive a car to get to their destinations, most users only have to know how to define the problems they want to solve using MATLAB and how to use the corresponding routines to solve their problems We never deny that detailed knowledge about the algorithm (engine) of the program (car) is helpful for getting safely to the solution (destination); we only imply that one-time users of any MATLAB program or routine may use this book as well as the students who want to understand the underlying principle of each algorithm In this book, we focus on understanding the fundamental mathematical concepts and mastering problem-solving skills using numerical methods with the help of MATLAB and skip some tedious derivations Obviously, basic concepts must be taught so that students can properly formulate the mathematics problems Afterwards, students can directly use the MATLAB codes to solve practical problems Almost every algorithm introduced in this book is followed by example MATLAB code with a friendly interface so that students can easily modify the code to solve real life problems The selection of exercises follows the some philosophy of making the learning easy and practical Students should be able to solve similar problems immediately after taking the class using the MATLAB codes we provide For most students—and particularly nonmath majors—understanding how to use numerical tools correctly in solving their problems of interest is more important than studying lengthy proofs and derivations MATLAB is one of the most developed software packages available today It provides many numerical methods and it is very easy to use, even for people without prior programming experience We have supplemented MATLAB’s builtin functions with more than 100 small MATLAB routines Readers should find xiii xiv PREFACE these routines handy and useful Some of these routines give better results for some problems than the built-in functions Students are encouraged to develop their own routines following the examples The knowledge in this book is derived from the work of many eminent scientists, scholars, researchers, and MATLAB developers, all of whom we thank We thank our colleagues, students, relatives, and friends for their support and encouragement We thank the reviewers, whose comments were so helpful in tuning this book We especially thank Senior Researcher Yong-Suk Park for his invaluable help in correction We thank the editorial and production staff of John Wiley & Sons, Inc including Editor Val Moliere and Production Editor Lisa VanHorn for their kind, efficient, and encouraging guide WON YOUNG YANG WENWU CAO TAE-SANG CHUNG JOHN MORRIS October 2004 494 MATLAB Figure I.2 The MATLAB file editor/debugger window is (are) suspicious to be the source(s) of error, by clicking the pertinent statement line of the program with the left mouse button and pressing the F12 key or clicking ‘Set/Clear Breakpoint’ in the ‘Breakpoints’ pull-down menu of the Editor/Debugger window Then, you will see a small red disk in front of every statement at which you set the breakpoint Going to the MATLAB Command window, type in the name of the file containing the main program to try running the program Then, go back to the Editor/Debugger window and you will see the cursor blinking just after a green arrow between the red disk and the first statement line at which you set the breakpoint Determining which variable to look into, go to the Command window and type in the variable name(s) (just after the prompt ‘K>>’) or whatever statement you want to run for debugging If you want to proceed to the next statement line in the program, go back to the Editor/Debugger window and press the F10 (single step) key or the F11 (step in) key to dig into a called routine If you want to jump to the next breakpoint, press F5 or click ‘Run (Continue)’ in the Debug pull-down menu of the Editor/Debugger window If you want to run the program until just before a statement, move the cursor to the line and click ‘Go Until Cursor’ in the Debug pull-down menu (see Fig I.2) If you have figure out what is wrong, edit the pertinent part of the program, save the edited program in the Editor/Debugger window, and then go to the Command window, typing the name of the file containing the main program to try running the program for test If the result seems to reflect that the program still has a bug, go back to step and restart the whole procedure MATLAB 495 If you use the MATLAB of version 5.x, you can refer to the usage of the constrained minimization routine ‘constr()’, which is summarized in the box below USAGE OF THE MATLAB 5.X BUILT-IN FUNCTION “CONSTR()” FOR CONSTRAINED OPTIMIZATION [x,options] = constr(’ftn’,x0,options,l,u) ž Input arguments (only ‘ftn’ and x0 required, the others optional) ‘ftn’ : usually defined in an m-file and should return two output arguments, one of which is a scalar value (f (x)) of the function (ftn) to be minimized and the other is a vector (g(x)) of constraints such that g(x) ≤ x0 : the initial guess of solution options: is used for setting the termination tolerance on x, f (x), and constraint violation through options(2)/(3)/(4), the number of the (leading) equality constraints among g(x) ≤ through options (13), etc (For more details, type ‘help foptions’ into the MATLAB command window) l,u : lower/upper bound vectors such that l ≤ x ≤ u ž Output arguments : minimum point reached in the permissible region satisfying the constraints options: outputs some information about the search process and the result like the function value at the minimum point (x) reached through options (8) x REFERENCES [B-1] Burden, Richard L., and Fairs, J Douglas, Numerical Analysis, 7th ed., Brooks/ Cole Thomson, Pacific Grove, CA, 2001 [B-2] Bell, H E., Gerschgorin’s theorem and the zeros of polynomials, Am Math Monthly 72, 292–295 (1965) [C-1] Canale, Raymond, and Chapra, Steven, Numerical Methods for Engineers: with Software and Programming Applications, McGraw-Hill, New York, 2002 [F-1] Fausett, L V., Applied Numerical Analysis Using MATLAB, Prentice-Hall, Upper Saddle River, NJ, 1999 [H-1] Hamming, R W., Numerical Methods for Scientists and Engineers, 2nd ed., McGraw-Hill, New York, 1973 [K-1] Kreyszig, Erwin, Advanced Engineering Mathematics, 8th ed., John Wiley & Sons, New York, 1999 [K-2] Kreyszig, Erwin, Introductory Functional Analysis with Applications, John Wiley & Sons, New York, 1978 [L-1] Lindfield, G R., and Peny, J E T., Numerical Methods Using MATLAB, 8th ed., Prentice-Hall, Upper Saddle River, NJ, 2000 [L-2] Luenberger, D G., Linear and Nonlinear Programming, 2nd ed., Addison-Wesley Publishing Company, Reading, MA, 1984 [M-1] Mathews, J H., and Fink, K D., Numerical Methods Using MATLAB, PrenticeHall, Upper Saddle River, NJ, 1999 [M-2] Maron, Melvin J., Numerical Analysis, Macmillan, Inc., New York, 1982 [N-1] Nakamura, Shoichiro, Numerical Analysis and Graphic Visualization with MATLAB, 2nd ed., Prentice-Hall, Upper Saddle River, NJ, 2002 [O-1] Oppenheim, Alan V., and Schafer, Ronald W., Discrete-Time Signal Processing, Prentice-Hall, Englewood Cliffs, NJ, 1989 [P-1] Peaceman, D W., and Rachford, H H., The numerical solution of parabolic and elliptic differential equations, J Soc Ind Appl Math 3, 28–41 (1955) [P-2] Pham, D T., and Karaboga, D., Intelligent Optimization Techniques, SpringerVerlag, London, 1998 Applied Numerical Methods Using MATLAB, by Yang, Cao, Chung, and Morris Copyright  2005 John Wiley & Sons, Inc., ISBN 0-471-69833-4 497 498 REFERENCES [P-3] Phillips, C L., and Nagle, H T., Jr., Digital Control System Analysis and Design, Prentice-Hall, Upper Saddle River, NJ, 2002 [R-1] Rao, S S., The Finite Element Method in Engineering, 3rd ed., Butterworth Heinemann, Boston, 1999 [R-2] Recktenwald, G W., Numerical Methods with MATLAB, Prentice-Hall, Upper Saddle River, NJ, 2000 [S-1] Schilling, R J., and Harris, S L., Applied Numerical Methods for Engineers Using MATLAB and C, Brooks/Cole, Pacific Grove, CA, 2000 [S-2] Silvester, P P., and Ferrari, R L., Finite Elements for Electrical Engineers, 3rd ed., Cambridge University Press, Cambridge, U.K., 1996 [S-3] Stoer, J., and Bulirsch, R., Introduction to Numerical Analysis, Springer-Verlag, New York, 1980 [W-1] Website [W-2] Website [W-3] Website [W-4] Website

Ngày đăng: 23/05/2018, 13:56

TỪ KHÓA LIÊN QUAN