1、1Copyright 2011 by yshong2YUNG-SHAN HONG,Ph.D.,PE.Office:E723Tel:26215656 ext.3260Instructor:Copyright 2015 by yshong3Objective:This course covers a variety of numerical methods and their applications in various engineering problems.Emphasis is placed on the solution of solving nonlinear equation,ma
2、trix analysis of linear and nonlinear equations,eigen-value problems,curve fitting,numerical integration and differentiations as well as interpolation methods.Pre-knowledge of Engineering Mathematics and programming skills with computer language(s)are strongly required.Copyright 2006 by yshong4Outli
3、ne and Schedule:u Introduction(2 hrs)u Mathematical modeling and engineering problem solving(2hrs)u Error and definition(2hrs)u Roots of equations(1)-bracketing methods(2hrs)u Roots of equations(2)-open methods(2hr)u Systems of nonlinear equations(2hrs)u Linear algebraic equations-mathematical and n
4、umerical method(3hrs)u Eigenvalue problems(3hrs)Copyright 2006 by yshong5Outline and Schedule:u Least squares regression(2hrs)u Interpolation-Lagrange and Newton approach(2hr)u Interpolation-spline function(2hrs)u Numerical integration general,double integral(2hrs)u Numerical integration Gauss integ
5、ral(2hrs)u Numerical solution of ordinary differential equations(2hrs)u Numerical solution of partial differential equations(2hrs)Copyright 2007 by yshong6Grading:u Ordinarily expression 40%u Homework(67 times)u Mid term exam 30%u Final term exam 30%Copyright 2006 by yshong7Textbook:Chapra,S.C.and C
6、anale,R.P.(2010),“Numerical methods for engineers”,Sixth Edition,McGRAW-Hill.Reference:u Gerad,C.F.and Wheatley,P.O.(1999),“Applied numerical analysis”,Sixth Edition,Addison-Wesley.u Schilling,R.J.and Harris,S.L.(1999),“Applied numerical methods for engineers using Matlab and C”,Brooks/Cole.u 林聰悟、林佳
7、慧(1997),“數值方法與程式”,圖文技術服務。Copyright 2009 by yshong8About the authors:Steve Chapra teaches in the Civil and Environmental Engineering Department at Tufts University.Dr.Chapra received engineering degrees from Manhattan College and the University of Michigan.Before joining the faculty at Tufts,he worke
8、d for the Environmental Protection Agency and the National Oceanic and Atmospheric Administration,and taught at Texas A&M University and the University of Colorado.His general research interests focus on surface water-quality modeling and advanced computer applications in environmental engineering.C
9、opyright 2006 by yshong9About the co-authors:Raymond P.Canale is an emeritus professor at the University of Michigan.During his over 20-year career at the university,he taught numerous courses in the area of computers,numerical methods,and environmental engineering.He also directed extensive researc
10、h programs in the area of mathematical and computer modeling of aquatic ecosystems.He has authored or coauthored several books and has published over 100 scientific papers and reports.Copyright 2006 by yshong10Why you should study numerical methods?u Numerical methods are extremely powerful problem-
11、solving tools.They are capable of handling large systems of equations,nonlinearities,and complicated geometries that are not uncommon in engineering practice and often impossible to solve analytically.u During your careers,you may often have occasion to use commercially available prepackaged that in
12、volve numerical methods.The intelligent use these programs is often predicated on knowledge of the basic theory underlying the methods.Copyright 2006 by yshong11u Many problems cannot be approached using prepackaged programs.If you are conversant with numerical methods and are adept at computer prog
13、ramming,you can design your own programs to solve problems without having to buy expensive software.u Numerical methods are an efficient vehicle for learning to use computers.Because numerical methods are for the most part designed for implementation on computers,they are ideal for this purpose.You
14、will also learn to control the errors of approximation that are part of large-scale numerical calculations.u Numerical methods provide a vehicle for you to reinforce your understanding of mathematics.Because one function of numerical methods is to reduce higher mathematics to basic arithmetic operat
15、ions.Copyright 2006 by yshong12Solutions of the problem in engineering:INTRODUCTIONINTRODUCTIONu Analytical solution:(closed form solution)Ex.Determine)(sin xdxd)(sinxdxdat x=0 let x=0 1cos)(sinxxdxd900 x(o)sinxEx.Determine d AEPLdP1?Copyright 2006 by yshong13u Numerical solution:(approximation solu
16、tion)Ex.Determine )2ln(2xxedxdxat x=10 let )2ln()(2xxexfxxf(x)101?Copyright 2006 by yshong14Numerical method:Data+Mathematical theory+computer program Approximation Copyright 2006 by yshong15Types of the problem:(a)Solution of nonlinear equation(roots of equation)059423xxx 594)(23xxxxflet xf(x)Ex.Co
17、pyright 2006 by yshong16(b)Matrix analysis(solution of linear algebratic eqs.)Ex.22221211212111puauapuaua 212122211211ppuuaaaau1u2Ex.2321043yxyxCopyright 2006 by yshong17(c)System of nonlinear eqs.Ex.x1x2 222221121122121111)()()()(cxxaxxacxxaxxa 2121222121212111)()()()(ccxxxaxaxaxaCopyright 2006 by
18、yshong18(d)Curve fittingu Regression Least squares regressionu Interpolation&ExtrapolationxyyxRegressionInterpolation&ExtrapolationCopyright 2006 by yshong19(e)Integration techniquexf(x)abIf(x)badxxfI)(p(w)spaceCopyright 2006 by yshong20(f)Ordinary differential equation(ODE)Because many physical law
19、s are couched in terms of the rate of change of a quantity rather than the magnitude of the quantity itself.Ex.tdtdy3Difference scheme viewpoint),(1ytftyytydtdyiiSolve y as a function of t),(1ytftyyiiytf(t,y)yi+1yiyRi+1titi+1tCopyright 2006 by yshong21(f)Ordinary differential equation(ODE)Additional
20、 data must be given:u Initial value problemu Boundary value problemx1f(x1)x?x1f(x1)x?x2f(x2)Copyright 2006 by yshong22(g)Partial differential equation(PDE)The behavior of a physical quantity is couched in terms of its rate of change with respect to two or more independent variables.u Elliptic solid
21、mech.,flow mech.potential),(2222yxpyuxu 0),(yxpLaplace eqs.(seepage eq.)Copyright 2006 by yshong23(g)Partial differential equation(PDE)u Parabolic consolidation,heat tuczuv122Analytical sol.0.mu 2drvvHtcT u Hyperbolic wave eqs.222221xuctuCopyright 2006 by yshong24Motivation:Numerical methods are tec
22、hniques by which mathematical problems are formulated so that they can be solved with arithmetic operations.Although there are many kinds of numerical methods,they have one common characteristic:they invariably involve large numbers of tedious arithmetic calculations.It is little wonder that with th
23、e development of fast,efficient digital computers,the role of numerical methods in engineering problem solving has increased dramatically in recent years.Copyright 2006 by yshong25Non-computer methods:(1)Solutions were derived for some problems using analytical,or exact method.Ex.0422 xxExact sol.ix
24、3121642Ex.082sin/3257xxexxx?Exact sol.Copyright 2006 by yshong26(2)Graphical solutions were used to characterize the behavior of systems.Ex.0104305222yxyx12xyx.y.x.y.The results are not very precise.Graphical techniques are often limited to problems that can be described using three or fewer dimensi
25、ons.(3)Calculators and slide rules were used to implement numerical method manually.The method used to simple engineering problems.Copyright 2006 by yshong27Numerical method:Data+Mathematical theory+computer program Approximation Complex engineering problems:Copyright 2006 by yshong28The engineering
26、 problem-solving process:Problem definitionMathematical modelNumeric or graphic resultsImplementationDataTheoryProblem-solving tools:Computers,statistics,Numerical methods,graphics,etc.Societal interfaces:Scheduling,optimization,communication,public interaction,etc.Copyright 2006 by yshong29CHAPTER
27、1 CHAPTER 1 A SIMPLE MATHEMATICAL A SIMPLE MATHEMATICAL MODELMODELA mathematical model can be broadly defined as a formulation or equation that expresses the essential features of a physical system or process in mathematical terms.In a very general sense,it can be represented as a functional relatio
28、nship of the form:Dependent variable=f(independent variables,parameters,forcing functions).(1.1)Copyright 2006 by yshong30Dependent variable=f(independent variables,parameters,forcing functions).(1.1)Where the dependent variable is a characteristic that usually reflects the behavior or state of the
29、system;the independent variables are usually dimensions,such as time and space,along which the systems behavior is being determined;the parameters are reflective of the systems properties or composition;and the forcing functions are external influences acting upon it.AEPLdd:dependent variableP:forci
30、ng functionsA,E,L:parametersCopyright 2006 by yshong31The following illustrates a physical problem how to represent by a mathematical model.According Newton second law,maF Where F=net force acting on the body(N or kg-m/sec2)m=mass of object(kg)a=its acceleration(m/sec2)(1.2)Copyright 2006 by yshong3
31、2(1.2):Where a=the dependent variable reflecting the systems behaviorF=the forcing function(net froce)m=a parameter represent a property of the system mFa(1.3)Note:this simple case there is no independent variable because we are not yet predicting how acceleration varies in time or space.Copyright 2
32、006 by yshong33To illustrate a more complex model of this kind,Newtons second law can be used to determine the terminal velocity of a free-falling body near the earths surface.The falling body will be a parachutist.(Fig.1.2)mFdtdv.(1.4)FuFdF:net force+:the object will accelerate-:the object will dec
33、elerate0:the object will remain at a constant levelCopyright 2006 by yshong34 UDFFF.(1.5)FD:the downward pull of gravityFU:the upward force of air resistance cvFU mgFD.(1.6).(1.7)g:the gravitational constant 9.8 m/s2c:drag coefficient=f(shape,surface roughness,.)Copyright 2006 by yshong35From eqs.(1
34、.4)through(1.7)combined:mcvmgdtdv vmcgdtdvor.(1.9).(1.8)Type of eq.?ODEEq.(1.9)is a differential equation that relates the acceleration of a falling object to the forces acting on it.If the parachutist is initially at rest(v=0 at t=0),that is a initial value problem.Solve eq.(1.9)forWhat type of pro
35、blem?Copyright 2006 by yshong36)1()()/(tmcecgmtv.(1.10)Note:v(t):the dependent variablet=the independent variablec,m=parametersg=the forcing function The following will illustrate the analytical solution and the numerical solution,respectively.Copyright 2006 by yshong37Ex 1.1 analytical solutionKnow
36、n:mass=68.1 kg,c=12.5 kg/sEq.(1.10)then)1(39.53)(18355.0tetvterminal velocity53.39exact sol.t(s)v(m/s)Eq.(1.10)is called an analytical,or exact solution because it exactly satisfies the original differential equation.Unfortunately,there are many mathematical models that cannot be solved exactly.In m
37、any of these cases,the only alternative is to develop a numerical solution that approximates the exact solution.Copyright 2006 by yshong38Ex 1.2 numerical solution tvtttvvtvdtdviiii0lim11.(1.11)vmcgdtdv.(1.9)So eq.(1.9):iiiiivmcgttvv11Copyright 2006 by yshong39)(11iiiiittvmcgvvWhen t=0,v=0,if step s
38、ize(time step)=2 6.192)0(1.685.128.90)2(tv 322)6.19(1.685.128.96.19)4(tvi=0i=1m/sm/sv(t=6),v(t=8),.Copyright 2006 by yshong40v(m/s)t(s)terminal velocityexact sol.numerical sol.24860Copyright 2006 by yshong41Homework:Problems 1.1,1.2 and 1.3(p.21)Due:One weekCopyright 2010 by yshong42CHAPTER 2 CHAPTE
39、R 2 PROGRAMMING AND PROGRAMMING AND SOFTWARESOFTWAREpp.25-51Copyright 2006 by yshong43CHAPTER 3 CHAPTER 3 APPROXIMATIONS AND APPROXIMATIONS AND ROUND-OFF ERRORSROUND-OFF ERRORSHow much error is present in our calculations and is it tolerable?Two major forms of numerical error:Round-off errorTruncati
40、on errorInherent errorCopyright 2006 by yshong44The concept of a significant figure.See Fig.3.1(p.53)Accuracy and precisionAccuracy refers to how closely a computed or measured value agrees with the true value.True value=2.83Precision refers to how closely individual computed or measured values agre
41、e with each other.Copyright 2006 by yshong45Fig.3.2Increasing accuracyIncreasing precision(a)(b)(c)(d)Copyright 2006 by yshong46Numerical methods should be sufficiently accurate or unbiased to meet the requirements of particular engineering problem.They also should be precise enough for adequate eng
42、ineering design.Copyright 2006 by yshong47Error definitions(1)True error Et(absolute error)Et=true value-approximationEx.Two approaches to measure length of the two objects.Approach(a):Object(a)true length=1m,measured error=1cm Approach(b):Object(b)true length=0.1m,measured error=1cmWhat is better a
43、pproach?Copyright 2006 by yshong48(2)Relative error et%100valuetrueerrortrueteEx.Two approaches to measure length of the two objects.Approach(a):Object(a)true length=1m,measured error=1cm Approach(b):Object(b)true length=0.1m,measured error=1cmApproach(a):e et=1%Approach(b):e et=10%Copyright 2006 by
44、 yshong49(3)The approximation percent relative error ea%100%100)()1()(mimimiauuuionapproximatcurrentionapproximatpreviousionapproximatcurrente.(3.5)m:iteration numberi:point,positionIterative approach characteristicvalueCal.numberCopyright 2006 by yshong50Truncation error(Chapter 4)Truncation errors
45、 are those that result from using an approximation in place of an exact mathematical procedure.For example,in Chap.1 we approximated the derivative of velocity of a falling parachutist by a finite-divided-difference eq.of the form.iiiittvvtvdtdv11.(4.1)Copyright 2006 by yshong51A truncation error wa
46、s introduced into the numerical solution because the difference eq.only approximates the true value of the derivative.In order to gain insight into the properties of such errors,we now turn to a mathematical formulation that is used widely in numerical methods to express functions in an approximate
47、fashion the Taylor series.Copyright 2006 by yshong52Taylor seriesc is between a,b,nth-order derivatives are existence for f(x),then f(x)at c can be to express following eq.using Taylor series.dttftxnxRxRncxcfcxcfcxcfcfxfxcnnnnnn)()(!1)()()!1()(.!2)(!1)()()()(1)1(2Rn(x)=remainder termCopyright 2006 b
48、y yshong53If c=0,f(x)series expressing to call Maclaurins series,dttftxnxRxRnxfxfxffxfxnnnnnn 0)(1)1(2)()(!1)()()!1()0(.!2)0(!1)0()0()(If(n-1)th-order approximate,then Rn(x)refers to truncation errorCopyright 2006 by yshong54Ex.Use fourth-order Maclaurin series expansions to approximate the function
49、 xexf)(Predict the functions value at x=1.Sol:let f(x)=ex,f(x)=f(x)=f(x)=f(4)(x)=ex,f(0)=1,f(x)=f(x)=f(x)=f(4)(x)=1Maclaurin expansion series:.!4)0(!3)0(!2)0(!1)0()0()(4)4(32 xfxfxfxffxfCopyright 2006 by yshong55Expressing to fourth-order 432424161211)(xxxxxf 70833.22465241612111)1(4fBut 71828.2)(11
50、exfx truncation error=2.71828-2.70833=0.00995Copyright 2006 by yshong56In a similar manner,the complete Taylor series expansion:nniiiniiiiiiiiiiiRxxnxfxxxfxxxfxxxfxfxf 11)1(31)3(2111)()!1()(.)(!3)()(!2)()()()(.(4.5)If we simplify the Taylor series,)()()(11iiiiixxxfxfxfRefer to first-order approximat