ebook img

Numerical Methods for Engineers and Scientists Using MATLAB® PDF

494 Pages·2017·5.05 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Numerical Methods for Engineers and Scientists Using MATLAB®

Numerical Methods for Engineers and Scientists Using MATLAB® Second Edition Numerical Methods for Engineers and Scientists Using MATLAB® Second Edition Ramin S. Esfandiari, PhD MATLAB® 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® software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particu- lar use of the MATLAB® software. CRC Press Taylor & Francis Group, 6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742 © 2017 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Printed on acid-free paper International Standard Book Number-13: 978-1-4987-7742-1 (Hardback) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including pho- tocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www.copyright.com (http:// www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Library of Congress Cataloging–in–Publication Data Names: Esfandiari, Ramin S., author. Title: Numerical methods for engineers and scientists using MATLAB / Ramin S. Esfandiari. Description: Second edition. | Boca Raton : a CRC title, part of the Taylor & Francis imprint, a member of the Taylor & Francis Group, the academic division of T&F Informa, plc, [2017] Identifiers: LCCN 2016039623 | ISBN 9781498777421 (hardback : alk. paper) Subjects: LCSH: Engineering mathematics. | Numerical analysis. Classification: LCC TA335 .E843 2017 | DDC 620.00285/53--dc23 LC record available at https://lccn.loc.gov/2016039623 Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com To My wife Haleh, my sisters Mandana and Roxana, and my parents to whom I owe everything Contents Preface .............................................................................................................................................xv Acknowledgments ......................................................................................................................xix Author ...........................................................................................................................................xxi 1. Background and Introduction ..............................................................................................1 Part 1: Background ..................................................................................................................1 1.1 Differential Equations ..................................................................................................1 1.1.1 Linear, First-Order ODEs ................................................................................1 1.1.2 Second-Order ODEs with Constant Coeficients ........................................2 1.1.2.1 Homogeneous Solution ...................................................................2 1.1.2.2 Particular Solution ...........................................................................3 1.1.3 Method of Undetermined Coeficients .........................................................3 1.2 Matrix Analysis .............................................................................................................4 1.2.1 Matrix Operations............................................................................................5 1.2.2 Matrix Transpose .............................................................................................5 1.2.3 Special Matrices ...............................................................................................6 1.2.4 Determinant of a Matrix .................................................................................6 1.2.5 Properties of Determinant ..............................................................................6 1.2.5.1 Cramer’s Rule ....................................................................................7 1.2.6 Inverse of a Matrix ...........................................................................................8 1.2.7 Properties of Inverse ........................................................................................9 1.2.8 Solving a Linear System of Equations ..........................................................9 1.3 Matrix Eigenvalue Problem .........................................................................................9 1.3.1 Solving the Eigenvalue Problem ..................................................................10 1.3.2 Similarity Transformation ............................................................................11 1.3.3 Matrix Diagonalization .................................................................................11 1.3.4 Eigenvalue Properties of Matrices ...............................................................12 Part 2: Introduction to Numerical Methods .......................................................................12 1.4 Errors and Approximations .......................................................................................12 1.4.1 Sources of Computational Error ..................................................................12 1.4.2 Binary and Hexadecimal Numbers ............................................................13 1.4.3 Floating Point and Rounding Errors ...........................................................13 1.4.4 Round-Off: Chopping and Rounding .........................................................14 1.4.5 Absolute and Relative Errors .......................................................................15 1.4.6 Error Bound ....................................................................................................16 1.4.7 Transmission of Error from a Source to the Final Result .........................16 1.4.8 Subtraction of Nearly Equal Numbers .......................................................17 1.5 Iterative Methods ........................................................................................................19 1.5.1 Fundamental Iterative Method ....................................................................20 1.5.2 Rate of Convergence of an Iterative Method ..............................................21 Problem Set (Chapter 1) ........................................................................................................22 2. Introduction to MATLAB® .................................................................................................27 2.1 MATLAB Built-In Functions .....................................................................................27 vii viii Contents 2.1.1 Rounding Commands ...................................................................................27 2.1.2 Relational Operators ......................................................................................28 2.1.3 Format Options ..............................................................................................28 2.2 Vectors and Matrices ..................................................................................................29 2.2.1 Linspace...........................................................................................................30 2.2.2 Matrices ...........................................................................................................30 2.2.3 Determinant, Transpose, and Inverse .........................................................32 2.2.4 Slash Operators ..............................................................................................33 2.2.5 Element-by-Element Operations ..................................................................33 2.2.6 Diagonal Matrices and Diagonals of a Matrix ...........................................34 2.3 Symbolic Math Toolbox ..............................................................................................36 2.3.1 Anonymous Functions ..................................................................................38 2.3.2 MATLAB Function ........................................................................................38 2.3.3 Differentiation ................................................................................................39 2.3.4 Partial Derivatives .........................................................................................40 2.3.5 Integration .......................................................................................................40 2.4 Program Flow Control ................................................................................................41 2.4.1 for Loop .........................................................................................................41 2.4.2 The if Command ..........................................................................................42 2.4.3 while Loop ....................................................................................................43 2.5 Displaying Formatted Data .......................................................................................43 2.5.1 Differential Equations ...................................................................................44 2.6 Plotting .........................................................................................................................45 2.6.1 subplot ..........................................................................................................45 2.6.2 Plotting Analytical Expressions ..................................................................46 2.6.3 Multiple Plots ..................................................................................................46 2.7 User-Deined Functions and Script Files .................................................................47 2.7.1 Setting Default Values for Input Variables .................................................49 2.7.2 Creating Script Files ......................................................................................50 Problem Set (Chapter 2) ........................................................................................................51 3. Numerical Solution of Equations of a Single Variable .................................................55 3.1 Numerical Solution of Equations ..............................................................................55 3.2 Bisection Method ........................................................................................................55 3.2.1 MATLAB Built-In Function fzero .............................................................60 3.3 Regula Falsi Method (Method of False Position) ....................................................61 3.3.1 Modiied Regula Falsi Method ....................................................................64 3.4 Fixed-Point Method ....................................................................................................65 3.4.1 Selection of a Suitable Iteration Function ...................................................66 3.4.2 A Note on Convergence ................................................................................67 3.4.3 Rate of Convergence of the Fixed-Point Iteration ......................................71 3.5 Newton’s Method (Newton–Raphson Method) .....................................................72 3.5.1 Rate of Convergence of Newton’s Method .................................................76 3.5.2 A Few Notes on Newton’s Method .............................................................77 3.5.3 Modiied Newton’s Method for Roots with Multiplicity 2 or Higher ......................................................................................................78 3.6 Secant Method .............................................................................................................81 3.6.1 Rate of Convergence of Secant Method ......................................................83 3.6.2 A Few Notes on Secant Method ..................................................................83 Contents ix 3.7 Equations with Several Roots ....................................................................................83 3.7.1 Finding Roots to the Right of a Speciied Point .........................................83 3.7.2 Finding Several Roots in an Interval Using fzero ..................................84 Problem Set (Chapter 3) ........................................................................................................88 4. Numerical Solution of Systems of Equations .................................................................95 4.1 Linear Systems of Equations .....................................................................................95 4.2 Numerical Solution of Linear Systems.....................................................................96 4.3 Gauss Elimination Method ........................................................................................96 4.3.1 Choosing the Pivot Row: Partial Pivoting with Row Scaling .................98 4.3.2 Permutation Matrices ....................................................................................99 4.3.3 Counting the Number of Operations ........................................................102 4.3.3.1 Elimination ....................................................................................102 4.3.3.2 Back Substitution ..........................................................................103 4.3.4 Tridiagonal Systems ....................................................................................103 4.3.4.1 Thomas Method ...........................................................................104 4.3.4.2 MATLAB Built-In Function "\" .................................................106 4.4 LU Factorization Methods .......................................................................................107 4.4.1 Doolittle Factorization .................................................................................107 4.4.2 Finding L and U Using Steps of Gauss Elimination ...............................108 4.4.3 Finding L and U Directly............................................................................108 4.4.3.1 Doolittle’s Method to Solve a Linear System ............................110 4.4.3.2 Operations Count .........................................................................112 4.4.4 Cholesky Factorization ................................................................................112 4.4.4.1 Cholesky’s Method to Solve a Linear System ...........................113 4.4.4.2 Operations Count .........................................................................115 4.4.4.3 MATLAB Built-In Functions lu and chol ...............................115 4.5 Iterative Solution of Linear Systems .......................................................................116 4.5.1 Vector Norms ................................................................................................116 4.5.2 Matrix Norms ...............................................................................................118 4.5.2.1 Compatibility of Vector and Matrix Norms .............................119 4.5.3 General Iterative Method ............................................................................120 4.5.3.1 Convergence of the General Iterative Method .........................120 4.5.4 Jacobi Iteration Method ...............................................................................121 4.5.4.1 Convergence of the Jacobi Iteration Method ............................122 4.5.5 Gauss–Seidel Iteration Method ..................................................................125 4.5.5.1 Convergence of the Gauss–Seidel Iteration Method ...............127 4.5.6 Indirect Methods versus Direct Methods for Large Systems ................130 4.6 Ill-Conditioning and Error Analysis ......................................................................131 4.6.1 Condition Number.......................................................................................131 4.6.2 Ill-Conditioning ...........................................................................................132 4.6.2.1 Indicators of Ill-Conditioning .....................................................133 4.6.3 Computational Error ...................................................................................133 4.6.3.1 Consequences of Ill-Conditioning .............................................135 4.6.4 Effects of Parameter Changes on the Solution ........................................136 4.7 Systems of Nonlinear Equations .............................................................................138 4.7.1 Newton’s Method for a System of Nonlinear Equations ........................138 4.7.1.1 Newton’s Method for Solving a System of Two Nonlinear Equations ...........................................................138 x Contents 4.7.1.2 Newton’s Method for Solving a System of n Nonlinear Equations .......................................................................................142 4.7.1.3 Convergence of Newton’s Method .............................................142 4.7.2 Fixed-Point Iteration Method for a System of Nonlinear Equations ....143 4.7.2.1 Convergence of the Fixed-Point Iteration Method ...................143 Problem Set (Chapter 4) ......................................................................................................146 5. Curve Fitting and Interpolation ......................................................................................161 5.1 Least-Squares Regression ........................................................................................161 5.2 Linear Regression ......................................................................................................162 5.2.1 Deciding a “Best” Fit Criterion ..................................................................163 5.2.2 Linear Least-Squares Regression ...............................................................164 5.3 Linearization of Nonlinear Data .............................................................................167 5.3.1 Exponential Function ..................................................................................167 5.3.2 Power Function ............................................................................................167 5.3.3 Saturation Function .....................................................................................168 5.4 Polynomial Regression .............................................................................................172 5.4.1 Quadratic Least-Squares Regression ........................................................174 5.4.2 Cubic Least-Squares Regression ................................................................176 5.4.3 MATLAB Built-In Functions Polyfit and Polyval ............................178 5.5 Polynomial Interpolation .........................................................................................179 5.5.1 Lagrange Interpolating Polynomials ........................................................180 5.5.2 Drawbacks of Lagrange Interpolation ......................................................183 5.5.3 Newton Divided-Difference Interpolating Polynomials .......................184 5.5.4 Special Case: Equally-Spaced Data ...........................................................190 5.5.5 Newton Forward-Difference Interpolating Polynomials .......................191 5.6 Spline Interpolation ..................................................................................................193 5.6.1 Linear Splines ...............................................................................................194 5.6.2 Quadratic Splines .........................................................................................195 5.6.2.1 Function Values at the Endpoints (2 Equations) ......................195 5.6.2.2 Function Values at the Interior Knots (2n − 2 Equations) .......196 5.6.2.3 First Derivatives at the Interior Knots (n − 1 Equations) ........196 5.6.2.4 Second Derivative at the Left Endpoint is Zero (1 Equation) ....196 5.6.3 Cubic Splines ................................................................................................198 5.6.3.1 Clamped Boundary Conditions .................................................199 5.6.3.2 Free Boundary Conditions ..........................................................199 5.6.4 Construction of Cubic Splines: Clamped Boundary Conditions ..........199 5.6.5 Construction of Cubic Splines: Free Boundary Conditions ...................204 5.6.6 MATLAB Built-In Functions interp1 and spline ..............................205 5.6.7 Boundary Conditions ..................................................................................207 5.6.8 Interactive Curve Fitting and Interpolation in MATLAB ......................208 5.7 Fourier Approximation and Interpolation ............................................................209 5.7.1 Sinusoidal Curve Fitting .............................................................................209 5.7.1.1 Fourier Approximation ...............................................................210 5.7.1.2 Fourier Interpolation ...................................................................210 5.7.2 Linear Transformation of Data ..................................................................210 5.7.3 Discrete Fourier Transform ........................................................................215 5.7.4 Fast Fourier Transform ................................................................................216 5.7.4.1 Sande–Tukey Algorithm (N = 2p, p = integer) ...........................217

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.