numerical analysis using matlab and excel - steven t. karris

627 730 1
numerical analysis using matlab and excel - steven t. karris

Đ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

Orchard Publications www.orchardpublications.com Numerical Analysis Using MATLAB® and Excel® Steven T. Karris Third Edition ISBN-13: 978-11-9934404-004-11 Orchard Publications Visit us on the Internet www.orchardpublications.com or email us: info@orchardpublications.com Steven T. Karris is the president and founder of Orchard Publications, has undergraduate and graduate degrees in electrical engineering, and is a registered professional engineer in California and Florida. He has more than 35 years of professional engineering experience and more than 30 years of teaching experience as an adjunct professor, most recently at UC Berkeley, California. This text includes the following chapters and appendices: • Introduction to MATLAB • Root Approximations • Sinusoids and Complex Numbers • Matrices and Determinants • Review of Differential Equations • Fourier, Taylor, and Maclaurin Series • Finite Differences and Interpolation • Linear and Parabolic Regression • Solution of Differential Equations by Numerical Methods • Integration by Numerical Methods • Difference Equations • Partial Fraction Expansion • The Gamma and Beta Functions • Orthogonal Functions and Matrix Factorizations • Bessel, Legendre, and Chebyshev Polynomials • Optimization Methods • Difference Equations in Discrete-Time Systems • Introduction to Simulink • Ill-Conditioned Matrices Each chapter contains numerous practical applications supplemented with detailed instructions for using MATLAB and/or Excel to obtain quick solutions. Students and working professionals will find NNuummeerriiccaall AAnnaallyyssiiss UUssiinngg MMAATTLLAABB®® aanndd EExxcceell®®,, TThhiirrdd EEddiittiioonn , to be a concise and easy-to-learn text. It provides com- plete, clear, and detailed explanations of the principal numerical analysis methods and well known functions used in science and engineering. These are illustrated with many real-world examples. Numerical Analysis Using MATLAB® and Excel® Third Edition $60.00 USA ISBN-10: 1-9934404-004-77 Numerical Analysis Using MATLAB® and Excel® Third Edition Steven T. Karris Orchard Publications www.orchardpublications.com Numerical Analysis Using MATLAB® and Excel®, Third Edition Copyright ” 2007 Orchard Publications. All rights reserved. Printed in the United States of America. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a data base or retrieval system, without the prior written permission of the publisher. Direct all inquiries to Orchard Publications, info@orchardpublications.com Product and corporate names are trademarks or registered trademarks of the Microsoft™ Corporation and The MathWorks™, Inc. They are used only for identification and explanation, without intent to infringe. Library of Congress Cataloging-in-Publication Data Library of Congress Control Number: 2007922100 Copyright TX 5-589-152 ISBN-13: 978-1-934404-04-1 ISBN-10: 1-934404-04-7 Disclaimer The author has made every effort to make this text as complete and accurate as possible, but no warranty is implied. The author and publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this text. Preface Numerical analysis is the branch of mathematics that is used to find approximations to difficult problems such as finding the roots of non − linear equations, integration involving complex expressions and solving differential equations for which analytical solutions do not exist. It is applied to a wide variety of disciplines such as business, all fields of engineering, computer science, education, geology, meteorology, and others. Years ago, high − speed computers did not exist, and if they did, the largest corporations could only afford them; consequently, the manual computation required lots of time and hard work. But now that computers have become indispensable for research work in science, engineering and other fields, numerical analysis has become a much easier and more pleasant task. This book is written primarily for students/readers who have a good background of high − school algebra, geometry, trigonometry, and the fundamentals of differential and integral calculus. * A prior knowledge of differential equations is desirable but not necessary; this topic is reviewed in Chapter 5. One can use Fortran, Pascal, C, or Visual Basic or even a spreadsheet to solve a difficult problem. It is the opinion of this author that the best applications programs for solving engineering problems are 1) MATLAB which is capable of performing advanced mathematical and engineering computations, and 2) the Microsoft Excel spreadsheet since the versatility offered by spreadsheets have revolutionized the personal computer industry. We will assume that the reader has no prior knowledge of MATLAB and limited familiarity with Excel. We intend to teach the student/reader how to use MATLAB via practical examples and for detailed explanations he/she will be referred to an Excel reference book or the MATLAB User’s Guide. The MATLAB commands, functions, and statements used in this text can be executed with either MATLAB Student Version 12 or later. Our discussions are based on a PC with Windows XP platforms but if you have another platform such as Macintosh, please refer to the appropriate sections of the MATLAB’s User Guide that also contains instructions for installation. MATLAB is an acronym for MATrix LABoratory and it is a very large computer application which is divided to several special application fields referred to as toolboxes. In this book we will be using the toolboxes furnished with the Student Edition of MATLAB. As of this writing, the latest release is MATLAB Student Version Release 14 and includes SIMULINK which is a * These topics are discussed in Mathematics for Business, Science, and Technology, Third Edition, ISBN 0 − 9709511 − 0 − 8. This text includes probability and other advanced topics which are supplemented by many practical applications using Microsoft Excel and MATLAB. software package used for modeling, simulating, and analyzing dynamic systems. SIMULINK is not discussed in this text; the interested reader may refer to Introduction to Simulink with Engineering Applications, ISBN 0 − 9744239 − 7 − 1. Additional information including purchasing the software may be obtained from The MathWorks, Inc., 3 Apple Hill Drive, Natick, MA 01760 − 2098. Phone: 508 647 − 7000, Fax: 508 647 − 7001, e − mail: info@mathwork.com and web site http://www.mathworks.com. The author makes no claim to originality of content or of treatment, but has taken care to present definitions, statements of physical laws, theorems, and problems. Chapter 1 is an introduction to MATLAB. The discussion is based on MATLAB Student Version 5 and it is also applicable to Version 6. Chapter 2 discusses root approximations by numerical methods. Chapter 3 is a review of sinusoids and complex numbers. Chapter 4 is an introduction to matrices and methods of solving simultaneous algebraic equations using Excel and MATLAB. Chapter 5 is an abbreviated, yet practical introduction to differential equations, state variables, state equations, eigenvalues and eigenvectors. Chapter 6 discusses the Taylor and Maclaurin series. Chapter 7 begins with finite differences and interpolation methods. It concludes with applications using MATLAB. Chapter 8 is an introduction to linear and parabolic regression. Chapters 9 and 10 discuss numerical methods for differentiation and integration respectively. Chapter 11 is a brief introduction to difference equations with a few practical applications. Chapters 12 is devoted to partial fraction expansion. Chapters 13, 14, and 15 discuss certain interesting functions that find wide application in science, engineering, and probability. This text concludes with Chapter 16 which discusses three popular optimization methods. New to the Third Edition This is an extensive revision of the first edition. The most notable changes are the inclusion of Fourier series, orthogonal functions and factorization methods, and the solutions to all end − of − chapter exercises. It is in response to many readers who expressed a desire to obtain the solutions in order to check their solutions to those of the author and thereby enhancing their knowledge. Another reason is that this text is written also for self − study by practicing engineers who need a review before taking more advanced courses such as digital image processing. The author has prepared more exercises and they are available with their solutions to those instructors who adopt this text for their class. Another change is the addition of a rather comprehensive summary at the end of each chapter. Hopefully, this will be a valuable aid to instructors for preparation of view foils for presenting the material to their class. The last major change is the improvement of the plots generated by the latest revisions of the MATLAB® Student Version, Release 14. Orchard Publications Fremont, California www.orchardpublications.com info@orchardpublications.com Numerical Analysis Using MATLAB® and Excel®, Third Edition i Copyright © Orchard Publications Table of Contents 1 Introduction to MATLAB 1−1 1.1 Command Window 1−1 1.2 Roots of Polynomials 1−3 1.3 Polynomial Construction from Known Roots 1−4 1.4 Evaluation of a Polynomial at Specified Values 1−5 1.5 Rational Polynomials 1−8 1.6 Using MATLAB to Make Plots 1−9 1.7 Subplots 1−18 1.8 Multiplication, Division and Exponentiation 1−19 1.9 Script and Function Files 1−26 1.10 Display Formats 1−31 1.11 Summary 1−33 1.12 Exercises 1−37 1.13 Solutions to End−of−Chapter Exercises 1−38 MATLAB Computations: Entire chapter 2 Root Approximations 2−1 2.1 Newton’s Method for Root Approximation 2−1 2.2 Approximations with Spreadsheets 2−7 2.3 The Bisection Method for Root Approximation 2−19 2.4 Summary 2−27 2.5 Exercises 2−28 2.6 Solutions to End−of−Chapter Exercises 2−29 MATLAB Computations: Pages 2 −2 through 2−7, 2−14, 2−21 through 2−23, 2−29 through 2−34 Excel Computations: Pages 2 −8 through 2−19, 2−24 through 2−26 3 Sinusoids and Phasors 3−1 3.1 Alternating Voltages and Currents 3−1 3.2 Characteristics of Sinusoids 3−2 3.3 Inverse Trigonometric Functions 3 −10 3.4 Phasors 3 −10 3.5 Addition and Subtraction of Phasors 3 −11 3.6 Multiplication of Phasors 3 −12 3.7 Division of Phasors 3 −13 ii Numerical Analysis Using MATLAB® and Excel®, Third Edition Copyright © Orchard Publications 3.8 Exponential and Polar Forms of Phasors 3−13 3.9 Summary 3−24 3.10 Exercises 3−27 3.11 Solutions to End−of−Chapter Exercises 3−28 MATLAB Computations: Pages 3−15 through 3−23, 3−28 through 3−31 Simulink Modeling: Pages 3−16 through 3−23 4 Matrices and Determinants 4−1 4.1 Matrix Definition 4−1 4.2 Matrix Operations 4−2 4.3 Special Forms of Matrices 4−5 4.4 Determinants 4−9 4.5 Minors and Cofactors 4−13 4.6 Cramer’s Rule 4−18 4.7 Gaussian Elimination Method 4−20 4.8 The Adjoint of a Matrix 4−22 4.9 Singular and Non−Singular Matrices 4−22 4.10 The Inverse of a Matrix 4−23 4.11 Solution of Simultaneous Equations with Matrices 4−25 4.12 Summary 4−32 4.13 Exercises 4−36 4.14 Solutions to End−of−Chapter Exercises 4−38 MATLAB Computations: Pages 4−3, 4−5 through 4−8, 4−10, 4−12, 4−3, 4−5, 4−19 through 4−20, 4−24, 4−26, 4−28, 4−30, 4−38, 4−41, 4−43 Excel Computations: Pages 4−28 through 4−29, 4−42 through 4−43 5 Differential Equations, State Variables, and State Equations 5−1 5.1 Simple Differential Equations 5 −1 5.2 Classification 5−2 5.3 Solutions of Ordinary Differential Equations (ODE) 5 −6 5.4 Solution of the Homogeneous ODE 5 −8 5.5 Using the Method of Undetermined Coefficients for the Forced Response 5−10 5.6 Using the Method of Variation of Parameters for the Forced Response 5 −20 5.7 Expressing Differential Equations in State Equation Form 5 −24 5.8 Solution of Single State Equations 5−27 5.9 The State Transition Matrix 5 −28 5.10 Computation of the State Transition Matrix 5 −30 5.11 Eigenvectors 5 −38 5.12 Summary 5−42 Numerical Analysis Using MATLAB® and Excel®, Third Edition iii Copyright © Orchard Publications 5.13 Exercises 5−47 5.14 Solutions to End−of−Chapter Exercises 5−49 MATLAB Computations: Pages 5 −11, 5−13 through 5−14, 5−16 through 5−17, 5 −19, 5−23, 5−33 through 5−35, 5−37, 5−49 through 5−53, 5−55 6 Fourier, Taylor, and Maclaurin Series 6−1 6.1 Wave Analysis 6−1 6.2 Evaluation of the Coefficients 6−2 6.3 Symmetry 6−7 6.4 Waveforms in Trigonometric Form of Fourier Series 6−12 6.5 Alternate Forms of the Trigonometric Fourier Series 6−25 6.6 The Exponential Form of the Fourier Series 6−29 6.7 Line Spectra 6−33 6.8 Numerical Evaluation of Fourier Coefficients 6−36 6.9 Power Series Expansion of Functions 6−40 6.10 Taylor and Maclaurin Series 6−41 6.11 Summary 6−48 6.12 Exercises 6−51 6.13 Solutions to End−of−Chapter Exercises 6−53 MATLAB Computations: Pages 6−35, 6−45, 6−58 through 6−61 Excel Computations: Pages 6−37 through 6−39 7 Finite Differences and Interpolation 7−1 7.1 Divided Differences 7−1 7.2 Factorial Polynomials 7−6 7.3 Antidifferences 7−12 7.4 Newton’s Divided Difference Interpolation Method 7−15 7.5 Lagrange’s Interpolation Method 7 −17 7.6 Gregory−Newton Forward Interpolation Method 7−19 7.7 Gregory −Newton Backward Interpolation Method 7−21 7.8 Interpolation with MATLAB 7 −24 7.9 Summary 7 −39 7.10 Exercises 7−44 7.11 Solutions to End −of−Chapter Exercises 7−45 MATLAB Computations: Pages 7−8 through 7−9, 7−13 through 7−15, 7 −26 through 7−38, 7−45 through 7−46, 7 −48, 7−50, 7−52 Excel Computations: Pages 7 −17 through 7−19, 7−22 through 7−25, 7−49, 7−52 iv Numerical Analysis Using MATLAB® and Excel®, Third Edition Copyright © Orchard Publications 8 Linear and Parabolic Regression 8−1 8.1 Curve Fitting 8−1 8.2 Linear Regression 8−2 8.3 Parabolic Regression 8−7 8.4 Regression with Power Series Approximations 8−14 8.5 Summary 8−24 8.6 Exercises 8−26 8.7 Solutions to End−of−Chapter Exercises 8−28 MATLAB Computations: Pages 8−11 through 8−14, 8−17 through 8−23, 8−30 through 8−34 Excel Computations: Pages 8−5 through 8−10, 8−15 through 8−19, 8−28 through 8−32 9 Solution of Differential Equations by Numerical Methods 9−1 9.1 Taylor Series Method 9−1 9.2 Runge−Kutta Method 9−5 9.3 Adams’ Method 9−13 9.4 Milne’s Method 9−15 9.5 Summary 9−17 9.6 Exercises 9−20 9.7 Solutions to End−of−Chapter Exercises 9−21 MATLAB Computations: Pages 9−5, 9−9 through 9−12, 9−21 through 9−23 Excel Computations: Page 9−2, 9−14, 9−22 through 9−26 10 Integration by Numerical Methods 10−1 10.1 The Trapezoidal Rule 10−1 10.2 Simpson’s Rule 10 −6 10.3 Summary 10 −14 10.4 Exercises 10 −15 10.5 Solution to End−of−Chapter Exercises 10−16 MATLAB Computations: Pages 10−3 through 10−6, 10−9 through 10−13, 10 −16, 10−18 through 10−21 Excel Computations: Pages 10 −10, 10−19 through 10−21 11 Difference Equations 11−1 11.1 Introduction 11−1 11.2 Definition, Solutions, and Applications 11−1 11.3 Fibonacci Numbers 11 −7 [...]... 1 dB and since 3 dB ≅ power ratio of 2 and 1 dB ≅ power ratio of 1.25 then, 4 dB ≅ ratio of ( 2 × 1.25 ) = ratio of 2.5 Likewise, 27 dB = 20 dB + 7 dB and this is equivalent to a power ratio of approximately 100 × 5 = 500 Using the relations 2 y = log x = 2 log x and 2 2 P = V- = I Z -Z if we let Z = 1 , the dB values for voltage and current ratios become Numerical Analysis Using MATLAB and Excel ,... num=[1 −3 0 5 7 9]; den=[2 0 −8 0 4 10 12];% Do not display num and den coefficients roots_num=roots(num), roots_den=roots(den) % Display num and den roots roots_num = 2.4186 + 1.0712i -0 .3370 + 0.9961i 2.4186 - 1.0712i -0 .3370 - 0.9961i roots_den = 1.6760 + 0.4922i -0 .2108 + 0.9870i 1.6760 - 0.4922i -0 .2108 - 0.9870i -1 .1633 -1 .9304 -1 .0000 As expected, the complex roots occur in complex conjugate... B−20 MATLAB Computations and Simulink Modeling: Entire Appendix B C Ill-Conditioned Matrices C−1 C.1 The Norm of a Matrix C−1 C.2 Condition Number of a Matrix .C−2 C.3 Hilbert Matrices C−3 vi Numerical Analysis Using MATLAB and Excel , Third Edition Copyright © Orchard Publications MATLAB Computations: Pages C−1, C−4 through C−5 References Index Numerical Analysis Using. .. between upper− and lower−case letters Thus, t and T are two different characters in MATLAB language The files that we create are saved with the file name we use and the extension m; for example, myfile01.m It is a good * EDU>> is the MATLAB prompt in the Student Version Numerical Analysis Using MATLAB and Excel , Third Edition Copyright © Orchard Publications 1−1 Chapter 1 Introduction to MATLAB practice... operating system, and remains in effect unless canceled or overridden by the operator Numerical Analysis Using MATLAB and Excel , Third Edition Copyright © Orchard Publications 1−11 Chapter 1 Introduction to MATLAB box off: This command removes the box (the solid lines which enclose the plot), and box on restores the box The command box toggles them The default is on title(‘string’): This command adds a... p2=[2 0 −8 0 4 10 12]; p1p2=conv(p1,p2) p1p2 = 2 -6 -8 34 18 -2 4 -7 4 -8 8 78 166 174 108 Therefore, 1−6 Numerical Analysis Using MATLAB and Excel , Third Edition Copyright © Orchard Publications Evaluation of a Polynomial at Specified Values p 1 Þ p 2 = 2x 11 – 6x 10 5 9 8 7 – 8x + 34x + 18x – 24x 4 3 6 2 – 74x – 88x + 78x + 166x + 174x + 108 We can write MATLAB statements in one line if we separate them... the command window, we click on the Close button When we are done and want to leave MATLAB, we type quit or exit But if we want to clear all previous values, variables, and equations without exiting, we should use the clear command This command erases everything; it is like exiting MATLAB and starting it again The clc command clears the screen but MATLAB still remembers all values, variables and equations... have denoted the polynomial as p1, and the roots as roots_ p1 p1=[1 −10 35 −50 24] % Specify the coefficients of p1(x) p1 = 1 -1 0 35 -5 0 24 roots_ p1=roots(p1) % Find the roots of p1(x) roots_p1 = 4.0000 3.0000 2.0000 1.0000 We observe that MATLAB displays the polynomial coefficients as a row vector, and the roots as a column vector Numerical Analysis Using MATLAB and Excel , Third Edition Copyright... displays Helvetica Font: User inputs at MATLAB s command window prompt EDU>>* Helvetica Bold: MATLAB functions Bold Italic: Important terms and facts, notes, and file names When we first start MATLAB, we see the toolbar on top of the command screen and the prompt EDU>> This prompt is displayed also after execution of a command; MATLAB now waits for a new command from the user We can use the Editor/Debugger... x and y* The three−dimensional plot is shown in Figure 1.5 3000 2000 1000 0 -1 000 -2 000 10 5 0 -5 -1 0 -1 0 -5 0 5 10 Figure 1.5 Three dimensional plot for Example 1.11 * This statement uses the so called dot multiplication, dot division, and dot exponentiation where these operations are preceded by a dot (period) These operations will be explained in Section 1.8, Page 1−19 1−16 Numerical Analysis Using . must save our program with a file name which starts with a letter. Impor- tant! MATLAB is case sensitive, that is, it distinguishes between upper− and lower−case let- ters. Thus, t and T are two. returns to the command window. 3. To execute a program, we type the file name without the .m extension at the EDU>> prompt; then, we press <enter> and observe the execution and the values. more information on this topic. Henceforth, it will be understood that each input command is typed after the EDU>> prompt and followed by the <enter> key. The command help matlab iofun

Ngày đăng: 08/04/2014, 10:22

Từ khóa liên quan

Mục lục

  • Cover Page

  • Back Page

  • Title Page

  • ISBN 1934404047

  • Preface

  • Table of Contents

  • 1 Introduction to MATLAB

    • 1.1 Command Window

    • 1.2 Roots of Polynomials

    • 1.3 Polynomial Construction from Known Roots

    • 1.4 Evaluation of a Polynomial at Specified Values

    • 1.5 Rational Polynomials

    • 1.6 Using MATLAB to Make Plots

    • 1.7 Subplots

    • 1.8 Multiplication, Division and Exponentiation

    • 1.9 Script and Function Files

    • 1.10 Display Formats

    • 1.11 Summary

    • 1.12 Exercises

    • 1.13 Solutions to End-of-Chapter Exercises

    • 2 Root Approximations

      • 2.1 Newton’s Method for Root Approximation

Tài liệu cùng người dùng

Tài liệu liên quan