Example: bachelor of science

NUMERICAL METHODS IN ENGINEERING WITH MATLAB

NUMERICAL METHODS in ENGINEERING with MATLAB NUMERICAL METHODS in ENGINEERING with MATLAB is a text for engineer-ing students and a reference for practicing engineers, especially thosewho wish to explore the power and efficiency of MATLAB . The choice ofnumerical METHODS was based on their relevance to ENGINEERING prob-lems. Every method is discussed thoroughly and illustrated with prob-lems involving both hand computation and programming. MATLABM-files accompany each method and are available on the book website. This code is made simple and easy to understand by avoiding com-plex book-keeping schemes, while maintaining the essential features ofthe method. MATLAB , was chosen as the example language because ofits ubiquitous use in ENGINEERING studies and practice.

numerical methods: solution of equations, interpolation and data fitting, numerical ... 1 Introduction to MATLAB 1.1 General Information Quick Overview Thischapteris not intended to be a comprehensive manualofMATLAB R. Our sole aim istoprovidesufficient information to give youagood start. If youarefamiliar

Tags:

  Introduction, Methods, Numerical, Numerical methods

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of NUMERICAL METHODS IN ENGINEERING WITH MATLAB

1 NUMERICAL METHODS in ENGINEERING with MATLAB NUMERICAL METHODS in ENGINEERING with MATLAB is a text for engineer-ing students and a reference for practicing engineers, especially thosewho wish to explore the power and efficiency of MATLAB . The choice ofnumerical METHODS was based on their relevance to ENGINEERING prob-lems. Every method is discussed thoroughly and illustrated with prob-lems involving both hand computation and programming. MATLABM-files accompany each method and are available on the book website. This code is made simple and easy to understand by avoiding com-plex book-keeping schemes, while maintaining the essential features ofthe method. MATLAB , was chosen as the example language because ofits ubiquitous use in ENGINEERING studies and practice.

2 Moreover, it iswidely available to students on school networks and through inexpen-sive educational versions. MATLAB a popular tool for teaching Kiusalaas is a Professor Emeritus in the Department of EngineeringScience and Mechanics at the Pennsylvania State University. He hastaught NUMERICAL METHODS , including finite element and boundary el-ement METHODS for over 30 years. He is also the co-author of fourother Books ENGINEERING Mechanics: Statics, ENGINEERING Mechanics:Dynamics,Mechanics of Materials, and an alternate version of this workwith Python METHODS INENGINEERING WITHMATLAB Jaan KiusalaasThe Pennsylvania State UniversitycambridgeuniversitypressCambri dge,NewYork,Melbourne,Madrid,CapeTown,Si ngapore,S o PauloCambridgeUniversityPressThe EdinburghBuilding,Cambridgecb22ru,UKFirs tpublishedin printformatisbn-13978-0-521-85288-3isbn- 13978-0-511-12811-0 Jaan Kiusalaas20052005 Informationon this in statutoryexceptionand to the provisionofrelevantcollectivelicensingag reements,no reproductionof any part may take placewithoutthe writtenpermissionof no responsibilityfor the persistenceor accuracyofurlsfor externalor third-partyinternetwebsitesreferredto in this publication,and doesnotguaranteethat any contenton suchwebsitesis.

3 Or will remain,accurateor the UnitedStatesof Americaby CambridgeUniversityPress, (NetLibrary)eBook(NetLibrary) book is targeted primarily toward engineers and ENGINEERING students of ad-vanced standing (sophomores, seniors and graduate students). Familiarity with acomputer language is required; knowledge of basic ENGINEERING subjects is useful, butnot text attempts to place emphasis on NUMERICAL METHODS , not engineers are not programmers, but problem solvers. They want to know whatmethods can be applied to a given problem, what are their strengths and pitfalls andhow to implement them. Engineers are not expected to write computer code for basictasks from scratch; they are more likely to utilize functions and subroutines that havebeen already written and tested.

4 Thus programming by engineers is largely confinedto assembling existing pieces of code into a coherent package that solves the problemat piece of code is usually a function that implements a specific task. For theuser the details of the code are unimportant. What matters is the interface (what goesin and what comes out) and an understanding of the method on which the algorithmis based. Since no NUMERICAL algorithm is infallible, the importance of understandingthe underlying method cannot be overemphasized; it is, in fact, the rationale behindlearning NUMERICAL book attempts to conform to the views outlined above. Each numericalmethod is explained in detail and its shortcomings are pointed out. The examplesthat follow individual topics fall into two categories: hand computations that illustratethe inner workings of the method, and small programs that show how the computercode is utilized in solving a problem.

5 Problems that require programming are markedwith .The material consists of the usual topics covered in an ENGINEERING course onnumerical METHODS : solution of equations, interpolation and data fitting, numericaldifferentiation and integration, solution of ordinary differential equations and eigen-value problems. The choice of METHODS within each topic is tilted toward relevanceviiviiiPrefaceto ENGINEERING problems. For example, there is an extensive discussion of symmetric,sparsely populated coefficient matrices in the solution of simultaneous the same vein, the solution of eigenvalue problems concentrates on METHODS thatefficiently extract specific eigenvalues from banded important criterion used in the selection of METHODS was clarity. Algorithmsrequiring overly complex bookkeeping were rejected regardless of their efficiency androbustness.

6 This decision, which was taken with great reluctance, is in keeping withthe intent to avoid emphasis on selection of algorithms was also influenced by current practice. This dis-qualified several well-known historical METHODS that have been overtaken by morerecent developments. For example, the secant method for finding roots of equationswas omitted as having no advantages over Brent s method. For the same reason, themultistep METHODS used to solve differential equations ( , Milne and Adams meth-ods) were left out in favor of the adaptive Runge Kutta and Bulirsch Stoer absent is a chapter on partial differential equations. It was felt that thistopic is best treated by finite element or boundary element METHODS , which are outsidethe scope of this book. The finite difference model, which is commonly introducedin NUMERICAL METHODS texts, is just too impractical in handling multidimensionalboundary value usual, the book contains more material than can be covered in a three-creditcourse.

7 The topics that can be skipped without loss of continuity are tagged with anasterisk (*).The programs listed in this book were tested with MATLAB and underWindows XP. The source code can be downloaded from the book s website author wishes to express his gratitude to the anonymous reviewers andProfessor Andrew Pytel for their suggestions for improving the manuscript. Creditis also due to the authors ofNumerical Recipes(Cambridge University Press) whosepresentation of NUMERICAL METHODS was inspirational in writing this to InformationQuick OverviewThischapterisnotintendedtobeacom prehensivemanualofMATLABR .Oursoleaim ,and weassumethatyouare,itisnotdifficult isahigh-level computerlanguageforscientificcomputing and datavi-sualization builtaround an ateducationalinstitutionsand interactivesystemisthatprogramscan betested and debuggedquickly,allowingtheuserto concentratemoreontheprinciplesbehindthep rogram andless onprogramming thereisnoneedto com-pile, linkandexecuteaftereach correction, MATLAB programscan bedevelopedinmuch , MATLAB doesnotproduce stand-aloneapplications theprogramscan berunonlyoncomputersthathaveMATLAB other advantages over mainstreamlanguages thatcontribute torapid program development: MATLAB containsalargenumberof functionsthataccessproven numericalli-braries, ( ,solutionof simultaneousequations) can beaccomplishedwithasingle functioncall.

8 Thereisextensivegraphics supportthatallows theresults of computationstobeplottedwithafewstatement s. to MATLABThe syntaxof MATLAB resembles ideaof the similari-ties, letuscompare the codeswritteninthe twolanguages forsolutionof simultaneousequationsAx=bbyGauss the subroutinein FORTRAN90:subroutine gauss(A,b,n)use prec_modimplicit nonereal(DP), dimension(:,:), intent(in out) :: Areal(DP), dimension(:), intent(in out) :: binteger, intent(in) :: nreal(DP) :: lambdainteger :: i,k! --------------Elimination phase--------------dok=1,n-1doi=k+1,nif( A(i,k) /= 0) thenlambda = A(i,k)/A(k,k)A(i,k+1:n) = A(i,k+1:n) - lambda*A(k,k+1:n)b(i) = b(i) - lambda*b(k)end ifend doend do! ------------Back substitution phase----------dok=n,1,-1b(k) = (b(k) - sum(A(k,k+1:n)*b(k+1:n)))/A(k,k)end doreturnend subroutine gaussThe statementuse precmodtells the compilerto loadthemoduleprecmod(not shownhere),whichdefines theuse ofarraysections, suchasa(k,k+1:n),afeaturethatwasnotavail ablein equivalentMATLAB functionis( MATLAB doesnot havesubroutines):functionb=gauss(A,b)n = length(b);%-----------------Elimination phase-------------fork=1:n-1fori=k+1 General Informationif A(i,k) = 0lambda = A(i,k)/A(k,k);A(i,k+1:n) = A(i,k+1:n) - lambda*A(k,k+1:n);b(i)= b(i) - lambda*b(k);endendend%--------------Back substitution phase-----------fork=n:-1:1b(k) = (b(k) - A(k,k+1:n)*b(k+1:n))/A(k,k).

9 EndSimultaneousequationscanalsobe solvedinMATLAB with the simple commandA\b(seebelow).MATLABcan beoperatedintheinteractivemodethroughits command window,whereeach command isexecuted immediatelyuponits ofan interactive sessionforthesolutionof simultaneousequations:>>A=[210;-122;014] ;%Input3x3matrix>>b=[1;2;3]; %Inputcolumnvector>>soln=A\b %SolveA*x=bbyleftdivisionsoln = symbol>>isMATLAB spromptfor (%)marks (;)hastwofunctions:itsuppressesprintouto fintermediateresultsandseparates therowsofamatrix. Withoutaterminatingsemicolon, theresult ofacommand wouldbedisplayed. Forexample, omissionofthe last semicoloninthe linedefiningthematrixAwouldresultin>>A=[ 210;-122;014]A=210-1 2 20144 introduction to MATLABF unctionsand programscan becreatedwith the MATLAB editor/debugger andsavedwith ( MATLAB calls themM-files).

10 Thefilenameofasavedfunctionshouldbeident ical to thename of the function. Forexample,if the functionforGauss ,itcan becalledjust likeanyMATLAB function:>>A=[210;-122;014];>>b=[1;2;3]; >> soln = gauss(A,b)soln = Types and VariablesData TypesThemost commonlyusedMATLAB datatypes, orclasses,aredouble,charandlogical,all ofwhichareconsideredbyMATLAB the classdouble,whichrepresentsdouble-precis ion arrays;ascalar istreatedasa1 1 elements ofachartypearray arestrings (sequencesof characters),whereasalogicaltypearrayelem entmaycontainonly1(true) or0(false).Another importantclassisfunctionhandle, consists of the character@, followedbythename of the supposethatwehaveaMATLAB functionplot(func,x1,x2)thatplotsany functioncall toplot sinxfrom0to otherdatatypes,butwe seldomcomeacross can class ofanobject can bedisplayedwith theclasscommand.


Related search queries